Skip to content

Instantly share code, notes, and snippets.

@hhamon
Created April 27, 2012 15:52
Show Gist options
  • Save hhamon/2510338 to your computer and use it in GitHub Desktop.
Save hhamon/2510338 to your computer and use it in GitHub Desktop.
Listenning to the bootstrap MVC event
<?php
namespace NewModule;
use Zend\EventManager\StaticEventManager;
use Zend\EventManager\EventDescription as Event;
use Zend\EventManager\StaticEventManager;
class Module
{
public function init(ModuleManager $manager)
{
$events = StaticEventManager::getInstance();
$events->attach('bootstrap', 'bootstrap', array($this, 'configureView'));
}
public function configureView(Event $e)
{
die('triggered');
}
}
@hhamon
Copy link
Author

hhamon commented Apr 27, 2012

The fix is as follow:

<?php

namespace NewModule;

use Zend\EventManager\StaticEventManager;
use Zend\EventManager\EventDescription as Event;
use Zend\EventManager\StaticEventManager;

class Module
{
    public function init(ModuleManager $manager)
    {
        $events = $manager->events();

        $sharedEvents = $events->getSharedCollections();
        $sharedEvents->attach('bootstrap', 'bootstrap', array($this, 'configureView'));
    }

    public function configureView(Event $e)
    {
        die('triggered');
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment