ICanBoogie
  • Documentation
  • API Reference
  • Routing 4.0.x
Namespaces
  • ICanBoogie
    • Routing
      • Controller
      • Route
      • RouteDispatcher
Classes
  • ClosureController
  • Controller
  • FormattedRoute
  • Helpers
  • Pattern
  • Route
  • RouteCollection
  • RouteDefinition
  • RouteDispatcher
  • RouteMaker
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\Prototyped
┗ ICanBoogie\Routing\Controller

Direct known subclasses

ICanBoogie\Routing\ClosureController

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 ) : ICanBoogie\HTTP\Request

Returns

ICanBoogie\HTTP\Request
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 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 action( ICanBoogie\HTTP\Request $request ) : ICanBoogie\HTTP\Response|mixed

Performs the proper action for the request.

Performs the proper action for the request.

Parameters

$request

Returns

ICanBoogie\HTTP\Response|mixed
public redirect( ICanBoogie\Routing\Route|string $url, integer $status = Status::FOUND, 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 ICanBoogie\Routing\Status::FOUND, 302).
$headers
Additional headers.

Returns

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

Forwards the request.

Forwards the request.

Parameters

$destination

Returns

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

Forwards dispatching to another router.

Forwards dispatching to another router.

Parameters

$route

Returns

ICanBoogie\HTTP\Response|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.

Routing 4.0.x – Check on GitHub – API documentation generated by ApiGen