PHP Класс 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().
Показать файл
Открыть проект
Примеры использования класса
Открытые свойства
Свойство |
Тип |
Описание |
|
$components |
array |
Other Components this component uses. |
|
$request |
Cake\Network\Request |
Request object |
|
$response |
Cake\Network\Response |
Response object |
|
Защищенные свойства (Protected)
Свойство |
Тип |
Описание |
|
$_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. |
|
Открытые методы
Описание методов
__construct()
публичный метод
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()
публичный метод
Returns an array that can be used to describe the internal state of this
object.
Magic method for lazy loading $components.
implementedEvents()
публичный метод
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.
initialize()
публичный метод
Implement this method to avoid having to overwrite
the constructor and call parent.
Описание свойств
$_componentMap защищенное свойство
A component lookup table used to lazy load component objects.
protected array $_componentMap |
Результат |
array |
|
$_defaultConfig защищенное свойство
These are merged with user-provided config when the component is used.
protected array $_defaultConfig |
Результат |
array |
|
$_registry защищенное свойство
Component registry class used to lazy load components.
protected ComponentRegistry,Cake\Controller $_registry |
Результат |
Cake\Controller\ComponentRegistry |
|
$components публичное свойство
Other Components this component uses.
public array $components |
Результат |
array |
|
$request публичное свойство
public Request,Cake\Network $request |
Результат |
Cake\Network\Request |
|
$response публичное свойство
public Response,Cake\Network $response |
Результат |
Cake\Network\Response |
|