PHP Class Cake\Controller\Component

### Initialize hook Like Controller and Table, this class has an initialize() hook that you can use to add custom 'constructor' logic. It is important to remember that each request (and sub-request) will only make one instance of any given component. ### Life cycle callbacks Components can provide several callbacks that are fired at various stages of the request cycle. The available callbacks are: - beforeFilter(Event $event) Called before the controller's beforeFilter method by default. - startup(Event $event) Called after the controller's beforeFilter method, and before the controller action is called. - beforeRender(Event $event) Called before the Controller beforeRender, and before the view class is loaded. - shutdown(Event $event) Called after the action is complete and the view has been rendered but before Controller::afterFilter(). - beforeRedirect(Event $event $url, Response $response) Called before a redirect is done. Allows you to change the URL that will be redirected to by returning a Response instance with new URL set using Response::location(). Redirection can be prevented by stopping the event propagation. While the controller is not an explicit argument for the callback methods it is the subject of each event and can be fetched using Event::subject().
See also: Cake\Controller\Controller::$components
Inheritance: implements Cake\Event\EventListenerInterface, use trait Cake\Core\InstanceConfigTrait, use trait Cake\Log\LogTrait
Afficher le fichier Open project: cakephp/cakephp Class Usage Examples

Méthodes publiques

Свойство Type Description
$components array Other Components this component uses.
$request Cake\Network\Request Request object
$response Cake\Network\Response Response object

Protected Properties

Свойство Type Description
$_componentMap array A component lookup table used to lazy load component objects.
$_defaultConfig array These are merged with user-provided config when the component is used.
$_registry Cake\Controller\ComponentRegistry Component registry class used to lazy load components.

Méthodes publiques

Méthode Description
__construct ( Cake\Controller\ComponentRegistry $registry, array $config = [] ) Constructor
__debugInfo ( ) : array Returns an array that can be used to describe the internal state of this object.
__get ( string $name ) : mixed Magic method for lazy loading $components.
implementedEvents ( ) : array Get the Controller callbacks this Component is interested in.
initialize ( array $config ) : void Constructor hook method.

Method Details

__construct() public méthode

Constructor
public __construct ( Cake\Controller\ComponentRegistry $registry, array $config = [] )
$registry Cake\Controller\ComponentRegistry A ComponentRegistry this component can use to lazy load its components
$config array Array of configuration settings.

__debugInfo() public méthode

Returns an array that can be used to describe the internal state of this object.
public __debugInfo ( ) : array
Résultat array

__get() public méthode

Magic method for lazy loading $components.
public __get ( string $name ) : mixed
$name string Name of component to get.
Résultat mixed A Component object or null.

implementedEvents() public méthode

Uses Conventions to map controller events to standard component callback method names. By defining one of the callback methods a component is assumed to be interested in the related event. Override this method if you need to add non-conventional event listeners. Or if you want components to listen to non-standard events.
public implementedEvents ( ) : array
Résultat array

initialize() public méthode

Implement this method to avoid having to overwrite the constructor and call parent.
public initialize ( array $config ) : void
$config array The configuration settings provided to this component.
Résultat void

Property Details

$_componentMap protected_oe property

A component lookup table used to lazy load component objects.
protected array $_componentMap
Résultat array

$_defaultConfig protected_oe property

These are merged with user-provided config when the component is used.
protected array $_defaultConfig
Résultat array

$_registry protected_oe property

Component registry class used to lazy load components.
protected ComponentRegistry,Cake\Controller $_registry
Résultat Cake\Controller\ComponentRegistry

$components public_oe property

Other Components this component uses.
public array $components
Résultat array

$request public_oe property

Request object
public Request,Cake\Network $request
Résultat Cake\Network\Request

$response public_oe property

Response object
public Response,Cake\Network $response
Résultat Cake\Network\Response