ICanBoogie/Routing master
  • Namespace
  • Class

Namespaces

  • ICanBoogie
    • Routing
      • Controller
      • Route
      • RouteDispatcher

Classes

  • Controller
  • FormattedRoute
  • Helpers
  • Pattern
  • Route
  • RouteCollection
  • RouteDefinition
  • RouteDispatcher
  • RouteMaker

Interfaces

  • Exception
  • ToSlug

Exceptions

  • ActionNotDefined
  • ControllerNotDefined
  • PatternNotDefined
  • PatternRequiresValues
  • RouteNotDefined

Functions

  • absolutize_url
  • contextualize
  • decontextualize

Class Controller

A route controller.

Accessing the application's properties

The class tries to retrieve undefined properties from the application, so the following code yields the same results:

<?php

$this->app->models
# or
$this->models

But because request is defined by the controller the following code might not yield the same results:

<?php

$this->app->request
# or
$this->request
ICanBoogie\Prototyped
Extended by ICanBoogie\Routing\Controller
Abstract
Namespace: ICanBoogie\Routing
Located at Controller.php

Methods summary

protected string|null
# get_name( )

Return the name of the controller, extracted from its class name.

Return the name of the controller, extracted from its class name.

Returns

string|null

The underscored name of the controller, or null if it cannot be extracted.

protected ICanBoogie\HTTP\Request
# get_request( )

Returns

ICanBoogie\HTTP\Request
protected ICanBoogie\Routing\Route
# get_route( )

Returns

ICanBoogie\Routing\Route
protected ICanBoogie\HTTP\Response
# lazy_get_response( )

Returns

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

Controls the route and returns a response.

Controls the route and returns a response.

The response is obtained by invoking action(). When the result is a ICanBoogie\HTTP\Response instance it is returned as is, when the $response property has been initialized the result is used as its body and the response is returned, otherwise the result is returned as is.

The ICanBoogie\Routing\Controller::action:before event of class ICanBoogie\Routing\Controller\BeforeActionEvent is fired before invoking action(), the ICanBoogie\Routing\Controller::action:before event of class ICanBoogie\Routing\Controller\ActionEvent is fired after.

Parameters

$request

Returns

ICanBoogie\HTTP\Response|mixed
abstract protected ICanBoogie\HTTP\Response|mixed
# action( ICanBoogie\HTTP\Request $request )

Performs the proper action for the request.

Performs the proper action for the request.

Parameters

$request

Returns

ICanBoogie\HTTP\Response|mixed
public ICanBoogie\HTTP\RedirectResponse
# redirect( ICanBoogie\Routing\Route|string $url, integer $status = ICanBoogie\Routing\Status::FOUND, array $headers = [] )

Redirects the request.

Redirects the request.

Parameters

$url
The URL to redirect the request to.
$status
Status code (defaults to ICanBoogie\Routing\Status::FOUND, 302).
$headers
Additional headers.

Returns

ICanBoogie\HTTP\RedirectResponse
public mixed
# forward_to( ICanBoogie\Routing\Route|mixed $destination )

Forwards the request.

Forwards the request.

Parameters

$destination

Returns

mixed
protected ICanBoogie\HTTP\Response|mixed
# forward_to_route( ICanBoogie\Routing\Route $route )

Forwards dispatching to another router.

Forwards dispatching to another router.

Parameters

$route

Returns

ICanBoogie\HTTP\Response|mixed

Properties summary

Magic properties

public ICanBoogie\HTTP\Response $response
public read-only string $name

The name of the controller.

public read-only ICanBoogie\HTTP\Request $request

The request being dispatched.

public read-only ICanBoogie\Routing\Route $route

The route being dispatched.

ICanBoogie/Routing master API documentation generated by ApiGen