4 * Zend Framework (http://framework.zend.com/)
6 * @link http://github.com/zendframework/zf2 for the canonical source repository
7 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
8 * @license http://framework.zend.com/license/new-bsd New BSD License
11 namespace Zend\Session\SaveHandler
;
13 use Zend\Session\Exception\InvalidArgumentException
;
14 use Zend\Stdlib\AbstractOptions
;
17 * MongoDB session save handler Options
19 class MongoDBOptions
extends AbstractOptions
33 protected $collection;
38 * @see http://php.net/manual/en/mongocollection.save.php
41 protected $saveOptions = array('safe' => true);
48 protected $nameField = 'name';
55 protected $dataField = 'data';
62 protected $lifetimeField = 'lifetime';
69 protected $modifiedField = 'modified';
74 * @param string $database
75 * @return MongoDBOptions
76 * @throws InvalidArgumentException
78 public function setDatabase($database)
80 $database = (string) $database;
81 if (strlen($database) === 0) {
82 throw new InvalidArgumentException('$database must be a non-empty string');
84 $this->database
= $database;
93 public function getDatabase()
95 return $this->database
;
101 * @param string $collection
102 * @return MongoDBOptions
103 * @throws InvalidArgumentException
105 public function setCollection($collection)
107 $collection = (string) $collection;
108 if (strlen($collection) === 0) {
109 throw new InvalidArgumentException('$collection must be a non-empty string');
111 $this->collection
= $collection;
116 * Get collection name
120 public function getCollection()
122 return $this->collection
;
128 * @see http://php.net/manual/en/mongocollection.save.php
129 * @param array $saveOptions
130 * @return MongoDBOptions
132 public function setSaveOptions(array $saveOptions)
134 $this->saveOptions
= $saveOptions;
143 public function getSaveOptions()
145 return $this->saveOptions
;
151 * @param string $nameField
152 * @return MongoDBOptions
153 * @throws InvalidArgumentException
155 public function setNameField($nameField)
157 $nameField = (string) $nameField;
158 if (strlen($nameField) === 0) {
159 throw new InvalidArgumentException('$nameField must be a non-empty string');
161 $this->nameField
= $nameField;
170 public function getNameField()
172 return $this->nameField
;
178 * @param string $dataField
179 * @return MongoDBOptions
180 * @throws InvalidArgumentException
182 public function setDataField($dataField)
184 $dataField = (string) $dataField;
185 if (strlen($dataField) === 0) {
186 throw new InvalidArgumentException('$dataField must be a non-empty string');
188 $this->dataField
= $dataField;
197 public function getDataField()
199 return $this->dataField
;
205 * @param string $lifetimeField
206 * @return MongoDBOptions
207 * @throws InvalidArgumentException
209 public function setLifetimeField($lifetimeField)
211 $lifetimeField = (string) $lifetimeField;
212 if (strlen($lifetimeField) === 0) {
213 throw new InvalidArgumentException('$lifetimeField must be a non-empty string');
215 $this->lifetimeField
= $lifetimeField;
224 public function getLifetimeField()
226 return $this->lifetimeField
;
232 * @param string $modifiedField
233 * @return MongoDBOptions
234 * @throws InvalidArgumentException
236 public function setModifiedField($modifiedField)
238 $modifiedField = (string) $modifiedField;
239 if (strlen($modifiedField) === 0) {
240 throw new InvalidArgumentException('$modifiedField must be a non-empty string');
242 $this->modifiedField
= $modifiedField;
251 public function getModifiedField()
253 return $this->modifiedField
;