Exemple #1
0
 /**
  * Constructor
  *
  * $config is an instance of Zend_Config or an array of key/value pairs containing configuration options for
  * Zend_Session_SaveHandler_DbTable and Zend_Db_Table_Abstract. These are the configuration options for
  * Zend_Session_SaveHandler_DbTable:
  *
  * primaryAssignment => (string|array) Session table primary key value assignment
  *      (optional; default: 1 => sessionId) You have to assign a value to each primary key of your session table.
  *      The value of this configuration option is either a string if you have only one primary key or an array if
  *      you have multiple primary keys. The array consists of numeric keys starting at 1 and string values. There
  *      are some values which will be replaced by session information:
  *
  *      sessionId       => The id of the current session
  *      sessionName     => The name of the current session
  *      sessionSavePath => The save path of the current session
  *
  *      NOTE: One of your assignments MUST contain 'sessionId' as value!
  *
  * modifiedColumn    => (string) Session table last modification time column
  *
  * lifetimeColumn    => (string) Session table lifetime column
  *
  * dataColumn        => (string) Session table data column
  *
  * lifetime          => (integer) Session lifetime (optional; default: ini_get('session.gc_maxlifetime'))
  *
  * overrideLifetime  => (boolean) Whether or not the lifetime of an existing session should be overridden
  *      (optional; default: false)
  *
  * @param  Zend_Config|array $config      User-provided configuration
  * @return void
  * @throws Zend_Session_SaveHandler_Exception
  */
 public function __construct($config)
 {
     if ($config instanceof \Zend\Config\Config) {
         $config = $config->toArray();
     } else {
         if (!is_array($config)) {
             throw new Exception\InvalidArgumentException('$config must be an instance of Zend\\Config or array of key/value pairs containing ' . 'configuration options for Zend\\Session\\SaveHandler\\DbTable and Zend\\Db\\Table\\Abstract.');
         }
     }
     foreach ($config as $key => $value) {
         do {
             switch ($key) {
                 case 'manager':
                     $this->setManager($value);
                     break;
                 case self::PRIMARY_ASSIGNMENT:
                     $this->_primaryAssignment = $value;
                     break;
                 case self::MODIFIED_COLUMN:
                     $this->_modifiedColumn = (string) $value;
                     break;
                 case self::LIFETIME_COLUMN:
                     $this->_lifetimeColumn = (string) $value;
                     break;
                 case self::DATA_COLUMN:
                     $this->_dataColumn = (string) $value;
                     break;
                 case self::LIFETIME:
                     $this->setLifetime($value);
                     break;
                 case self::OVERRIDE_LIFETIME:
                     $this->setOverrideLifetime($value);
                     break;
                 default:
                     // unrecognized options passed to parent::__construct()
                     break 2;
             }
             unset($config[$key]);
         } while (false);
     }
     parent::__construct($config);
 }
Exemple #2
0
 /**
  * Constructor
  *
  * $config is an instance of Zend\Config\Config. These are the configuration options for
  * Zend\Session\SaveHandler\DbTable:
  *
  * name              => (string) Session table name
  *
  * primaryAssignment => (string|array) Session table primary key value assignment
  *      (optional; default: 1 => sessionId) You have to assign a value to each primary key of your session table.
  *      The value of this configuration option is either a string if you have only one primary key or an array if
  *      you have multiple primary keys. The array consists of numeric keys starting at 1 and string values. There
  *      are some values which will be replaced by session information:
  *
  *      sessionId       => The id of the current session
  *      sessionName     => The name of the current session
  *      sessionSavePath => The save path of the current session
  *
  *      NOTE: One of your assignments MUST contain 'sessionId' as value!
  *
  * modifiedColumn    => (string) Session table last modification time column
  *
  * lifetimeColumn    => (string) Session table lifetime column
  *
  * dataColumn        => (string) Session table data column
  *
  * lifetime          => (integer) Session lifetime (optional; default: ini_get('session.gc_maxlifetime'))
  *
  * overrideLifetime  => (boolean) Whether or not the lifetime of an existing session should be overridden
  *      (optional; default: false)
  *
  * @param  Configuration      User-provided configuration
  * @return void
  * @throws Zend_Session_SaveHandler_Exception
  */
 public function __construct(Configuration $config)
 {
     $config = $config->toArray();
     foreach ($config as $key => $value) {
         do {
             switch ($key) {
                 case self::NAME:
                     $this->_name = (string) $value;
                     break;
                 case self::PRIMARY_ASSIGNMENT:
                     $this->_primaryAssignment = $value;
                     break;
                 case self::MODIFIED_COLUMN:
                     $this->_modifiedColumn = (string) $value;
                     break;
                 case self::LIFETIME_COLUMN:
                     $this->_lifetimeColumn = (string) $value;
                     break;
                 case self::DATA_COLUMN:
                     $this->_dataColumn = (string) $value;
                     break;
                 case self::LIFETIME:
                     $this->setLifetime($value);
                     break;
                 case self::OVERRIDE_LIFETIME:
                     $this->setOverrideLifetime($value);
                     break;
                 default:
                     // unrecognized options passed to parent::__construct()
                     break 2;
             }
             unset($config[$key]);
         } while (false);
     }
     parent::__construct($config);
 }