mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-25 23:04:51 +02:00
Remove method write() from Icinga\Web\Session\SessionNamespace
This commit is contained in:
parent
c00dbf9f46
commit
6f988cb94c
@ -121,7 +121,7 @@ class PhpSession extends Session
|
|||||||
|
|
||||||
foreach ($_SESSION as $key => $value) {
|
foreach ($_SESSION as $key => $value) {
|
||||||
if (strpos($key, self::NAMESPACE_PREFIX) === 0) {
|
if (strpos($key, self::NAMESPACE_PREFIX) === 0) {
|
||||||
$namespace = new SessionNamespace($this);
|
$namespace = new SessionNamespace();
|
||||||
$namespace->setAll($value);
|
$namespace->setAll($value);
|
||||||
$this->namespaces[substr($key, strlen(self::NAMESPACE_PREFIX))] = $namespace;
|
$this->namespaces[substr($key, strlen(self::NAMESPACE_PREFIX))] = $namespace;
|
||||||
} else {
|
} else {
|
||||||
|
@ -75,7 +75,7 @@ abstract class Session extends SessionNamespace
|
|||||||
unset($this->removedNamespaces[array_search($identifier, $this->removedNamespaces)]);
|
unset($this->removedNamespaces[array_search($identifier, $this->removedNamespaces)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->namespaces[$identifier] = new SessionNamespace($this);
|
$this->namespaces[$identifier] = new SessionNamespace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->namespaces[$identifier];
|
return $this->namespaces[$identifier];
|
||||||
|
@ -14,13 +14,6 @@ use IteratorAggregate;
|
|||||||
*/
|
*/
|
||||||
class SessionNamespace implements IteratorAggregate
|
class SessionNamespace implements IteratorAggregate
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The session this namespace is associated to
|
|
||||||
*
|
|
||||||
* @var Session
|
|
||||||
*/
|
|
||||||
protected $session;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The actual values stored in this container
|
* The actual values stored in this container
|
||||||
*
|
*
|
||||||
@ -35,16 +28,6 @@ class SessionNamespace implements IteratorAggregate
|
|||||||
*/
|
*/
|
||||||
protected $removed = array();
|
protected $removed = array();
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new session namespace
|
|
||||||
*
|
|
||||||
* @param Session $session The session this namespace is associated to
|
|
||||||
*/
|
|
||||||
public function __construct(Session $session = null)
|
|
||||||
{
|
|
||||||
$this->session = $session;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an iterator for all values in this namespace
|
* Return an iterator for all values in this namespace
|
||||||
*
|
*
|
||||||
@ -197,18 +180,6 @@ class SessionNamespace implements IteratorAggregate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Save the session this namespace is associated to
|
|
||||||
*/
|
|
||||||
public function write()
|
|
||||||
{
|
|
||||||
if (!$this->session) {
|
|
||||||
throw new IcingaException('Cannot save, session not set');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->session->write();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether the session namespace has been changed
|
* Return whether the session namespace has been changed
|
||||||
*
|
*
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
namespace Tests\Icinga\Web\Session;
|
namespace Tests\Icinga\Web\Session;
|
||||||
|
|
||||||
use Mockery;
|
|
||||||
use Icinga\Test\BaseTestCase;
|
use Icinga\Test\BaseTestCase;
|
||||||
use Icinga\Web\Session\SessionNamespace;
|
use Icinga\Web\Session\SessionNamespace;
|
||||||
|
|
||||||
@ -85,26 +84,4 @@ class SessionNamespaceTest extends BaseTestCase
|
|||||||
$this->assertEquals($value, $values[$key]);
|
$this->assertEquals($value, $values[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException Icinga\Exception\IcingaException
|
|
||||||
* @expectedExceptionMessage Cannot save, session not set
|
|
||||||
*/
|
|
||||||
public function testInvalidParentWrite()
|
|
||||||
{
|
|
||||||
$ns = new SessionNamespace();
|
|
||||||
$ns->write();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check whether it is possible to write a namespace's parent
|
|
||||||
*/
|
|
||||||
public function testValidParentWrite()
|
|
||||||
{
|
|
||||||
$sessionMock = Mockery::mock('Icinga\Web\Session\Session');
|
|
||||||
$sessionMock->shouldReceive('write')->atLeast()->times(1);
|
|
||||||
|
|
||||||
$ns = new SessionNamespace($sessionMock);
|
|
||||||
$ns->write();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user