This repository has been archived by the owner on Jan 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated zend-view to eventmanager v3
- Uses dev-develop until we tag EM3. - Updates trigger and attach calls to follow v3. - Updates tests: - strategy tests primarily needed tooling for doing assertions on listeners and priorities after attaching aggregates (and updating aggregates to attach using the new signature). - Navigation and UrlIntegration tests were marked as incomplete as they depend on zend-mvc for testing.
- Loading branch information
1 parent
b44b831
commit 73b70d8
Showing
9 changed files
with
176 additions
and
101 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace ZendTest\View; | ||
|
||
use ReflectionProperty; | ||
use Zend\EventManager\EventManager; | ||
|
||
/** | ||
* Offer methods for introspecting event manager events and listeners. | ||
*/ | ||
trait EventManagerIntrospectionTrait | ||
{ | ||
public function getEventsFromEventManager(EventManager $events) | ||
{ | ||
$r = new ReflectionProperty($events, 'events'); | ||
$r->setAccessible(true); | ||
$listeners = $r->getValue($events); | ||
return array_keys($listeners); | ||
} | ||
|
||
public function getListenersForEvent($event, EventManager $events, $withPriority = false) | ||
{ | ||
$r = new ReflectionProperty($events, 'events'); | ||
$r->setAccessible(true); | ||
$listeners = $r->getValue($events); | ||
|
||
if (! isset($listeners[$event])) { | ||
return $this->traverseListeners([]); | ||
} | ||
|
||
return $this->traverseListeners($listeners[$event], $withPriority); | ||
} | ||
|
||
public function traverseListeners(array $queue, $withPriority = false) | ||
{ | ||
krsort($queue, SORT_NUMERIC); | ||
|
||
foreach ($queue as $priority => $listeners) { | ||
$priority = (int) $priority; | ||
foreach ($listeners as $listener) { | ||
if ($withPriority) { | ||
yield $priority => $listener; | ||
} else { | ||
yield $listener; | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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
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
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
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
Oops, something went wrong.