Permalink
Browse files

added phpdoc

added default name in SendResponseEvent
removed unused factories
  • Loading branch information...
1 parent 011ecde commit 2d48e88c73f5de96693da5383bf678cf629dd5f1 @prolic prolic committed Dec 9, 2012
@@ -281,7 +281,7 @@ public function run()
$response = $result->last();
if ($response instanceof ResponseInterface) {
$event->setTarget($this);
- $this->setResponse($response);
+ $event->setResponse($response);
$events->trigger(MvcEvent::EVENT_FINISH, $event);
return $response;
}
@@ -301,13 +301,13 @@ public function run()
$response = $result->last();
if ($response instanceof ResponseInterface) {
$event->setTarget($this);
- $this->setResponse($response);
+ $event->setResponse($response);
$events->trigger(MvcEvent::EVENT_FINISH, $event);
return $response;
}
$response = $this->getResponse();
- $this->setResponse($response);
+ $event->setResponse($response);
return $this->completeRequest($event);
}
@@ -329,19 +329,4 @@ protected function completeRequest(MvcEvent $event)
$events->trigger(MvcEvent::EVENT_FINISH, $event);
return $event->getResponse();
}
-
- /**
- * Set response object in mvc event and service manager
- *
- * @param \Zend\Stdlib\ResponseInterface $response
- */
- protected function setResponse(ResponseInterface $response)
- {
- $serviceManager = $this->getServiceManager();
- $serviceManager->setAllowOverride(true);
- $serviceManager->setService('Response', $response);
- $serviceManager->setAllowOverride(false);
- $this->getMvcEvent()->setResponse($response);
- $this->response = $response;
- }
}
@@ -1,9 +1,22 @@
<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Mvc
+ */
namespace Zend\Mvc\ResponseSender;
use Zend\Console\Response;
+/**
+ * @category Zend
+ * @package Zend_Mvc
+ * @subpackage ResponseSender
+ */
class ConsoleResponseSender implements ResponseSenderInterface
{
/**
@@ -1,11 +1,24 @@
<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Mvc
+ */
namespace Zend\Mvc\ResponseSender;
use Zend\Mvc\ResponseSender\SendResponseEvent;
use Zend\Http\Header\MultipleHeaderInterface;
use Zend\Http\PhpEnvironment\Response;
+/**
+ * @category Zend
+ * @package Zend_Mvc
+ * @subpackage ResponseSender
+ */
class PhpEnvironmentResponseSender implements ResponseSenderInterface
{
/**
@@ -1,9 +1,22 @@
<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Mvc
+ */
namespace Zend\Mvc\ResponseSender;
use Zend\Mvc\ResponseSender\SendResponseEvent;;
+/**
+ * @category Zend
+ * @package Zend_Mvc
+ * @subpackage ResponseSender
+ */
interface ResponseSenderInterface
{
/**
@@ -1,19 +1,37 @@
<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Mvc
+ */
namespace Zend\Mvc\ResponseSender;
use Zend\EventManager\Event;
use Zend\Stdlib\ResponseInterface;
+/**
+ * @category Zend
+ * @package Zend_Mvc
+ * @subpackage ResponseSender
+ */
class SendResponseEvent extends Event
{
/**#@+
* Mvc events triggered by eventmanager
*/
- const SEND_RESPONSE = 'sendResponse';
+ const EVENT_SEND_RESPONSE = 'sendResponse';
/**#@-*/
/**
+ * @var string Event name
+ */
+ protected $name = 'sendResponse';
+
+ /**
* @var ResponseInterface
*/
protected $response;
@@ -112,7 +112,6 @@ public function sendResponse(MvcEvent $e)
return; // there is no response to send
}
$event = new SendResponseEvent();
- $event->setName(SendResponseEvent::SEND_RESPONSE);
$event->setResponse($response);
$event->setTarget($this);
$this->getEventManager()->trigger($event);
@@ -126,8 +125,8 @@ public function sendResponse(MvcEvent $e)
protected function attachDefaultListeners()
{
$events = $this->getEventManager();
- $events->attach(SendResponseEvent::SEND_RESPONSE, new PhpEnvironmentResponseSender(), -1000);
- $events->attach(SendResponseEvent::SEND_RESPONSE, new ConsoleResponseSender(), -2000);
+ $events->attach(SendResponseEvent::EVENT_SEND_RESPONSE, new PhpEnvironmentResponseSender(), -1000);
+ $events->attach(SendResponseEvent::EVENT_SEND_RESPONSE, new ConsoleResponseSender(), -2000);
//$events->attach(SendResponseEvent::SEND_RESPONSE, new StreamResponseSender(), -3000);
}
@@ -1,47 +0,0 @@
-<?php
-
-namespace Zend\Mvc\Service;
-
-use Zend\Mvc\Exception;
-use Zend\ServiceManager\FactoryInterface;
-use Zend\ServiceManager\ServiceLocatorInterface;
-
-class ResponseSenderFactory implements FactoryInterface
-{
- /**
- * @var array
- */
- protected $defaultOptions = array(
- 'Zend\Http\PhpEnvironment\Response' => 'Zend\Mvc\ResponseSender\PhpEnvironmentResponseSender',
- 'Zend\Console\Response' => 'Zend\Mvc\ResponseSender\ConsoleResponseSender',
- );
-
- /**
- * Create response sender based on current response class
- *
- * @param ServiceLocatorInterface $serviceLocator
- * @return \Zend\Mvc\ResponseSender\ResponseSenderInterface
- * @throws Exception\RuntimeException
- */
- public function createService(ServiceLocatorInterface $serviceLocator)
- {
- $config = $serviceLocator->get('Config');
- if (isset($config['response_sender'])) {
- $options = array_merge($this->defaultOptions, $config['response_sender']);
- } else {
- $options = $this->defaultOptions;
- }
- $response = $serviceLocator->get('Response');
- $responseClass = get_class($response);
- if (!isset($options[$responseClass])) {
- throw new Exception\RuntimeException(
- 'No response sender for given response class "' . $responseClass . '" available.'
- );
- }
- $responseSender = new $options[$responseClass];
- /* @var $responseSender \Zend\Mvc\ResponseSender\ResponseSenderInterface */
- $responseSender->setResponse($response);
- return $responseSender;
- }
-
-}
@@ -56,7 +56,6 @@ class ServiceListenerFactory implements FactoryInterface
'HttpRouter' => 'Zend\Mvc\Service\RouterFactory',
'Request' => 'Zend\Mvc\Service\RequestFactory',
'Response' => 'Zend\Mvc\Service\ResponseFactory',
- 'ResponseSender' => 'Zend\Mvc\Service\ResponseSenderFactory',
'Router' => 'Zend\Mvc\Service\RouterFactory',
'ViewHelperManager' => 'Zend\Mvc\Service\ViewHelperManagerFactory',
'ViewFeedRenderer' => 'Zend\Mvc\Service\ViewFeedRendererFactory',
@@ -74,7 +73,6 @@ class ServiceListenerFactory implements FactoryInterface
'Di' => 'DependencyInjector',
'Zend\Di\LocatorInterface' => 'DependencyInjector',
'Zend\Mvc\Controller\PluginManager' => 'ControllerPluginManager',
- 'Zend\Mvc\ResponseSender\ResponseSenderInterface' => 'ResponseSender',
'Zend\View\Resolver\TemplateMapResolver' => 'ViewTemplateMapResolver',
'Zend\View\Resolver\TemplatePathStack' => 'ViewTemplatePathStack',
'Zend\View\Resolver\AggregateResolver' => 'ViewResolver',

0 comments on commit 2d48e88

Please sign in to comment.