CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.8 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.8
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Command
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
      • Retry
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • Dispatcher
  • DispatcherFactory
  • DispatcherFilter
  • RouteBuilder
  • Router

Traits

  • RequestActionTrait
 1: <?php
 2: /**
 3:  * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
 4:  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
 5:  *
 6:  * Licensed under The MIT License
 7:  * For full copyright and license information, please see the LICENSE.txt
 8:  * Redistributions of files must retain the above copyright notice.
 9:  *
10:  * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11:  * @link          https://cakephp.org CakePHP(tm) Project
12:  * @since         0.2.9
13:  * @license       https://opensource.org/licenses/mit-license.php MIT License
14:  */
15: namespace Cake\Routing;
16: 
17: use Cake\Event\EventDispatcherTrait;
18: use Cake\Event\EventListenerInterface;
19: use Cake\Http\ActionDispatcher;
20: use Cake\Http\Response;
21: use Cake\Http\ServerRequest;
22: 
23: /**
24:  * Dispatcher converts Requests into controller actions. It uses the dispatched Request
25:  * to locate and load the correct controller. If found, the requested action is called on
26:  * the controller
27:  *
28:  * @deprecated 3.6.0 Dispatcher is deprecated. You should update your application to use
29:  *   the Http\Server implementation instead.
30:  */
31: class Dispatcher
32: {
33:     use EventDispatcherTrait;
34: 
35:     /**
36:      * Connected filter objects
37:      *
38:      * @var \Cake\Event\EventListenerInterface[]
39:      */
40:     protected $_filters = [];
41: 
42:     /**
43:      * Dispatches and invokes given Request, handing over control to the involved controller. If the controller is set
44:      * to autoRender, via Controller::$autoRender, then Dispatcher will render the view.
45:      *
46:      * Actions in CakePHP can be any public method on a controller, that is not declared in Controller. If you
47:      * want controller methods to be public and in-accessible by URL, then prefix them with a `_`.
48:      * For example `public function _loadPosts() { }` would not be accessible via URL. Private and protected methods
49:      * are also not accessible via URL.
50:      *
51:      * If no controller of given name can be found, invoke() will throw an exception.
52:      * If the controller is found, and the action is not found an exception will be thrown.
53:      *
54:      * @param \Cake\Http\ServerRequest $request Request object to dispatch.
55:      * @param \Cake\Http\Response $response Response object to put the results of the dispatch into.
56:      * @return string|null if `$request['return']` is set then it returns response body, null otherwise
57:      * @throws \LogicException When the controller did not get created in the Dispatcher.beforeDispatch event.
58:      */
59:     public function dispatch(ServerRequest $request, Response $response)
60:     {
61:         deprecationWarning(
62:             'Dispatcher is deprecated. You should update your application to use ' .
63:             'the Http\Server implementation instead.'
64:         );
65:         $actionDispatcher = new ActionDispatcher(null, $this->getEventManager(), $this->_filters);
66:         $response = $actionDispatcher->dispatch($request, $response);
67:         if ($request->getParam('return', null) !== null) {
68:             return $response->body();
69:         }
70: 
71:         return $response->send();
72:     }
73: 
74:     /**
75:      * Add a filter to this dispatcher.
76:      *
77:      * The added filter will be attached to the event manager used
78:      * by this dispatcher.
79:      *
80:      * @param \Cake\Event\EventListenerInterface $filter The filter to connect. Can be
81:      *   any EventListenerInterface. Typically an instance of \Cake\Routing\DispatcherFilter.
82:      * @return void
83:      */
84:     public function addFilter(EventListenerInterface $filter)
85:     {
86:         $this->_filters[] = $filter;
87:     }
88: 
89:     /**
90:      * Get the list of connected filters.
91:      *
92:      * @return \Cake\Event\EventListenerInterface[]
93:      */
94:     public function filters()
95:     {
96:         return $this->_filters;
97:     }
98: }
99: 
Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs