diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-05-06 17:22:11 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-06-10 11:47:36 +0200 |
commit | c20653dfbe552b53fa3281ff8f2a9214fc8a26a9 (patch) | |
tree | c9a0b6b822ac4e8c020f02f9b9455e931e7010f3 /phpBB | |
parent | 0aa6381834724e9d56d15a11b608b3c0c45e4d37 (diff) | |
download | forums-c20653dfbe552b53fa3281ff8f2a9214fc8a26a9.tar forums-c20653dfbe552b53fa3281ff8f2a9214fc8a26a9.tar.gz forums-c20653dfbe552b53fa3281ff8f2a9214fc8a26a9.tar.bz2 forums-c20653dfbe552b53fa3281ff8f2a9214fc8a26a9.tar.xz forums-c20653dfbe552b53fa3281ff8f2a9214fc8a26a9.zip |
[ticket/12508] Remove extension manager from finder
PHPBB3-12508
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/phpbb/extension/finder.php | 61 |
1 files changed, 25 insertions, 36 deletions
diff --git a/phpBB/phpbb/extension/finder.php b/phpBB/phpbb/extension/finder.php index 6f2408094e..b67c0709a4 100644 --- a/phpBB/phpbb/extension/finder.php +++ b/phpBB/phpbb/extension/finder.php @@ -18,7 +18,7 @@ namespace phpbb\extension; */ class finder { - protected $extension_manager; + protected $extensions; protected $filesystem; protected $phpbb_root_path; protected $cache; @@ -48,9 +48,6 @@ class finder /** * Creates a new finder instance with its dependencies * - * @param \phpbb\extension\manager $extension_manager An extension manager - * instance that provides the finder with a list of active - * extensions and their locations * @param \phpbb\filesystem $filesystem Filesystem instance * @param string $phpbb_root_path Path to the phpbb root directory * @param \phpbb\cache\driver\driver_interface $cache A cache instance or null @@ -58,9 +55,8 @@ class finder * @param string $cache_name The name of the cache variable, defaults to * _ext_finder */ - public function __construct(\phpbb\extension\manager $extension_manager, \phpbb\filesystem $filesystem, $phpbb_root_path = '', \phpbb\cache\driver\driver_interface $cache = null, $php_ext = 'php', $cache_name = '_ext_finder') + public function __construct(\phpbb\filesystem $filesystem, $phpbb_root_path = '', \phpbb\cache\driver\driver_interface $cache = null, $php_ext = 'php', $cache_name = '_ext_finder') { - $this->extension_manager = $extension_manager; $this->filesystem = $filesystem; $this->phpbb_root_path = $phpbb_root_path; $this->cache = $cache; @@ -76,11 +72,24 @@ class finder 'extension_prefix' => false, 'extension_directory' => false, ); + $this->extensions = array(); $this->cached_queries = ($this->cache) ? $this->cache->get($this->cache_name) : false; } /** + * Set the array of extensions + * + * @param array $extensions A list of extensions that should be searched aswell + * @return \phpbb\extension\finder This object for chaining calls + */ + public function set_extensions(array $extensions) + { + $this->extensions = $extensions; + return $this; + } + + /** * Sets a core path to be searched in addition to extensions * * @param string $core_path The path relative to phpbb_root_path @@ -246,16 +255,14 @@ class finder * phpBB naming rules an incorrect class name will be returned. * * @param bool $cache Whether the result should be cached - * @param bool $use_all_available Use all available instead of just all - * enabled extensions * @return array An array of found class names */ - public function get_classes($cache = true, $use_all_available = false) + public function get_classes($cache = true) { $this->query['extension_suffix'] .= '.' . $this->php_ext; $this->query['core_suffix'] .= '.' . $this->php_ext; - $files = $this->find($cache, false, $use_all_available); + $files = $this->find($cache, false); return $this->get_classes_from_files($files); } @@ -290,27 +297,23 @@ class finder * Finds all directories matching the configured options * * @param bool $cache Whether the result should be cached - * @param bool $use_all_available Use all available instead of just all - * enabled extensions * @param bool $extension_keys Whether the result should have extension name as array key * @return array An array of paths to found directories */ - public function get_directories($cache = true, $use_all_available = false, $extension_keys = false) + public function get_directories($cache = true, $extension_keys = false) { - return $this->find_with_root_path($cache, true, $use_all_available, $extension_keys); + return $this->find_with_root_path($cache, true, $extension_keys); } /** * Finds all files matching the configured options. * * @param bool $cache Whether the result should be cached - * @param bool $use_all_available Use all available instead of just all - * enabled extensions * @return array An array of paths to found files */ - public function get_files($cache = true, $use_all_available = false) + public function get_files($cache = true) { - return $this->find_with_root_path($cache, false, $use_all_available); + return $this->find_with_root_path($cache, false); } /** @@ -319,15 +322,11 @@ class finder * @param bool $cache Whether the result should be cached * @param bool $is_dir Directories will be returned when true, only files * otherwise - * @param bool $use_all_available Use all available instead of just all - * enabled extensions - * @param bool $extension_keys If true, result will be associative array - * with extension name as key * @return array An array of paths to found items */ - protected function find_with_root_path($cache = true, $is_dir = false, $use_all_available = false, $extension_keys = false) + protected function find_with_root_path($cache = true, $is_dir = false, $extension_keys = false) { - $items = $this->find($cache, $is_dir, $use_all_available); + $items = $this->find($cache, $is_dir); $result = array(); foreach ($items as $item => $ext_name) @@ -351,21 +350,11 @@ class finder * @param bool $cache Whether the result should be cached * @param bool $is_dir Directories will be returned when true, only files * otherwise - * @param bool $use_all_available Use all available instead of just all - * enabled extensions * @return array An array of paths to found items */ - public function find($cache = true, $is_dir = false, $use_all_available = false) + public function find($cache = true, $is_dir = false) { - if ($use_all_available) - { - $extensions = $this->extension_manager->all_available(); - } - else - { - $extensions = $this->extension_manager->all_enabled(); - } - + $extensions = $this->extensions; if ($this->query['core_path']) { $extensions['/'] = $this->phpbb_root_path . $this->query['core_path']; |