Component (class)
Class Component
Base class for an individual Component. Components provide reusable bits of controller logic that can be composed into a controller. Components also provide request life-cycle callbacks for injecting logic at specific points.
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)
登录查看完整内容