Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
[zendframework/zendframework#1] simplify aggregate priority
Browse files Browse the repository at this point in the history
- Default to 1, allowing removal of a case statement and code
  duplication in each strategy
- Requires that the EventManager::attachAggregate $priority argument
  also defaults to 1
  • Loading branch information
weierophinney committed Feb 28, 2012
1 parent 43dd724 commit 8cbb1a1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
9 changes: 2 additions & 7 deletions src/Strategy/FeedStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,11 @@ public function __construct(FeedRenderer $renderer)
* Attach the aggregate to the specified event manager
*
* @param EventCollection $events
* @param int $priority
* @return void
*/
public function attach(EventCollection $events, $priority = null)
public function attach(EventCollection $events, $priority = 1)
{
if (null === $priority) {
$this->listeners[] = $events->attach('renderer', array($this, 'selectRenderer'));
$this->listeners[] = $events->attach('response', array($this, 'injectResponse'));
return;
}

$this->listeners[] = $events->attach('renderer', array($this, 'selectRenderer'), $priority);
$this->listeners[] = $events->attach('response', array($this, 'injectResponse'), $priority);
}
Expand Down
9 changes: 2 additions & 7 deletions src/Strategy/JsonStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,11 @@ public function __construct(JsonRenderer $renderer)
* Attach the aggregate to the specified event manager
*
* @param EventCollection $events
* @param int $priority
* @return void
*/
public function attach(EventCollection $events, $priority = null)
public function attach(EventCollection $events, $priority = 1)
{
if (null === $priority) {
$this->listeners[] = $events->attach('renderer', array($this, 'selectRenderer'));
$this->listeners[] = $events->attach('response', array($this, 'injectResponse'));
return;
}

$this->listeners[] = $events->attach('renderer', array($this, 'selectRenderer'), $priority);
$this->listeners[] = $events->attach('response', array($this, 'injectResponse'), $priority);
}
Expand Down
9 changes: 2 additions & 7 deletions src/Strategy/PhpRendererStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,11 @@ public function getContentPlaceholders()
* Attach the aggregate to the specified event manager
*
* @param EventCollection $events
* @param int $priority
* @return void
*/
public function attach(EventCollection $events, $priority = null)
public function attach(EventCollection $events, $priority = 1)
{
if (null === $priority) {
$this->listeners[] = $events->attach('renderer', array($this, 'selectRenderer'));
$this->listeners[] = $events->attach('response', array($this, 'injectResponse'));
return;
}

$this->listeners[] = $events->attach('renderer', array($this, 'selectRenderer'), $priority);
$this->listeners[] = $events->attach('response', array($this, 'injectResponse'), $priority);
}
Expand Down

0 comments on commit 8cbb1a1

Please sign in to comment.