3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Cache\Storage\Adapter
;
12 class MongoDbOptions
extends AdapterOptions
14 // @codingStandardsIgnoreStart
16 * Prioritized properties ordered by prio to be set first
17 * in case a bulk of options sets set at once
21 protected $__prioritizedProperties__ = ['resource_manager', 'resource_id'];
22 // @codingStandardsIgnoreEnd
25 * The namespace separator
29 private $namespaceSeparator = ':';
32 * The mongo DB resource manager
34 * @var null|MongoDbResourceManager
36 private $resourceManager;
39 * The resource id of the resource manager
43 private $resourceId = 'default';
46 * Set namespace separator
48 * @param string $namespaceSeparator
50 * @return MongoDbOptions Provides a fluent interface
52 public function setNamespaceSeparator($namespaceSeparator)
54 $namespaceSeparator = (string) $namespaceSeparator;
56 if ($this->namespaceSeparator
!== $namespaceSeparator) {
57 $this->triggerOptionEvent('namespace_separator', $namespaceSeparator);
59 $this->namespaceSeparator
= $namespaceSeparator;
66 * Get namespace separator
70 public function getNamespaceSeparator()
72 return $this->namespaceSeparator
;
76 * Set the mongodb resource manager to use
78 * @param null|MongoDbResourceManager $resourceManager
80 * @return MongoDbOptions Provides a fluent interface
82 public function setResourceManager(MongoDbResourceManager
$resourceManager = null)
84 if ($this->resourceManager
!== $resourceManager) {
85 $this->triggerOptionEvent('resource_manager', $resourceManager);
87 $this->resourceManager
= $resourceManager;
94 * Get the mongodb resource manager
96 * @return MongoDbResourceManager
98 public function getResourceManager()
100 return $this->resourceManager ?
: $this->resourceManager
= new MongoDbResourceManager();
104 * Get the mongodb resource id
108 public function getResourceId()
110 return $this->resourceId
;
114 * Set the mongodb resource id
116 * @param string $resourceId
118 * @return MongoDbOptions Provides a fluent interface
120 public function setResourceId($resourceId)
122 $resourceId = (string) $resourceId;
124 if ($this->resourceId
!== $resourceId) {
125 $this->triggerOptionEvent('resource_id', $resourceId);
127 $this->resourceId
= $resourceId;
134 * Set the mongo DB server
136 * @param string $server
138 * @return MongoDbOptions Provides a fluent interface
140 public function setServer($server)
142 $this->getResourceManager()->setServer($this->getResourceId(), $server);
149 * @param array $connectionOptions
151 * @return MongoDbOptions Provides a fluent interface
153 public function setConnectionOptions(array $connectionOptions)
155 $this->getResourceManager()->setConnectionOptions($this->getResourceId(), $connectionOptions);
162 * @param array $driverOptions
164 * @return MongoDbOptions Provides a fluent interface
166 public function setDriverOptions(array $driverOptions)
168 $this->getResourceManager()->setDriverOptions($this->getResourceId(), $driverOptions);
175 * @param string $database
177 * @return MongoDbOptions Provides a fluent interface
179 public function setDatabase($database)
181 $this->getResourceManager()->setDatabase($this->getResourceId(), $database);
188 * @param string $collection
190 * @return MongoDbOptions Provides a fluent interface
192 public function setCollection($collection)
194 $this->getResourceManager()->setCollection($this->getResourceId(), $collection);