mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-24 12:03:21 +01:00
[ticket/11381] Make finder able to search in all available extensions
PHPBB3-11381
This commit is contained in:
parent
8200509c79
commit
e34f6a5269
@ -247,14 +247,16 @@ class phpbb_extension_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)
|
||||
public function get_classes($cache = true, $use_all_available = false)
|
||||
{
|
||||
$this->query['extension_suffix'] .= $this->php_ext;
|
||||
$this->query['core_suffix'] .= $this->php_ext;
|
||||
|
||||
$files = $this->find($cache, false);
|
||||
$files = $this->find($cache, false, $use_all_available);
|
||||
|
||||
$classes = array();
|
||||
foreach ($files as $file => $ext_name)
|
||||
@ -270,23 +272,27 @@ class phpbb_extension_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, $extension_keys = false)
|
||||
public function get_directories($cache = true, $use_all_available = false, $extension_keys = false)
|
||||
{
|
||||
return $this->find_with_root_path($cache, true, $extension_keys);
|
||||
return $this->find_with_root_path($cache, true, $use_all_available, $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)
|
||||
public function get_files($cache = true, $use_all_available = false)
|
||||
{
|
||||
return $this->find_with_root_path($cache, false);
|
||||
return $this->find_with_root_path($cache, false, $use_all_available);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -295,13 +301,15 @@ class phpbb_extension_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, $extension_keys = false)
|
||||
protected function find_with_root_path($cache = true, $is_dir = false, $use_all_available = false, $extension_keys = false)
|
||||
{
|
||||
$items = $this->find($cache, $is_dir);
|
||||
$items = $this->find($cache, $is_dir, $use_all_available);
|
||||
|
||||
$result = array();
|
||||
foreach ($items as $item => $ext_name)
|
||||
@ -325,9 +333,11 @@ class phpbb_extension_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)
|
||||
public function find($cache = true, $is_dir = false, $use_all_available = false)
|
||||
{
|
||||
$this->query['is_dir'] = $is_dir;
|
||||
$query = md5(serialize($this->query));
|
||||
@ -339,7 +349,14 @@ class phpbb_extension_finder
|
||||
|
||||
$files = array();
|
||||
|
||||
$extensions = $this->extension_manager->all_enabled();
|
||||
if ($use_all_available)
|
||||
{
|
||||
$extensions = $this->extension_manager->all_available();
|
||||
}
|
||||
else
|
||||
{
|
||||
$extensions = $this->extension_manager->all_enabled();
|
||||
}
|
||||
|
||||
if ($this->query['core_path'])
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ class phpbb_style_extension_path_provider extends phpbb_extension_provider imple
|
||||
if ($path && !phpbb_is_absolute($path))
|
||||
{
|
||||
$result = $finder->directory('/' . $this->ext_dir_prefix . $path)
|
||||
->get_directories(true, true);
|
||||
->get_directories(true, false, true);
|
||||
foreach ($result as $ext => $ext_path)
|
||||
{
|
||||
$directories[$ext][] = $ext_path;
|
||||
|
Loading…
x
Reference in New Issue
Block a user