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

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
Prepping for 2.2.0RC1.
  • Loading branch information
weierophinney committed May 1, 2013
161 parents 91105ad + e3a1818 + a31ffcc + 370a890 + 79102c3 + 0d79e94 + c3f023e + 7ee4fbe + 7c5f46f + 93e1c5e + 300993b + 3fa60b1 + 56e7a3b + f66fb69 + 65e3dc5 + 893db4e + 1f95227 + 37eba61 + a8a134d + 2a58e81 + c687156 + ff43991 + bad6a8b + aba47b0 + 955d97a + 2b78fdc + 0094c19 + 4985e6d + d904244 + 52367d8 + dce778a + 2305c94 + 052b9a4 + ef11064 + 4efb47c + b3dcf28 + 778fbea + cdde9b4 + 6ade9b9 + 435888b + 2ad89a8 + e232251 + 5932189 + d0360d2 + 52242e5 + 3804b57 + 1cecc58 + 4a4065c + f9b61b5 + 0a07b63 + 0e321e0 + 95ceb90 + 4380d08 + ec9c36c + 4de92b2 + b6eb950 + fca746d + ff69119 + 5351804 + 3617ea6 + 24c8a1f + 0aa6c03 + b24267c + beadb3c + 51c4ced + d92ccc9 + eb1f131 + f383de1 + abc631a + 666ec86 + e22a167 + bb8b8f6 + b55f760 + f23a913 + 9ba9f17 + d01f94f + 9c4e0cc + 63c4a7e + 9eedf95 + 980bffb + 03cf7b3 + 8bbf35d + aff3454 + 1c6567c + a102513 + 90b7795 + 286539e + 7f08291 + 417d368 + ae0f13d + 7894420 + 8ff1b30 + 55ca16f + 0c6cb6c + 7010e32 + 745a36a + f021693 + cd91ba2 + 5586879 + 1cd9259 + b611b41 + e07e054 + 7657d67 + 52b6014 + 00211c2 + 0d594de + f919c63 + 7e217f4 + 3e0da00 + 3723e41 + facd3ee + 4d8294f + 3cdb12a + f09df31 + 34e6a86 + 4e1b451 + 2d3566a + ef9466a + 3c172af + 2260c5e + dd964bc + f325c01 + 3cd4478 + dc3a58e + cf0af6f + 6e93d7b + 6b3eedb + ce63e39 + 1bd656e + cc16778 + 720b563 + 039e86a + b27a1fe + 88022d1 + b4847de + 1b48124 + 6a22f1e + b63de1e + 770056f + 9e9a6cb + f6a6b75 + 9533639 + 82f2194 + 1c82c93 + b2d0ea0 + 65cd119 + b2e527d + 513214f + 3a8340e + 251bd01 + 6cd974a + 8a9cfe7 + c0ef35c + a4120f3 + ec53915 + 5d1b205 + 3b610ee + 83998db + ce6e83d + 79d9ad3 + 06667fc commit 09ba436
Show file tree
Hide file tree
Showing 14 changed files with 918 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/AbstractContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

namespace Zend\Session;

use Zend\Stdlib\ArrayObject;
use ArrayIterator;
use Iterator;
use Traversable;
use Zend\Session\ManagerInterface as Manager;
use Zend\Session\Storage\StorageInterface as Storage;
use Zend\Stdlib\ArrayObject;

/**
* Session storage container
Expand Down
2 changes: 1 addition & 1 deletion src/Config/StandardConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

namespace Zend\Session\Config;

use Traversable;
use Zend\Session\Config\ConfigInterface;
use Zend\Session\Exception;
use Zend\Validator\Hostname as HostnameValidator;
use Traversable;

/**
* Standard session configuration
Expand Down
10 changes: 5 additions & 5 deletions src/SaveHandler/MongoDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function __construct($mongo, MongoDBOptions $options)
*
* @param string $savePath
* @param string $name
* @return boolean
* @return bool
*/
public function open($savePath, $name)
{
Expand All @@ -93,7 +93,7 @@ public function open($savePath, $name)
/**
* Close session
*
* @return boolean
* @return bool
*/
public function close()
{
Expand Down Expand Up @@ -130,7 +130,7 @@ public function read($id)
*
* @param string $id
* @param string $data
* @return boolean
* @return bool
*/
public function write($id, $data)
{
Expand Down Expand Up @@ -165,7 +165,7 @@ public function write($id, $data)
* Destroy session
*
* @param string $id
* @return boolean
* @return bool
*/
public function destroy($id)
{
Expand All @@ -188,7 +188,7 @@ public function destroy($id)
*
* @see http://docs.mongodb.org/manual/tutorial/expire-data/
* @param int $maxlifetime
* @return boolean
* @return bool
*/
public function gc($maxlifetime)
{
Expand Down
151 changes: 151 additions & 0 deletions src/Service/ContainerAbstractServiceFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Session\Service;

use Zend\ServiceManager\AbstractFactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\Session\Container;

/**
* Session container abstract service factory.
*
* Allows creating Container instances, using the Zend\Service\ManagerInterface
* if present. Containers are named in a "session_containers" array in the
* Config service:
*
* <code>
* return array(
* 'session_containers' => array(
* 'auth',
* 'user',
* 'captcha',
* ),
* );
* </code>
*
* Services use the prefix "SessionContainer\\":
*
* <code>
* $container = $services->get('SessionContainer\captcha');
* </code>
*/
class ContainerAbstractServiceFactory implements AbstractFactoryInterface
{
/**
* Cached container configuration
*
* @var array
*/
protected $config;

/**
* Configuration key in which session containers live
*
* @var string
*/
protected $configKey = 'session_containers';

/**
* @var \Zend\Session\ManagerInterface
*/
protected $sessionManager;

/**
* @param ServiceLocatorInterface $services
* @param string $name
* @param string $requestedName
* @return bool
*/
public function canCreateServiceWithName(ServiceLocatorInterface $services, $name, $requestedName)
{
$config = $this->getConfig($services);
if (empty($config)) {
return false;
}

$containerName = $this->normalizeContainerName($requestedName);
return array_key_exists($containerName, $config);
}

/**
* @param ServiceLocatorInterface $services
* @param string $name
* @param string $requestedName
* @return Container
*/
public function createServiceWithName(ServiceLocatorInterface $services, $name, $requestedName)
{
$manager = $this->getSessionManager($services);
return new Container($requestedName, $manager);
}

/**
* Retrieve config from service locator, and cache for later
*
* @param ServiceLocatorInterface $services
* @return false|array
*/
protected function getConfig(ServiceLocatorInterface $services)
{
if (null !== $this->config) {
return $this->config;
}

if (!$services->has('Config')) {
$this->config = array();
return $this->config;
}

$config = $services->get('Config');
if (!isset($config[$this->configKey]) || !is_array($config[$this->configKey])) {
$this->config = array();
return $this->config;
}

$config = $config[$this->configKey];
$config = array_flip($config);

$this->config = array_change_key_case($config);

return $this->config;
}

/**
* Retrieve the session manager instance, if any
*
* @param ServiceLocatorInterface $services
* @return null|\Zend\Session\ManagerInterface
*/
protected function getSessionManager(ServiceLocatorInterface $services)
{
if ($this->sessionManager !== null) {
return $this->sessionManager;
}

if ($services->has('Zend\Session\ManagerInterface')) {
$this->sessionManager = $services->get('Zend\Session\ManagerInterface');
}

return $this->sessionManager;
}

/**
* Normalize the container name in order to perform a lookup
*
* Strips off the "SessionContainer\" prefix, and lowercases the name.
*
* @param string $name
* @return string
*/
protected function normalizeContainerName($name)
{
return strtolower($name);
}
}
64 changes: 64 additions & 0 deletions src/Service/SessionConfigFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Session\Service;

use Zend\ServiceManager\Exception\ServiceNotCreatedException;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\Session\Config\ConfigInterface;

class SessionConfigFactory implements FactoryInterface
{
/**
* Create session configuration object
*
* Uses "session_config" section of configuration to seed a ConfigInterface
* instance. By default, Zend\Session\Config\SessionConfig will be used, but
* you may also specify a specific implementation variant using the
* "config_class" subkey.
*
* @param ServiceLocatorInterface $services
* @return ConfigInterface
* @throws ServiceNotCreatedException if session_config is missing, or an
* invalid config_class is used
*/
public function createService(ServiceLocatorInterface $services)
{
$config = $services->get('Config');
if (!isset($config['session_config']) || !is_array($config['session_config'])) {
throw new ServiceNotCreatedException(
'Configuration is missing a "session_config" key, or the value of that key is not an array'
);
}
$class = 'Zend\Session\Config\SessionConfig';
$config = $config['session_config'];
if (isset($config['config_class'])) {
if (!class_exists($config['config_class'])) {
throw new ServiceNotCreatedException(sprintf(
'Invalid configuration class "%s" specified in "config_class" session configuration; must be a valid class',
$class
));
}
$class = $config['config_class'];
unset($config['config_class']);
}

$sessionConfig = new $class();
if (!$sessionConfig instanceof ConfigInterface) {
throw new ServiceNotCreatedException(sprintf(
'Invalid configuration class "%s" specified in "config_class" session configuration; must implement Zend\Session\Config\ConfigInterface',
$class
));
}
$sessionConfig->setOptions($config);

return $sessionConfig;
}
}
Loading

0 comments on commit 09ba436

Please sign in to comment.