composer package updates
[openemr.git] / vendor / zendframework / zend-cache / src / Storage / Adapter / MongoDbOptions.php
blob42f36d1bc64a322ae2e2c7a8ad1910d413a52a8f
1 <?php
2 /**
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
8 */
10 namespace Zend\Cache\Storage\Adapter;
12 class MongoDbOptions extends AdapterOptions
14 // @codingStandardsIgnoreStart
15 /**
16 * Prioritized properties ordered by prio to be set first
17 * in case a bulk of options sets set at once
19 * @var string[]
21 protected $__prioritizedProperties__ = ['resource_manager', 'resource_id'];
22 // @codingStandardsIgnoreEnd
24 /**
25 * The namespace separator
27 * @var string
29 private $namespaceSeparator = ':';
31 /**
32 * The mongo DB resource manager
34 * @var null|MongoDbResourceManager
36 private $resourceManager;
38 /**
39 * The resource id of the resource manager
41 * @var string
43 private $resourceId = 'default';
45 /**
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;
62 return $this;
65 /**
66 * Get namespace separator
68 * @return string
70 public function getNamespaceSeparator()
72 return $this->namespaceSeparator;
75 /**
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;
90 return $this;
93 /**
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
106 * @return string
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;
130 return $this;
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);
143 return $this;
149 * @param array $connectionOptions
151 * @return MongoDbOptions Provides a fluent interface
153 public function setConnectionOptions(array $connectionOptions)
155 $this->getResourceManager()->setConnectionOptions($this->getResourceId(), $connectionOptions);
156 return $this;
162 * @param array $driverOptions
163 MongoDbOptions
164 * @return MongoDbOptions Provides a fluent interface
166 public function setDriverOptions(array $driverOptions)
168 $this->getResourceManager()->setDriverOptions($this->getResourceId(), $driverOptions);
169 return $this;
175 * @param string $database
177 * @return MongoDbOptions Provides a fluent interface
179 public function setDatabase($database)
181 $this->getResourceManager()->setDatabase($this->getResourceId(), $database);
182 return $this;
188 * @param string $collection
190 * @return MongoDbOptions Provides a fluent interface
192 public function setCollection($collection)
194 $this->getResourceManager()->setCollection($this->getResourceId(), $collection);
195 return $this;