\OCP\AppFrameworkApp

Class App

Summary

Methods
Properties
Constants
buildAppNamespace()
__construct()
getContainer()
registerRoutes()
dispatch()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$container
N/A

Properties

$container

$container : 

Type

Methods

buildAppNamespace()

buildAppNamespace(string  $appId, string  $topNamespace = 'OCA\\') : string

Turns an app id into a namespace by convetion. The id is split at the underscores, all parts are camelcased and reassembled. e.g.: some_app_id -> OCA\SomeAppId

Parameters

string $appId

the app id

string $topNamespace

the namespace which should be prepended to the transformed app id, defaults to OCA\

Returns

string —

the starting namespace for the app

__construct()

__construct(  $appName, array  $urlParams = array()) 

Parameters

$appName
array $urlParams

an array with variables extracted from the routes

registerRoutes()

registerRoutes(\OCP\Route\IRouter  $router, array  $routes) 

This function is to be called to create single routes and restful routes based on the given $routes array.

Example code in routes.php of tasks app (it will register two restful resources): $routes = array( 'resources' => array( 'lists' => array('url' => '/tasklists'), 'tasks' => array('url' => '/tasklists/{listId}/tasks') ) );

$a = new TasksApp(); $a->registerRoutes($this, $routes);

Parameters

\OCP\Route\IRouter $router
array $routes

dispatch()

dispatch(string  $controllerName, string  $methodName) 

This function is called by the routing component to fire up the frameworks dispatch mechanism.

Example code in routes.php of the task app: $this->create('tasks_index', '/')->get()->action( function($params){ $app = new TaskApp($params); $app->dispatch('PageController', 'index'); } );

Example for for TaskApp implementation: class TaskApp extends \OCP\AppFramework\App {

public function __construct($params){
    parent::__construct('tasks', $params);

    $this->getContainer()->registerService('PageController', function(IAppContainer $c){
        $a = $c->query('API');
        $r = $c->query('Request');
        return new PageController($a, $r);
    });
}

}

Parameters

string $controllerName

the name of the controller under which it is stored in the DI container

string $methodName

the method that you want to call