ICanBoogie/Routing v2.4.0
  • Namespace
  • Class

Namespaces

  • ICanBoogie
    • Routing
      • Controller
      • Dispatcher
      • Route

Classes

  • ActionController
  • Controller
  • Dispatcher
  • FormattedRoute
  • Helpers
  • Pattern
  • Route
  • Routes

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\Object
Extended by ICanBoogie\Routing\Controller

Direct known subclasses

ICanBoogie\Routing\ActionController

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
# get_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
protected mixed
# last_chance_get( string $property, boolean & $success )

Tries to get the undefined property from the application.

Tries to get the undefined property from the application.

Parameters

$property
$success

Returns

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

Redirects the request.

Redirects the request.

Parameters

$url
The URL to redirect the request to.
$status
Status code (defaults to 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.

public read-only ICanBoogie\Core $app

The application.

public read-only ICanBoogie\Module $module

The module defining the route. (This getter is provided by the icanboogie/module package)

public read-only ICanBoogie\ActiveRecord\Model $model

The primary model of the module. (This getter is provided by the icanboogie/module package)

public read-only ICanBoogie\Events $events

Provided through prototype getters or through $app.

ICanBoogie/Routing v2.4.0 API documentation generated by ApiGen