mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/11415] Create function in finder find_from_extension
PHPBB3-11415
This commit is contained in:
parent
1b34ddb330
commit
27b2bbb8ff
2 changed files with 30 additions and 13 deletions
|
@ -125,21 +125,10 @@ class phpbb_extension_base implements phpbb_extension_interface
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only have the finder search in this extension path directory
|
// Only have the finder search in this extension path directory
|
||||||
$extensions = array(
|
|
||||||
$this->extension_name => $this->extension_path,
|
|
||||||
);
|
|
||||||
|
|
||||||
$finder = $this->extension_manager->get_finder();
|
$finder = $this->extension_manager->get_finder();
|
||||||
$migrations = array();
|
$migrations = $finder
|
||||||
$file_list = $finder
|
|
||||||
->extension_directory('/migrations')
|
->extension_directory('/migrations')
|
||||||
->find_from_paths($extensions);
|
->find_from_extension($this->extension_name, $this->extension_path);
|
||||||
|
|
||||||
foreach ($file_list as $file)
|
|
||||||
{
|
|
||||||
$migrations[$file['named_path']] = $file['ext_name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$migrations = $finder->get_classes_from_files($migrations);
|
$migrations = $finder->get_classes_from_files($migrations);
|
||||||
|
|
||||||
return $migrations;
|
return $migrations;
|
||||||
|
|
|
@ -377,6 +377,34 @@ class phpbb_extension_finder
|
||||||
|
|
||||||
return $files;
|
return $files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds all file system entries matching the configured options for one
|
||||||
|
* specific extension
|
||||||
|
*
|
||||||
|
* @param string $extension_name Name of the extension
|
||||||
|
* @param string $extension_path Relative path to the extension root directory
|
||||||
|
* @param bool $cache Whether the result should be cached
|
||||||
|
* @param bool $is_dir Directories will be returned when true, only files
|
||||||
|
* otherwise
|
||||||
|
* @return array An array of paths to found items
|
||||||
|
*/
|
||||||
|
public function find_from_extension($extension_name, $extension_path, $cache = true, $is_dir = false)
|
||||||
|
{
|
||||||
|
$extensions = array(
|
||||||
|
$extension_name => $extension_path,
|
||||||
|
);
|
||||||
|
|
||||||
|
$files = array();
|
||||||
|
$file_list = $this->find_from_paths($extensions, $cache, $is_dir);
|
||||||
|
|
||||||
|
foreach ($file_list as $file)
|
||||||
|
{
|
||||||
|
$files[$file['named_path']] = $file['ext_name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $files;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all file system entries matching the configured options from
|
* Finds all file system entries matching the configured options from
|
||||||
|
|
Loading…
Add table
Reference in a new issue