Created
April 27, 2012 21:00
-
-
Save fritz-gerneth/2513188 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'di' => array( | |
'instance' => array( | |
'Test\Collection' => array( | |
'injections' => array( | |
'addListener' => array( | |
array('listener' => 'Test\View'), | |
), | |
) | |
), | |
), | |
'definition' => array( | |
'class' => array( | |
'Test\Collection' => array( | |
'addListener' => array( | |
'listener' => array( | |
'type' => 'Test\Listener', | |
'required' => false, | |
) | |
) | |
) | |
) | |
) | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Module | |
{ | |
public function init(Manager $moduleManager) | |
{ | |
$events = $moduleManager->events(); | |
$sharedEvents = $events->getSharedCollections(); | |
$sharedEvents->attach('Zend\Mvc\Bootstrap', 'bootstrap', array($this, 'test'), 900); | |
} | |
public function test($e) | |
{ | |
$f = $e->getParam('application')->getLocator()->get('Test\Collection'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Test; | |
use \Zend\EventManager\EventCollection, | |
\Zend\EventManager\EventManagerAware, | |
\Zend\Di\Locator; | |
class Collection //implements EventManagerAware | |
{ | |
protected $counter = 0; | |
public function __construct() | |
{ | |
} | |
public function setEventManager(EventCollection $eventManager) | |
{ | |
$eventManager->getSharedCollections()->attach('*', '*', array($this, 'onEvent')); | |
$this->counter++; | |
echo "Counter: " . $this->counter . "<br />"; | |
} | |
public function setLocator(Locator $locator) | |
{ | |
//\Zend\Debug::dump(debug_backtrace()); | |
$f = $locator->get('Test\Collection'); | |
if($f == $this) | |
{ echo "true"; } | |
} | |
public function onEvent($e) | |
{ | |
echo $e->getName() . "<br />"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Test; | |
use \Zend\EventManager\EventCollection, | |
\Zend\EventManager\EventManagerAware, | |
\Zend\Di\Locator; | |
class Collection //implements EventManagerAware | |
{ | |
protected $counter = 0; | |
public function __construct() | |
{ | |
} | |
public function setEventManager(EventCollection $eventManager) | |
{ | |
$eventManager->getSharedCollections()->attach('*', '*', array($this, 'onEvent')); | |
$this->counter++; | |
echo "Counter: " . $this->counter . "<br />"; | |
} | |
public function setLocator(Locator $locator) | |
{ | |
//\Zend\Debug::dump(debug_backtrace()); | |
$f = $locator->get('Test\Collection'); | |
if($f == $this) | |
{ echo "true"; } | |
} | |
public function onEvent($e) | |
{ | |
echo $e->getName() . "<br />"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Test; | |
use \Zend\EventManager\EventCollection, | |
\Zend\EventManager\EventManagerAware, | |
\Zend\Di\Locator; | |
class Collection //implements EventManagerAware | |
{ | |
protected $counter = 0; | |
public function __construct() | |
{ | |
} | |
public function setEventManager(EventCollection $eventManager) | |
{ | |
$eventManager->getSharedCollections()->attach('*', '*', array($this, 'onEvent')); | |
$this->counter++; | |
echo "Counter: " . $this->counter . "<br />"; | |
} | |
public function onEvent($e) | |
{ | |
echo $e->getName() . "<br />"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Test; | |
use \Zend\EventManager\EventCollection, | |
\Zend\EventManager\EventManagerAware, | |
\Zend\Di\Locator; | |
class Collection implements EventManagerAware | |
{ | |
protected $counter = 0; | |
public function __construct() | |
{ | |
} | |
public function setEventManager(EventCollection $eventManager) | |
{ | |
$eventManager->getSharedCollections()->attach('*', '*', array($this, 'onEvent')); | |
$this->counter++; | |
echo "Counter: " . $this->counter . "<br />"; | |
} | |
public function onEvent($e) | |
{ | |
echo $e->getName() . "<br />"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment