Autodoc
  • Namespace
  • Class
  • Tree

Namespaces

  • BlueTihi
    • Context
  • Brickrouge
    • Element
      • Nodes
    • Renderer
    • Widget
  • ICanBoogie
    • ActiveRecord
    • AutoConfig
    • CLDR
    • Composer
    • Core
    • Event
    • Exception
    • HTTP
      • Dispatcher
      • Request
    • I18n
      • Translator
    • Mailer
    • Modules
      • Taxonomy
        • Support
      • Thumbnailer
        • Versions
    • Object
    • Operation
      • Dispatcher
    • Prototype
    • Routes
    • Routing
      • Dispatcher
    • Session
  • Icybee
    • ActiveRecord
      • Model
    • ConfigOperation
    • Document
    • EditBlock
    • Element
      • ActionbarContextual
      • ActionbarSearch
      • ActionbarToolbar
    • FormBlock
    • Installer
    • ManageBlock
    • Modules
      • Articles
      • Cache
        • Collection
        • ManageBlock
      • Comments
        • ManageBlock
      • Contents
        • ManageBlock
      • Dashboard
      • Editor
        • Collection
      • Files
        • File
        • ManageBlock
      • Forms
        • Form
        • ManageBlock
      • I18n
      • Images
        • ManageBlock
      • Members
      • Modules
        • ManageBlock
      • Nodes
        • ManageBlock
        • Module
      • Pages
        • BreadcrumbElement
        • LanguagesElement
        • ManageBlock
        • NavigationBranchElement
        • NavigationElement
        • Page
        • PageController
      • Registry
      • Search
      • Seo
      • Sites
        • ManageBlock
      • Taxonomy
        • Terms
          • ManageBlock
        • Vocabulary
          • ManageBlock
      • Users
        • ManageBlock
        • NonceLogin
        • Roles
      • Views
        • ActiveRecordProvider
        • Collection
        • View
    • Operation
      • ActiveRecord
      • Constructor
      • Module
      • Widget
    • Rendering
  • None
  • Patron
  • PHP

Classes

  • CacheControlHeader
  • CallableDispatcher
  • ContentDispositionHeader
  • ContentTypeHeader
  • DateHeader
  • Dispatcher
  • File
  • FileList
  • Header
  • HeaderParameter
  • Headers
  • Helpers
  • RedirectResponse
  • Request
  • Response
  • WeightedDispatcher

Interfaces

  • IDispatcher

Exceptions

  • ForceRedirect
  • HTTPError
  • MethodNotSupported
  • NotFound
  • ServiceUnavailable
  • StatusCodeNotValid

Functions

  • dispatch
  • get_dispatcher
  • get_initial_request

Class Dispatcher

Dispatches requests.

Events:

  • ICanBoogie\HTTP\Dispatcher::dispatch:before: ICanBoogie\HTTP\Dispatcher\BeforeDispatchEvent.
  • ICanBoogie\HTTP\Dispatcher::dispatch: ICanBoogie\HTTP\Dispatcher\DispatchEvent.
  • ICanBoogie\HTTP\Dispatcher::rescue: ICanBoogie\Exception\RescueEvent.
ICanBoogie\HTTP\Dispatcher implements ArrayAccess, IteratorAggregate, ICanBoogie\HTTP\IDispatcher
Namespace: ICanBoogie\HTTP
Located at vendor/icanboogie/http/lib/dispatcher.php

Methods summary

public
# __construct( array $dispatchers = array() )

Initialiazes the ICanBoogie\HTTP\Dispatcher::$dispatchers property.

Initialiazes the ICanBoogie\HTTP\Dispatcher::$dispatchers property.

Dispatchers can be defined as callable or class name. If a dispatcher definition is not a callable it is used as class name to instantiate a dispatcher.

public ICanBoogie\HTTP\Response
# __invoke( ICanBoogie\HTTP\Request $request )

Dispatches the request to retrieve a ICanBoogie\HTTP\Response.

Dispatches the request to retrieve a ICanBoogie\HTTP\Response.

The request is dispatched by the ICanBoogie\HTTP\dispatch() method. If an exception is thrown during the dispatch the ICanBoogie\HTTP\Dispatcher::rescue() method is used to rescue the exception and retrieve a ICanBoogie\HTTP\Response.

HEAD requests

If a ICanBoogie\HTTP\NotFound exception is caught during the dispatching of a request with a ICanBoogie\HTTP\Request::METHOD_HEAD method the following happens:

1. The request is cloned and the method of the cloned request is changed to ICanBoogie\HTTP\Request::METHOD_GET. 2. The cloned method is dispatched. 3. If the result is not a ICanBoogie\HTTP\Response instance, the result is returned. 4. Otherwise, a new ICanBoogie\HTTP\Response instance is created with a null body, but the status code and headers of the original response. 5. The new response is returned.

Parameters

$request
ICanBoogie\HTTP\Request
$request

Returns

ICanBoogie\HTTP\Response

Implementation of

ICanBoogie\HTTP\IDispatcher::__invoke()
public `true`
# offsetExists( string $dispatcher_id )

Checks if the dispatcher is defined.

Checks if the dispatcher is defined.

Parameters

$dispatcher_id
string
$dispatcher_id The identifier of the dispatcher.

Returns

`true`
if the dispatcher is defined, false otherwise.

Implementation of

ArrayAccess::offsetExists()
public
# offsetGet( string $dispatcher_id )

Returns a dispatcher.

Returns a dispatcher.

Parameters

$dispatcher_id
string
$dispatcher_id The identifier of the dispatcher.

Implementation of

ArrayAccess::offsetGet()
public
# offsetSet( string $dispatcher_id, mixed $dispatcher )

Defines a dispatcher.

Defines a dispatcher.

Parameters

$dispatcher_id
string
$dispatcher_id The identifier of the dispatcher.
$dispatcher
mixed
$dispatcher The dispatcher class or callback.

Implementation of

ArrayAccess::offsetSet()
public
# offsetUnset( string $dispatcher_id )

Removes a dispatcher.

Removes a dispatcher.

Parameters

$dispatcher_id
string
$dispatcher_id The identifier of the dispatcher.

Implementation of

ArrayAccess::offsetUnset()
public
# getIterator( )

Implementation of

IteratorAggregate::getIterator()
protected ICanBoogie\HTTP\Response
# dispatch( ICanBoogie\HTTP\Request $request )

Dispatches a request using the defined dispatchers.

Dispatches a request using the defined dispatchers.

The method iterates over the defined dispatchers until one of them returns a ICanBoogie\HTTP\Response instance. If an exception is throw during the dispatcher execution and the dispatcher implements the ICanBoogie\HTTP\IDispatcher interface then its ICanBoogie\HTTP\IDispatcher::rescue() method is invoked to rescue the exception, otherwise the exception is just rethrown.

ICanBoogie\HTTP\Dispatcher\BeforeDispatchEvent is fired before dispatchers are traversed. If a response is provided the dispatchers are skipped.

ICanBoogie\HTTP\Dispatcher\DispatchEvent is fired before the response is returned. The event is fired event if the dispatchers didn't return a response. It's the last chance to get one.

Parameters

$request
ICanBoogie\HTTP\Request
$request

Returns

ICanBoogie\HTTP\Response

Throws

ICanBoogie\HTTP\NotFound
when neither the events nor the dispatchers were able to provide a ICanBoogie\HTTP\Response.
public ICanBoogie\HTTP\Response
# rescue( Exception $exception, ICanBoogie\HTTP\Request $request )

Tries to get a ICanBoogie\HTTP\Response object from an exception.

Tries to get a ICanBoogie\HTTP\Response object from an exception.

ICanBoogie\Exception\RescueEvent is fired with the exception as target. The response provided by one of the event hooks is returned. If there is no response the exception is thrown again.

If a response is finaly obtained, the X-ICanBoogie-Rescued-Exception header is added to indicate where the exception was thrown from.

Parameters

$exception
Exception
$exception The exception to rescue.
$request
ICanBoogie\HTTP\Request
$request The current request.

Returns

ICanBoogie\HTTP\Response

Throws

Exception
The exception is rethrown if it could not be rescued.

Implementation of

ICanBoogie\HTTP\IDispatcher::rescue()

Magic methods summary

Properties summary

protected array[string]callable|string $dispatchers
#

The dispatchers called during the dispatching of the request.

The dispatchers called during the dispatching of the request.

protected array[string]mixed $dispatchers_weight
#

The weights of the dispatchers.

The weights of the dispatchers.

protected mixed $dispatchers_order
#
Autodoc API documentation generated by ApiGen 2.8.0