Cakephp 从另一个类调用helper中实现的回调

Cakephp 从另一个类调用helper中实现的回调,cakephp,events,cakephp-3.0,Cakephp,Events,Cakephp 3.0,这是我的助手的样子: public function implementedEvents() { $mapping = parent::implementedEvents(); $mapping += [ 'Helper.Layout.beforeFilter' => 'filter', ]; return $mapping; } public function filter(&$cont

这是我的助手的样子:

public function implementedEvents()
{
        $mapping = parent::implementedEvents();

        $mapping += [
            'Helper.Layout.beforeFilter' => 'filter',
        ];

        return $mapping;
}

public function filter(&$content, $options = array()) {
     ...       
}
我想从另一个类调用这些回调:

$event = new Event('Helper.Layout.beforeFilter', $View, [
      'content' => &$body,
      'options' => array()
]);
EventManager::instance()->dispatch($event);

那么,我是否需要在全局的某个地方注册这些在helper中实现的侦听器?我应该如何注册这些侦听器?

这就是我在helper类中最后所做的:

public function __construct(View $view, array $config = [])
{
        parent::__construct($view, $config);
        $this->_converter = new StringConverter();
        $this->_setupEvents();
}
然后我向全局事件管理器注册我的侦听器:

protected function _setupEvents() {
        $events = [
            'filter' => [$this, 'filter']
        ];

        foreach ($events as $callable) {
                EventManager::instance()->on("Helper.Layout.beforeFilter", $callable);
}

public function filter($event) {
 ...
}

在bootstrap.php中注册@Salines:但是如何将我的helper类作为监听器从bootstrap.php发送到“on”函数