Source of file ListenerOptions.php
Size: 9,303 Bytes - Last Modified: 2014-03-12T23:21:18+01:00
/home/theseer/Downloads/ZendFramework-2.3.0/library/Zend/ModuleManager/Listener/ListenerOptions.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373 | <?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace Zend\ModuleManager\Listener; use Traversable; use Zend\Stdlib\AbstractOptions; /** * Listener options */ class ListenerOptions extends AbstractOptions { /** * @var array */ protected $modulePaths = array(); /** * @var array */ protected $configGlobPaths = array(); /** * @var array */ protected $configStaticPaths = array(); /** * @var array */ protected $extraConfig = array(); /** * @var bool */ protected $configCacheEnabled = false; /** * @var string */ protected $configCacheKey; /** * @var string */ protected $cacheDir; /** * @var bool */ protected $checkDependencies = true; /** * @var string */ protected $moduleMapCacheEnabled = false; /** * @var string */ protected $moduleMapCacheKey; /** * Get an array of paths where modules reside * * @return array */ public function getModulePaths() { return $this->modulePaths; } /** * Set an array of paths where modules reside * * @param array|Traversable $modulePaths * @throws Exception\InvalidArgumentException * @return ListenerOptions Provides fluent interface */ public function setModulePaths($modulePaths) { if (!is_array($modulePaths) && !$modulePaths instanceof Traversable) { throw new Exception\InvalidArgumentException( sprintf('Argument passed to %s::%s() must be an array, ' . 'implement the Traversable interface, or be an ' . 'instance of Zend\Config\Config. %s given.', __CLASS__, __METHOD__, gettype($modulePaths)) ); } $this->modulePaths = $modulePaths; return $this; } /** * Get the glob patterns to load additional config files * * @return array */ public function getConfigGlobPaths() { return $this->configGlobPaths; } /** * Get the static paths to load additional config files * * @return array */ public function getConfigStaticPaths() { return $this->configStaticPaths; } /** * Set the glob patterns to use for loading additional config files * * @param array|Traversable $configGlobPaths * @throws Exception\InvalidArgumentException * @return ListenerOptions Provides fluent interface */ public function setConfigGlobPaths($configGlobPaths) { if (!is_array($configGlobPaths) && !$configGlobPaths instanceof Traversable) { throw new Exception\InvalidArgumentException( sprintf('Argument passed to %s::%s() must be an array, ' . 'implement the Traversable interface, or be an ' . 'instance of Zend\Config\Config. %s given.', __CLASS__, __METHOD__, gettype($configGlobPaths)) ); } $this->configGlobPaths = $configGlobPaths; return $this; } /** * Set the static paths to use for loading additional config files * * @param array|Traversable $configStaticPaths * @throws Exception\InvalidArgumentException * @return ListenerOptions Provides fluent interface */ public function setConfigStaticPaths($configStaticPaths) { if (!is_array($configStaticPaths) && !$configStaticPaths instanceof Traversable) { throw new Exception\InvalidArgumentException( sprintf('Argument passed to %s::%s() must be an array, ' . 'implement the Traversable interface, or be an ' . 'instance of Zend\Config\Config. %s given.', __CLASS__, __METHOD__, gettype($configStaticPaths)) ); } $this->configStaticPaths = $configStaticPaths; return $this; } /** * Get any extra config to merge in. * * @return array|Traversable */ public function getExtraConfig() { return $this->extraConfig; } /** * Add some extra config array to the main config. This is mainly useful * for unit testing purposes. * * @param array|Traversable $extraConfig * @throws Exception\InvalidArgumentException * @return ListenerOptions Provides fluent interface */ public function setExtraConfig($extraConfig) { if (!is_array($extraConfig) && !$extraConfig instanceof Traversable) { throw new Exception\InvalidArgumentException( sprintf('Argument passed to %s::%s() must be an array, ' . 'implement the Traversable interface, or be an ' . 'instance of Zend\Config\Config. %s given.', __CLASS__, __METHOD__, gettype($extraConfig)) ); } $this->extraConfig = $extraConfig; return $this; } /** * Check if the config cache is enabled * * @return bool */ public function getConfigCacheEnabled() { return $this->configCacheEnabled; } /** * Set if the config cache should be enabled or not * * @param bool $enabled * @return ListenerOptions */ public function setConfigCacheEnabled($enabled) { $this->configCacheEnabled = (bool) $enabled; return $this; } /** * Get key used to create the cache file name * * @return string */ public function getConfigCacheKey() { return (string) $this->configCacheKey; } /** * Set key used to create the cache file name * * @param string $configCacheKey the value to be set * @return ListenerOptions */ public function setConfigCacheKey($configCacheKey) { $this->configCacheKey = $configCacheKey; return $this; } /** * Get the path to the config cache * * Should this be an option, or should the dir option include the * filename, or should it simply remain hard-coded? Thoughts? * * @return string */ public function getConfigCacheFile() { return $this->getCacheDir() . '/module-config-cache.' . $this->getConfigCacheKey().'.php'; } /** * Get the path where cache file(s) are stored * * @return string */ public function getCacheDir() { return $this->cacheDir; } /** * Set the path where cache files can be stored * * @param string $cacheDir the value to be set * @return ListenerOptions */ public function setCacheDir($cacheDir) { if (null === $cacheDir) { $this->cacheDir = $cacheDir; } else { $this->cacheDir = static::normalizePath($cacheDir); } return $this; } /** * Check if the module class map cache is enabled * * @return bool */ public function getModuleMapCacheEnabled() { return $this->moduleMapCacheEnabled; } /** * Set if the module class map cache should be enabled or not * * @param bool $enabled * @return ListenerOptions */ public function setModuleMapCacheEnabled($enabled) { $this->moduleMapCacheEnabled = (bool) $enabled; return $this; } /** * Get key used to create the cache file name * * @return string */ public function getModuleMapCacheKey() { return (string) $this->moduleMapCacheKey; } /** * Set key used to create the cache file name * * @param string $moduleMapCacheKey the value to be set * @return ListenerOptions */ public function setModuleMapCacheKey($moduleMapCacheKey) { $this->moduleMapCacheKey = $moduleMapCacheKey; return $this; } /** * Get the path to the module class map cache * * @return string */ public function getModuleMapCacheFile() { return $this->getCacheDir() . '/module-classmap-cache.'.$this->getModuleMapCacheKey().'.php'; } /** * Set whether to check dependencies during module loading or not * * @return string */ public function getCheckDependencies() { return $this->checkDependencies; } /** * Set whether to check dependencies during module loading or not * * @param bool $checkDependencies the value to be set * * @return ListenerOptions */ public function setCheckDependencies($checkDependencies) { $this->checkDependencies = (bool) $checkDependencies; return $this; } /** * Normalize a path for insertion in the stack * * @param string $path * @return string */ public static function normalizePath($path) { $path = rtrim($path, '/'); $path = rtrim($path, '\\'); return $path; } } |