/** * 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); * }); * } * } * * @param string $controllerName the name of the controller under which it is * stored in the DI container * @param string $methodName the method that you want to call * @since 6.0.0 */ public function dispatch($controllerName, $methodName) { \OC\AppFramework\App::main($controllerName, $methodName, $this->container); }
public function __invoke($params) { App::main($this->controllerName, $this->actionName, $this->container, $params); }
public function testCallbackIsCalled(){ $mock = $this->getMockBuilder('OCP\AppFramework\Http\ICallbackResponse') ->getMock(); $return = [null, [], [], $this->output, $mock]; $this->dispatcher->expects($this->once()) ->method('dispatch') ->with($this->equalTo($this->controller), $this->equalTo($this->controllerMethod)) ->will($this->returnValue($return)); $mock->expects($this->once()) ->method('callback'); App::main($this->controllerName, $this->controllerMethod, $this->container, []); }