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

Commit

Permalink
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 81 deletions.
30 changes: 3 additions & 27 deletions src/Strategy/FeedStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,16 @@

namespace Zend\View\Strategy;

use Zend\EventManager\AbstractListenerAggregate;
use Zend\EventManager\EventManagerInterface;
use Zend\EventManager\ListenerAggregateInterface;
use Zend\Feed\Writer\Feed;
use Zend\Http\Request as HttpRequest;
use Zend\View\Model;
use Zend\View\Renderer\FeedRenderer;
use Zend\View\ViewEvent;

class FeedStrategy implements ListenerAggregateInterface
class FeedStrategy extends AbstractListenerAggregate
{
/**
* @var \Zend\Stdlib\CallbackHandler[]
*/
protected $listeners = array();

/**
* @var FeedRenderer
*/
Expand All @@ -40,33 +35,14 @@ public function __construct(FeedRenderer $renderer)
}

/**
* Attach the aggregate to the specified event manager
*
* @param EventManagerInterface $events
* @param int $priority
* @return void
* {@inheritDoc}
*/
public function attach(EventManagerInterface $events, $priority = 1)
{
$this->listeners[] = $events->attach(ViewEvent::EVENT_RENDERER, array($this, 'selectRenderer'), $priority);
$this->listeners[] = $events->attach(ViewEvent::EVENT_RESPONSE, array($this, 'injectResponse'), $priority);
}

/**
* Detach aggregate listeners from the specified event manager
*
* @param EventManagerInterface $events
* @return void
*/
public function detach(EventManagerInterface $events)
{
foreach ($this->listeners as $index => $listener) {
if ($events->detach($listener)) {
unset($this->listeners[$index]);
}
}
}

/**
* Detect if we should use the FeedRenderer based on model type and/or
* Accept header
Expand Down
30 changes: 3 additions & 27 deletions src/Strategy/JsonStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

namespace Zend\View\Strategy;

use Zend\EventManager\AbstractListenerAggregate;
use Zend\EventManager\EventManagerInterface;
use Zend\EventManager\ListenerAggregateInterface;
use Zend\Http\Request as HttpRequest;
use Zend\View\Model;
use Zend\View\Renderer\JsonRenderer;
use Zend\View\ViewEvent;

class JsonStrategy implements ListenerAggregateInterface
class JsonStrategy extends AbstractListenerAggregate
{
/**
* Character set for associated content-type
Expand All @@ -25,11 +25,6 @@ class JsonStrategy implements ListenerAggregateInterface
*/
protected $charset = 'utf-8';

/**
* @var \Zend\Stdlib\CallbackHandler[]
*/
protected $listeners = array();

/**
* Multibyte character sets that will trigger a binary content-transfer-encoding
*
Expand All @@ -56,33 +51,14 @@ public function __construct(JsonRenderer $renderer)
}

/**
* Attach the aggregate to the specified event manager
*
* @param EventManagerInterface $events
* @param int $priority
* @return void
* {@inheritDoc}
*/
public function attach(EventManagerInterface $events, $priority = 1)
{
$this->listeners[] = $events->attach(ViewEvent::EVENT_RENDERER, array($this, 'selectRenderer'), $priority);
$this->listeners[] = $events->attach(ViewEvent::EVENT_RESPONSE, array($this, 'injectResponse'), $priority);
}

/**
* Detach aggregate listeners from the specified event manager
*
* @param EventManagerInterface $events
* @return void
*/
public function detach(EventManagerInterface $events)
{
foreach ($this->listeners as $index => $listener) {
if ($events->detach($listener)) {
unset($this->listeners[$index]);
}
}
}

/**
* Set the content-type character set
*
Expand Down
30 changes: 3 additions & 27 deletions src/Strategy/PhpRendererStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@

namespace Zend\View\Strategy;

use Zend\EventManager\AbstractListenerAggregate;
use Zend\EventManager\EventManagerInterface;
use Zend\EventManager\ListenerAggregateInterface;
use Zend\View\Renderer\PhpRenderer;
use Zend\View\ViewEvent;

class PhpRendererStrategy implements ListenerAggregateInterface
class PhpRendererStrategy extends AbstractListenerAggregate
{
/**
* @var \Zend\Stdlib\CallbackHandler[]
*/
protected $listeners = array();

/**
* Placeholders that may hold content
*
Expand Down Expand Up @@ -76,33 +71,14 @@ public function getContentPlaceholders()
}

/**
* Attach the aggregate to the specified event manager
*
* @param EventManagerInterface $events
* @param int $priority
* @return void
* {@inheritDoc}
*/
public function attach(EventManagerInterface $events, $priority = 1)
{
$this->listeners[] = $events->attach(ViewEvent::EVENT_RENDERER, array($this, 'selectRenderer'), $priority);
$this->listeners[] = $events->attach(ViewEvent::EVENT_RESPONSE, array($this, 'injectResponse'), $priority);
}

/**
* Detach aggregate listeners from the specified event manager
*
* @param EventManagerInterface $events
* @return void
*/
public function detach(EventManagerInterface $events)
{
foreach ($this->listeners as $index => $listener) {
if ($events->detach($listener)) {
unset($this->listeners[$index]);
}
}
}

/**
* Select the PhpRenderer; typically, this will be registered last or at
* low priority.
Expand Down

0 comments on commit f443c57

Please sign in to comment.