如何与DataCollector和EventSubscriberInterface进行通信

时间:2018-05-21 08:58:56

标签: events collect

我想收集订阅者事件中的数据,然后将其输出到collect function()。

class MyDataCollector extends DataCollector implements EventSubscriberInterface
{
public static function getSubscribedEvents()
    {
        return array(
             EventTypes::LOAD => 'providerLoad',
             ....
     }               

public static function create(EventDispatcherInterface $eventDispatcher)
    {
        $collector = new static();

        $eventDispatcher->addSubscriber($collector);

        return $collector;
    }
}

0 个答案:

没有答案