Permalink
Browse files

Forward #3452

Conflicts:
	library/Zend/Mvc/Controller/Plugin/PostRedirectGet.php
  • Loading branch information...
Maks3w committed Jan 16, 2013
2 parents 64d00bb + 46100cd commit d80d0760e5929367bef1ebfd3571db55e991e0a8
@@ -15,7 +15,6 @@
use IteratorAggregate;
use Zend\Session\Container;
use Zend\Session\ManagerInterface as Manager;
-use Zend\Session\SessionManager;
use Zend\Stdlib\SplQueue;
/**
@@ -79,7 +78,7 @@ public function setSessionManager(Manager $manager)
public function getSessionManager()
{
if (!$this->session instanceof Manager) {
- $this->setSessionManager(new SessionManager());
+ $this->setSessionManager(Container::getDefaultManager());
}
return $this->session;
}
@@ -28,6 +28,24 @@ class PostRedirectGet extends AbstractPlugin
*/
protected $sessionContainer;
+ /**
+ * Perform PRG logic
+ *
+ * If a null value is present for the $redirect, the current route is
+ * retrieved and use to generate the URL for redirect.
+ *
+ * If the request method is POST, creates a session container set to expire
+ * after 1 hop containing the values of the POST. It then redirects to the
+ * specified URL using a status 303.
+ *
+ * If the request method is GET, checks to see if we have values in the
+ * session container, and, if so, returns them; otherwise, it returns a
+ * boolean false.
+ *
+ * @param null|string $redirect
+ * @param bool $redirectToUrl
+ * @return \Zend\Http\Response|array|Traversable|false
+ */
public function __invoke($redirect = null, $redirectToUrl = false)
{
$controller = $this->getController();
@@ -11,7 +11,6 @@
namespace Zend\Session;
use Zend\EventManager\EventManagerInterface;
-use Zend\Session\SaveHandler\SaveHandlerInterface;
/**
* Session ManagerInterface implementation utilizing ext/session
@@ -43,14 +42,17 @@ class SessionManager extends AbstractManager
protected $validatorChain;
/**
- * Destructor
- * Ensures that writeClose is called.
+ * Constructor
*
- * @return void
+ * @param Config\ConfigInterface|null $config
+ * @param Storage\StorageInterface|null $storage
+ * @param SaveHandler\SaveHandlerInterface|null $saveHandler
+ * @throws Exception\RuntimeException
*/
- public function __destruct()
+ public function __construct(Config\ConfigInterface $config = null, Storage\StorageInterface $storage = null, SaveHandler\SaveHandlerInterface $saveHandler = null)
{
- $this->writeClose();
+ parent::__construct($config, $storage, $saveHandler);
+ register_shutdown_function(array($this, 'writeClose'));
}
/**
@@ -89,7 +91,7 @@ public function start($preserveStorage = false)
}
$saveHandler = $this->getSaveHandler();
- if ($saveHandler instanceof SaveHandlerInterface) {
+ if ($saveHandler instanceof SaveHandler\SaveHandlerInterface) {
// register the session handler with ext/session
$this->registerSaveHandler($saveHandler);
}
@@ -27,6 +27,11 @@ public function setUp()
$this->helper->setSessionManager($this->session);
}
+ public function tearDown()
+ {
+ $this->session->getStorage()->clear();
+ }
+
public function seedMessages()
{
$helper = new FlashMessenger();
@@ -65,7 +65,8 @@ public function setUp()
$this->sessionManager->destroy();
$this->controller->setEvent($this->event);
- $this->controller->flashMessenger()->setSessionManager($this->sessionManager);
+ $plugins = $this->controller->getPluginManager();
+ $plugins->get('flashmessenger')->setSessionManager($this->sessionManager);
}
public function testReturnsFalseOnIntialGet()
@@ -326,18 +326,6 @@ public function testCallingWriteCloseMarksStorageAsImmutable()
$this->assertTrue($storage->isImmutable());
}
- /**
- * @runInSeparateProcess
- */
- public function testCallingDestructorMarksStorageAsImmutable()
- {
- $this->manager->start();
- $storage = $this->manager->getStorage();
- $storage['foo'] = 'bar';
- $this->manager = null;
- $this->assertTrue($storage->isImmutable());
- }
-
/**
* @runInSeparateProcess
*/
@@ -15,7 +15,9 @@
class TestSaveHandlerWithValidator implements SaveHandler
{
public function open($save_path, $name)
- {return true;}
+ {
+ return true;
+ }
public function close()
{}

0 comments on commit d80d076

Please sign in to comment.