CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.1 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.1
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 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

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
    • Network
      • Email
      • Http
    • Routing
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • Dispatcher
  • Router

Class Dispatcher

Dispatcher converts Requests into controller actions. It uses the dispatched Request to locate and load the correct controller. If found, the requested action is called on the controller.

Direct Subclasses
  • ControllerTestDispatcher
Package: Cake\Routing
Copyright: Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
License: License (http://www.opensource.org/licenses/mit-license.php)
Location: Cake/Routing/Dispatcher.php

Method Summary

  • __construct() public
    Constructor.
  • _deliverAsset() protected
    Sends an asset file to the client
  • _getController() protected
    Get controller to use, either plugin controller or application controller
  • _invoke() protected

    Initializes the components and models a controller will be using. Triggers the controller action, and invokes the rendering if Controller::$autoRender is true and echo's the output. Otherwise the return value of the controller action are returned.

  • _loadController() protected
    Load controller and return controller classname
  • _loadRoutes() protected
    Loads route configuration
  • asset() public
    Checks if a requested asset exists and sends it to the browser
  • cached() public
    Outputs cached dispatch view cache
  • dispatch() public

    Dispatches and invokes given Request, handing over control to the involved controller. If the controller is set to autoRender, via Controller::$autoRender, then Dispatcher will render the view.

  • parseParams() public

    Applies Routing and additionalParameters to the request to be dispatched. If Routes have not been loaded they will be loaded, and app/Config/routes.php will be run.

Method Detail

__construct() public ¶

__construct( string $base = false )

Constructor.

Parameters
string $base optional false
The base directory for the application. Writes App.base to Configure.

_deliverAsset() protected ¶

_deliverAsset( CakeResponse $response , string $assetFile , string $ext )

Sends an asset file to the client

Parameters
CakeResponse $response
The response object to use.
string $assetFile
Path to the asset file in the file system
string $ext
The extension of the file to determine its mime type

_getController() protected ¶

_getController( CakeRequest $request , CakeResponse $response )

Get controller to use, either plugin controller or application controller

Parameters
CakeRequest $request
Request object
CakeResponse $response
Response for the controller.
Returns
mixed
name of controller if not loaded, or object if loaded

_invoke() protected ¶

_invoke( Controller $controller , CakeRequest $request , CakeResponse $response )

Initializes the components and models a controller will be using. Triggers the controller action, and invokes the rendering if Controller::$autoRender is true and echo's the output. Otherwise the return value of the controller action are returned.

Parameters
Controller $controller
Controller to invoke
CakeRequest $request
The request object to invoke the controller for.
CakeResponse $response
The response object to receive the output

_loadController() protected ¶

_loadController( CakeRequest $request )

Load controller and return controller classname

Parameters
CakeRequest $request
Returns
string|boolean
Name of controller class name

_loadRoutes() protected ¶

_loadRoutes( )

Loads route configuration

asset() public ¶

asset( string $url , CakeResponse $response )

Checks if a requested asset exists and sends it to the browser

Parameters
string $url
Requested URL
CakeResponse $response
The response object to put the file contents in.
Returns
boolean
True on success if the asset file was found and sent

cached() public ¶

cached( string $path )

Outputs cached dispatch view cache

Parameters
string $path
Requested URL path with any query string parameters
Returns
string|boolean
False if is not cached or output

dispatch() public ¶

dispatch( CakeRequest $request , CakeResponse $response , array $additionalParams = array() )

Dispatches and invokes given Request, handing over control to the involved controller. If the controller is set to autoRender, via Controller::$autoRender, then Dispatcher will render the view.

Actions in CakePHP can be any public method on a controller, that is not declared in Controller. If you want controller methods to be public and in-accessible by URL, then prefix them with a _. For example public function _loadPosts() { } would not be accessible via URL. Private and protected methods are also not accessible via URL.

If no controller of given name can be found, invoke() will throw an exception. If the controller is found, and the action is not found an exception will be thrown.

Parameters
CakeRequest $request
Request object to dispatch.
CakeResponse $response
Response object to put the results of the dispatch into.
array $additionalParams optional array()
Settings array ("bare", "return") which is melded with the GET and POST params
Returns
boolean
Success
Throws
MissingControllerException
When the controller is missing.

parseParams() public ¶

parseParams( CakeRequest $request , array $additionalParams = array() )

Applies Routing and additionalParameters to the request to be dispatched. If Routes have not been loaded they will be loaded, and app/Config/routes.php will be run.

Parameters
CakeRequest $request
CakeRequest object to mine for parameter information.
array $additionalParams optional array()

An array of additional parameters to set to the request. Useful when Object::requestAction() is involved

Returns
CakeRequest
The request object with routing params set.
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs