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

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 36 changed files with 1,111 additions and 1,260 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zendframework/zend-session",
"description": "Zend\\Session component",
"description": "manage and preserve session data, a logical complement of cookie data, across multiple page requests by the same client",
"license": "BSD-3-Clause",
"keywords": [
"zf2",
Expand All @@ -9,11 +9,11 @@
"homepage": "https://github.com/zendframework/zend-session",
"autoload": {
"psr-4": {
"Zend\\Session\\": "src/"
"Zend\\Session": "src/"
}
},
"require": {
"php": ">=5.3.23",
"php": ">=5.3.3",
"zendframework/zend-eventmanager": "self.version",
"zendframework/zend-stdlib": "self.version"
},
Expand Down
145 changes: 79 additions & 66 deletions src/AbstractManager.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
<?php
/**
* Zend Framework
* Zend Framework (http://framework.zend.com/)
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-webat this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Session
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @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_Session
*/

namespace Zend\Session;

use Zend\Session\ManagerInterface as Manager,
Zend\Session\SaveHandler\SaveHandlerInterface as SaveHandler,
Zend\Session\Storage\StorageInterface as Storage,
Zend\Session\Configuration\ConfigurationInterface as Configuration;
use Zend\Session\Config\ConfigInterface as Config;
use Zend\Session\ManagerInterface as Manager;
use Zend\Session\SaveHandler\SaveHandlerInterface as SaveHandler;
use Zend\Session\Storage\StorageInterface as Storage;

/**
* Base ManagerInterface implementation
Expand All @@ -32,21 +22,19 @@
*
* @category Zend
* @package Zend_Session
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class AbstractManager implements Manager
{
/**
* @var Configuration
* @var Config
*/
protected $config;

/**
* Default configuration class to use when no configuration provided
* @var string
*/
protected $configDefaultClass = 'Zend\\Session\\Configuration\\SessionConfiguration';
protected $defaultConfigClass = 'Zend\Session\Config\SessionConfig';

/**
* @var Storage
Expand All @@ -57,56 +45,89 @@ abstract class AbstractManager implements Manager
* Default storage class to use when no storage provided
* @var string
*/
protected $storageDefaultClass = 'Zend\\Session\\Storage\\SessionStorage';
protected $defaultStorageClass = 'Zend\Session\Storage\SessionStorage';

/**
* @var SaveHandler
*/
protected $saveHandler;


/**
* Constructor
*
* Allow passing a configuration object or class name, a storage object or
* class name, or an array of configuration.
*
* @param Configuration $config
* @param Storage $storage
* @param SaveHandler $saveHandler
* @return void
* @param Config|null $config
* @param Storage|null $storage
* @param SaveHandler|null $saveHandler
* @throws Exception\RuntimeException
*/
public function __construct(Configuration $config = null, Storage $storage = null, SaveHandler $saveHandler = null)
public function __construct(Config $config = null, Storage $storage = null, SaveHandler $saveHandler = null)
{
$this->setOptions($config);
$this->setStorage($storage);
if ($saveHandler) {
$this->setSaveHandler($saveHandler);
// init config
if ($config === null) {
if (!class_exists($this->defaultConfigClass)) {
throw new Exception\RuntimeException(sprintf(
'Unable to locate config class "%s"; class does not exist',
$this->defaultConfigClass
));
}

$config = new $this->defaultConfigClass();

if (!$config instanceof Config) {
throw new Exception\RuntimeException(sprintf(
'Default config class %s is invalid; must implement %s\Config\ConfigInterface',
$this->defaultConfigClass,
__NAMESPACE__
));
}
}

$this->config = $config;

// init storage
if ($storage === null) {
if (!class_exists($this->defaultStorageClass)) {
throw new Exception\RuntimeException(sprintf(
'Unable to locate storage class "%s"; class does not exist',
$this->defaultStorageClass
));
}

$storage = new $this->defaultStorageClass();

if (!$storage instanceof Storage) {
throw new Exception\RuntimeException(sprintf(
'Default storage class %s is invalid; must implement %s\Storage\StorageInterface',
$this->defaultConfigClass,
__NAMESPACE__
));
}
}

$this->storage = $storage;

// save handler
if ($saveHandler !== null) {
$this->saveHandler = $saveHandler;
}
}

/**
* Set configuration object
*
* @param null|Configuration $config
* @return void
* @param Config $config
* @return AbstractManager
*/
public function setOptions(Configuration $config = null)
public function setConfig(Config $config)
{
if (null === $config) {
$config = new $this->configDefaultClass();
if (!$config instanceof Configuration) {
throw new Exception\InvalidArgumentException('Default configuration type provided is invalid; must implement Zend\\Session\\Configuration');
}
}

$this->config = $config;
return $this;
}

/**
* Retrieve configuration object
*
* @return Configuration
*
* @return Config
*/
public function getConfig()
{
Expand All @@ -116,24 +137,18 @@ public function getConfig()
/**
* Set session storage object
*
* @param null|Storage $storage
* @return void
* @param Storage $storage
* @return AbstractManager
*/
public function setStorage(Storage $storage = null)
public function setStorage(Storage $storage)
{
if (null === $storage) {
$storage = new $this->storageDefaultClass();
if (!$storage instanceof Storage) {
throw new Exception\InvalidArgumentException('Default storage type provided is invalid; must implement Zend\\Session\\Storage');
}
}

$this->storage = $storage;
return $this;
}

/**
* Retrieve storage object
*
*
* @return Storage
*/
public function getStorage()
Expand All @@ -144,15 +159,13 @@ public function getStorage()
/**
* Set session save handler object
*
* @param SaveHandler $saveHandler
* @return void
* @param SaveHandler $saveHandler
* @return AbstractManager
*/
public function setSaveHandler(SaveHandler $saveHandler)
{
if ($saveHandler === null) {
return ;
}
$this->saveHandler = $saveHandler;
return $this;
}

/**
Expand All @@ -164,4 +177,4 @@ public function getSaveHandler()
{
return $this->saveHandler;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,59 +1,56 @@
<?php
/**
* Zend Framework
* Zend Framework (http://framework.zend.com/)
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-webat this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Session
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @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_Session
*/

namespace Zend\Session\Configuration;
namespace Zend\Session\Config;

/**
* Standard session configuration
*
* @category Zend
* @package Zend_Session
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface ConfigurationInterface
interface ConfigInterface
{
public function setOptions(array $options);
public function setOptions($options);
public function getOptions();

public function setOption($option, $value);
public function hasOption($option);
public function getOption($option);
public function toArray();
public function hasOption($option);

public function setSavePath($savePath);
public function getSavePath();
public function toArray();

public function setName($name);
public function getName();

public function setSavePath($savePath);
public function getSavePath();

public function setCookieLifetime($cookieLifetime);
public function getCookieLifetime();

public function setCookiePath($cookiePath);
public function getCookiePath();

public function setCookieDomain($cookieDomain);
public function getCookieDomain();

public function setCookieSecure($cookieSecure);
public function getCookieSecure();

public function setCookieHttpOnly($cookieHttpOnly);
public function getCookieHttpOnly();

public function setUseCookies($useCookies);
public function getUseCookies();

public function setRememberMeSeconds($rememberMeSeconds);
public function getRememberMeSeconds();
}
Loading

0 comments on commit 3cd4478

Please sign in to comment.