Changeset 9165
- Timestamp:
- 05/22/08 08:02:24 (5 years ago)
- Files:
-
- branches/1.1/lib/event/sfEventDispatcher.class.php (modified) (2 diffs)
- branches/1.1/lib/util/sfBrowser.class.php (modified) (2 diffs)
- branches/1.1/test/functional/sfTestBrowserTest.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/event/sfEventDispatcher.class.php
r8146 r9165 4 4 * This file is part of the symfony package. 5 5 * (c) Fabien Potencier <fabien.potencier@symfony-project.com> 6 * 6 * 7 7 * For the full copyright and license information, please view the LICENSE 8 8 * file that was distributed with this source code. … … 155 155 return $this->listeners[$name]; 156 156 } 157 158 /** 159 * Get the entire listeners stack. 160 * 161 * @return array The complete array of event names and listeners 162 */ 163 public function getListenerStack() 164 { 165 return $this->listeners; 166 } 157 167 } branches/1.1/lib/util/sfBrowser.class.php
r9074 r9165 405 405 { 406 406 $currentConfiguration = $this->context->getConfiguration(); 407 $configuration = ProjectConfiguration::getApplicationConfiguration($currentConfiguration->getApplication(), $currentConfiguration->getEnvironment(), $currentConfiguration->isDebug(), $currentConfiguration->getRootDir() , $currentConfiguration->getEventDispatcher());407 $configuration = ProjectConfiguration::getApplicationConfiguration($currentConfiguration->getApplication(), $currentConfiguration->getEnvironment(), $currentConfiguration->isDebug(), $currentConfiguration->getRootDir()); 408 408 $this->context = sfContext::createInstance($configuration); 409 410 // copy in any missing listeners 411 $dispatcher = $configuration->getEventDispatcher(); 412 foreach ($currentConfiguration->getEventDispatcher()->getListenerStack() as $name => $listeners) 413 { 414 foreach (array_diff($listeners, $dispatcher->getListeners($name)) as $listener) 415 { 416 $dispatcher->connect($name, $listener); 417 } 418 } 409 419 } 410 420 else … … 412 422 $this->context = sfContext::getInstance(); 413 423 $this->context->initialize($this->context->getConfiguration()); 414 }415 416 $this->context->getEventDispatcher()->connect('application.throw_exception', array($this, 'ListenToException')); 424 $this->context->getEventDispatcher()->connect('application.throw_exception', array($this, 'ListenToException')); 425 } 426 417 427 unset($currentConfiguration); 418 428 } branches/1.1/test/functional/sfTestBrowserTest.php
r9074 r9165 108 108 $b->get('/browser'); 109 109 $b->test()->ok($b->getContext()->getEventDispatcher()->hasListeners('my_event'), 'event listeners persist across multiple requests'); 110 111 // check consistency of number of listeners 112 $nb = count($b->getContext()->getEventDispatcher()->getListeners('application.throw_exception')); 113 $b->get('/browser'); 114 $b->test()->is(count($b->getContext()->getEventDispatcher()->getListeners('application.throw_exception')), $nb, 'event listeners are not duplicated');