App¶
-
class
OCP\AppFramework\
App
¶ - Class AppAny application must inherit this call - all controller instances to be used areto be registered using IContainer::registerService
Source: lib/public/AppFramework/App.php#55
Properties¶
Methods¶
-
public static
OCP\AppFramework\App::
buildAppNamespace
($appId, $topNamespace=OCA\)¶ - Turns an app id into a namespace by convention. The id is split at theunderscores, all parts are CamelCased and reassembled. e.g.:some_app_id -> OCA\SomeAppId
Source: Parameters: - $appId (string) the app id
- $topNamespace (string) the namespace which should be prepended to
the transformed app id, defaults to OCA
Returns: string the starting namespace for the app
Since: 8.0.0
-
public
OCP\AppFramework\App::
__construct
($appName, $urlParams=[])¶ Source: Parameters: - $appName (string)
- $urlParams (array) an array with variables extracted from the routes
Since: 6.0.0
-
public
OCP\AppFramework\App::
getContainer
()¶ Source: lib/public/AppFramework/App.php#125 Returns: \OCP\AppFramework\IAppContainer
Since: 6.0.0
-
public
OCP\AppFramework\App::
registerRoutes
($router, $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);
Source: Parameters: - $router (
OCP\Route\IRouter
) - $routes (array)
Since: 6.0.0
Deprecated: 20.0.0 Just return an array from your routes.php
- $router (
-
public
OCP\AppFramework\App::
dispatch
($controllerName, $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);});}}
Source: Parameters: - $controllerName (string) the name of the controller under which it is
stored in the DI container * $methodName (string) the method that you want to call
Since: 6.0.0