ICanBoogie
  • Documentation
  • API Reference
  • Routing v2.3.0
Namespaces
  • ICanBoogie
    • Routing
      • ActionController
      • Controller
      • Dispatcher
      • Route
Classes
  • ActionController
  • Controller
  • Dispatcher
  • FormattedRoute
  • Helpers
  • Pattern
  • Route
  • Routes
Interfaces
  • Exception
  • ToSlug
Exceptions
  • ActionNotDefined
  • ControllerNotDefined
  • PatternNotDefined
  • PatternRequiresValues
  • RouteNotDefined

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
┗ ICanBoogie\Routing\Controller

Direct known subclasses

ICanBoogie\Routing\ActionController

Abstract
Namespace: ICanBoogie\Routing
Located at Controller.php

Methods summary

protected get_name( void ) : string|null

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( void )
protected get_route( void ) : ICanBoogie\Routing\Route

Returns

ICanBoogie\Routing\Route
protected lazy_get_response( void ) : ICanBoogie\HTTP\Response

Returns

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

Controls the route and returns a response.

Controls the route and returns a response.

The response is obtained by invoking respond(). 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::respond:before event of class ICanBoogie\Routing\Controller\BeforeRespondEvent is fired before invoking respond(), the ICanBoogie\Routing\Controller::respond:before event of class ICanBoogie\Routing\Controller\RespondEvent is fired after.

Parameters

$request

Returns

ICanBoogie\HTTP\Response|mixed
abstract protected respond( ICanBoogie\HTTP\Request $request ) : ICanBoogie\HTTP\Response|mixed

Respond to the request.

Respond to the request.

Parameters

$request

Returns

ICanBoogie\HTTP\Response|mixed
protected last_chance_get( string $property, boolean & $success ) : mixed

Tries to get the undefined property from the application.

Tries to get the undefined property from the application.

Parameters

$property
$success

Returns

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

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
protected forward_to( ICanBoogie\Routing\Route|mixed $destination ) : mixed

Forwards the request.

Forwards the request.

Parameters

$destination

Returns

mixed

Properties summary

Magic properties

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

The name of the controller.

public read-only $request : ICanBoogie\HTTP\Request

The request being dispatched.

public read-only $route : ICanBoogie\Routing\Route

The route being dispatched.

public read-only $app : ICanBoogie\Core

The application.

public read-only $module : ICanBoogie\Module

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

public read-only $model : ICanBoogie\ActiveRecord\Model

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

public read-only $events : ICanBoogie\Events

Provided through prototype getters or through $app.

Routing v2.3.0 – Check on GitHub – API documentation generated by ApiGen