class Component implements ContainerAwareInterface, EventManagerAwareInterface

组件基类

通过 $this->{serviceName} 访问属性的方式访问所有注册到容器中的服务

Properties

ContainerInterface $container
EventManagerInterface $eventManager

Methods

setContainer(ContainerInterface $container)

设置依赖注入容器

getContainer()

No description

setEventManager(EventManagerInterface $eventManager)

设置事件管理器

mixed
trigger(string|EventInterface $event, mixed $data = null)

触发事件

__get(string $name)

获取容器本身,或者获取容器中的某个服务

Details

at line 33
setContainer(ContainerInterface $container)

设置依赖注入容器

Parameters

ContainerInterface $container 容器对象实例

at line 41
ContainerInterface getContainer()

Return Value

ContainerInterface

at line 49
setEventManager(EventManagerInterface $eventManager)

设置事件管理器

Parameters

EventManagerInterface $eventManager

at line 57
EventManagerInterface getEventManager()

Return Value

EventManagerInterface

at line 77
mixed trigger(string|EventInterface $event, mixed $data = null)

触发事件

$this->trigger('application.exception', $data);

$event = new Event('application.boot', $data);
$this->trigger($event);

Parameters

string|EventInterface $event 事件名称或事件对象实例
mixed $data 事件相关数据

Return Value

mixed

at line 88
ContainerInterface|mixed __get(string $name)

获取容器本身,或者获取容器中的某个服务

Parameters

string $name

Return Value

ContainerInterface|mixed