Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / ModuleManager / Listener / ListenerOptions.php
blob00c976aa7ed2d02aa2c35856275288cf2fbeeedc
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-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\ModuleManager\Listener;
12 use Traversable;
13 use Zend\Stdlib\AbstractOptions;
15 /**
16 * Listener options
18 class ListenerOptions extends AbstractOptions
20 /**
21 * @var array
23 protected $modulePaths = array();
25 /**
26 * @var array
28 protected $configGlobPaths = array();
30 /**
31 * @var array
33 protected $configStaticPaths = array();
35 /**
36 * @var array
38 protected $extraConfig = array();
40 /**
41 * @var bool
43 protected $configCacheEnabled = false;
45 /**
46 * @var string
48 protected $configCacheKey;
50 /**
51 * @var string
53 protected $cacheDir;
55 /**
56 * @var bool
58 protected $checkDependencies = true;
60 /**
61 * @var string
63 protected $moduleMapCacheEnabled = false;
65 /**
66 * @var string
68 protected $moduleMapCacheKey;
70 /**
71 * Get an array of paths where modules reside
73 * @return array
75 public function getModulePaths()
77 return $this->modulePaths;
80 /**
81 * Set an array of paths where modules reside
83 * @param array|Traversable $modulePaths
84 * @throws Exception\InvalidArgumentException
85 * @return ListenerOptions Provides fluent interface
87 public function setModulePaths($modulePaths)
89 if (!is_array($modulePaths) && !$modulePaths instanceof Traversable) {
90 throw new Exception\InvalidArgumentException(
91 sprintf('Argument passed to %s::%s() must be an array, '
92 . 'implement the Traversable interface, or be an '
93 . 'instance of Zend\Config\Config. %s given.',
94 __CLASS__, __METHOD__, gettype($modulePaths))
98 $this->modulePaths = $modulePaths;
99 return $this;
103 * Get the glob patterns to load additional config files
105 * @return array
107 public function getConfigGlobPaths()
109 return $this->configGlobPaths;
113 * Get the static paths to load additional config files
115 * @return array
117 public function getConfigStaticPaths()
119 return $this->configStaticPaths;
123 * Set the glob patterns to use for loading additional config files
125 * @param array|Traversable $configGlobPaths
126 * @throws Exception\InvalidArgumentException
127 * @return ListenerOptions Provides fluent interface
129 public function setConfigGlobPaths($configGlobPaths)
131 if (!is_array($configGlobPaths) && !$configGlobPaths instanceof Traversable) {
132 throw new Exception\InvalidArgumentException(
133 sprintf('Argument passed to %s::%s() must be an array, '
134 . 'implement the Traversable interface, or be an '
135 . 'instance of Zend\Config\Config. %s given.',
136 __CLASS__, __METHOD__, gettype($configGlobPaths))
140 $this->configGlobPaths = $configGlobPaths;
141 return $this;
145 * Set the static paths to use for loading additional config files
147 * @param array|Traversable $configStaticPaths
148 * @throws Exception\InvalidArgumentException
149 * @return ListenerOptions Provides fluent interface
151 public function setConfigStaticPaths($configStaticPaths)
153 if (!is_array($configStaticPaths) && !$configStaticPaths instanceof Traversable) {
154 throw new Exception\InvalidArgumentException(
155 sprintf('Argument passed to %s::%s() must be an array, '
156 . 'implement the Traversable interface, or be an '
157 . 'instance of Zend\Config\Config. %s given.',
158 __CLASS__, __METHOD__, gettype($configStaticPaths))
162 $this->configStaticPaths = $configStaticPaths;
163 return $this;
167 * Get any extra config to merge in.
169 * @return array|Traversable
171 public function getExtraConfig()
173 return $this->extraConfig;
177 * Add some extra config array to the main config. This is mainly useful
178 * for unit testing purposes.
180 * @param array|Traversable $extraConfig
181 * @throws Exception\InvalidArgumentException
182 * @return ListenerOptions Provides fluent interface
184 public function setExtraConfig($extraConfig)
186 if (!is_array($extraConfig) && !$extraConfig instanceof Traversable) {
187 throw new Exception\InvalidArgumentException(
188 sprintf('Argument passed to %s::%s() must be an array, '
189 . 'implement the Traversable interface, or be an '
190 . 'instance of Zend\Config\Config. %s given.',
191 __CLASS__, __METHOD__, gettype($extraConfig))
195 $this->extraConfig = $extraConfig;
196 return $this;
200 * Check if the config cache is enabled
202 * @return bool
204 public function getConfigCacheEnabled()
206 return $this->configCacheEnabled;
210 * Set if the config cache should be enabled or not
212 * @param bool $enabled
213 * @return ListenerOptions
215 public function setConfigCacheEnabled($enabled)
217 $this->configCacheEnabled = (bool) $enabled;
218 return $this;
222 * Get key used to create the cache file name
224 * @return string
226 public function getConfigCacheKey()
228 return (string) $this->configCacheKey;
232 * Set key used to create the cache file name
234 * @param string $configCacheKey the value to be set
235 * @return ListenerOptions
237 public function setConfigCacheKey($configCacheKey)
239 $this->configCacheKey = $configCacheKey;
240 return $this;
244 * Get the path to the config cache
246 * Should this be an option, or should the dir option include the
247 * filename, or should it simply remain hard-coded? Thoughts?
249 * @return string
251 public function getConfigCacheFile()
253 return $this->getCacheDir() . '/module-config-cache.' . $this->getConfigCacheKey().'.php';
257 * Get the path where cache file(s) are stored
259 * @return string
261 public function getCacheDir()
263 return $this->cacheDir;
267 * Set the path where cache files can be stored
269 * @param string $cacheDir the value to be set
270 * @return ListenerOptions
272 public function setCacheDir($cacheDir)
274 if (null === $cacheDir) {
275 $this->cacheDir = $cacheDir;
276 } else {
277 $this->cacheDir = static::normalizePath($cacheDir);
279 return $this;
283 * Check if the module class map cache is enabled
285 * @return bool
287 public function getModuleMapCacheEnabled()
289 return $this->moduleMapCacheEnabled;
293 * Set if the module class map cache should be enabled or not
295 * @param bool $enabled
296 * @return ListenerOptions
298 public function setModuleMapCacheEnabled($enabled)
300 $this->moduleMapCacheEnabled = (bool) $enabled;
301 return $this;
305 * Get key used to create the cache file name
307 * @return string
309 public function getModuleMapCacheKey()
311 return (string) $this->moduleMapCacheKey;
315 * Set key used to create the cache file name
317 * @param string $moduleMapCacheKey the value to be set
318 * @return ListenerOptions
320 public function setModuleMapCacheKey($moduleMapCacheKey)
322 $this->moduleMapCacheKey = $moduleMapCacheKey;
323 return $this;
327 * Get the path to the module class map cache
329 * @return string
331 public function getModuleMapCacheFile()
333 return $this->getCacheDir() . '/module-classmap-cache.'.$this->getModuleMapCacheKey().'.php';
337 * Set whether to check dependencies during module loading or not
339 * @return string
341 public function getCheckDependencies()
343 return $this->checkDependencies;
347 * Set whether to check dependencies during module loading or not
349 * @param bool $checkDependencies the value to be set
351 * @return ListenerOptions
353 public function setCheckDependencies($checkDependencies)
355 $this->checkDependencies = (bool) $checkDependencies;
357 return $this;
361 * Normalize a path for insertion in the stack
363 * @param string $path
364 * @return string
366 public static function normalizePath($path)
368 $path = rtrim($path, '/');
369 $path = rtrim($path, '\\');
370 return $path;