![]() You can also pass the URL as an array: $vars = $this->requestAction() Passing other request data $viewHtml = $this->requestAction('/articles/popular', ) You should use URL formats that are compatible with Router::reverse() ExamplesĪ basic example getting the return value of the controller action: $variables = $this->requestAction('/articles/popular') Ī basic example of request action to fetch a rendered page without the layout. ![]() Under the hood this method uses Router::reverse() to convert the $url parameter into a string URL. requestAction can be used to return rendered views or fetch the return value from controller actions. Can be used to connect controllers together or tie plugins into a main application. RequestAction() source public requestAction( string|array $url, array $extra )Ĭalls a controller's method from any location. Cake\Controller\ComponentRegistry|null $components optional null The component registry. Cake\Event\EventManager|null $eventManager optional null The event manager. string|null $name optional null Override the name useful in testing when using mocks. Cake\Network\Response $response optional null Response object for this controller. Can be null for testing, but expect that features that use the request parameters will not work. Parameters Cake\Http\ServerRequest $request optional null To override the conventions CakePHP uses you can define properties in your class declaration. Sets a number of properties based on conventions if they are empty. _construct() source public _construct( Cake\Http\ServerRequest $request null, Cake\Network\Response $response null, string|null $name null, Cake\Event\EventManager|null $eventManager null, Cake\Controller\ComponentRegistry|null $components null )
0 Comments
Leave a Reply. |