diff options
Diffstat (limited to 'phpBB/phpbb/extension/manager.php')
-rw-r--r-- | phpBB/phpbb/extension/manager.php | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/phpBB/phpbb/extension/manager.php b/phpBB/phpbb/extension/manager.php index 0bfec23573..4130e8455a 100644 --- a/phpBB/phpbb/extension/manager.php +++ b/phpBB/phpbb/extension/manager.php @@ -26,6 +26,7 @@ class manager protected $db; protected $config; protected $cache; + protected $user; protected $php_ext; protected $extensions; protected $extension_table; @@ -37,25 +38,27 @@ class manager * * @param ContainerInterface $container A container * @param \phpbb\db\driver\driver_interface $db A database connection - * @param \phpbb\config\config $config \phpbb\config\config + * @param \phpbb\config\config $config Config object * @param \phpbb\filesystem $filesystem + * @param \phpbb\user $user User object * @param string $extension_table The name of the table holding extensions * @param string $phpbb_root_path Path to the phpbb includes directory. - * @param string $php_ext php file extension + * @param string $php_ext php file extension, defaults to php * @param \phpbb\cache\driver\driver_interface $cache A cache instance or null * @param string $cache_name The name of the cache variable, defaults to _ext */ - public function __construct(ContainerInterface $container, \phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\filesystem $filesystem, $extension_table, $phpbb_root_path, $php_ext = 'php', \phpbb\cache\driver\driver_interface $cache = null, $cache_name = '_ext') + public function __construct(ContainerInterface $container, \phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\filesystem $filesystem, \phpbb\user $user, $extension_table, $phpbb_root_path, $php_ext = 'php', \phpbb\cache\driver\driver_interface $cache = null, $cache_name = '_ext') { + $this->cache = $cache; + $this->cache_name = $cache_name; + $this->config = $config; $this->container = $container; - $this->phpbb_root_path = $phpbb_root_path; $this->db = $db; - $this->config = $config; - $this->cache = $cache; + $this->extension_table = $extension_table; $this->filesystem = $filesystem; + $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; - $this->extension_table = $extension_table; - $this->cache_name = $cache_name; + $this->user = $user; $this->extensions = ($this->cache) ? $this->cache->get($this->cache_name) : false; @@ -145,12 +148,12 @@ class manager * Instantiates the metadata manager for the extension with the given name * * @param string $name The extension name - * @param string $template The template manager + * @param \phpbb\template\template $template The template manager * @return \phpbb\extension\metadata_manager Instance of the metadata manager */ public function create_extension_metadata_manager($name, \phpbb\template\template $template) { - return new \phpbb\extension\metadata_manager($name, $this->config, $this, $template, $this->phpbb_root_path); + return new \phpbb\extension\metadata_manager($name, $this->config, $this, $template, $this->user, $this->phpbb_root_path); } /** @@ -420,7 +423,7 @@ class manager foreach ($iterator as $file_info) { - if ($file_info->isFile() && $file_info->getFilename() == 'ext.' . $this->php_ext) + if ($file_info->isFile() && $file_info->getFilename() == 'composer.json') { $ext_name = $iterator->getInnerIterator()->getSubPath(); $composer_file = $iterator->getPath() . '/composer.json'; @@ -529,12 +532,22 @@ class manager } /** - * Instantiates a \phpbb\extension\finder. + * Instantiates a \phpbb\finder. * - * @return \phpbb\extension\finder An extension finder instance + * @param bool $use_all_available Should we load all extensions, or just enabled ones + * @return \phpbb\finder An extension finder instance */ - public function get_finder() + public function get_finder($use_all_available = false) { - return new \phpbb\extension\finder($this, $this->filesystem, $this->phpbb_root_path, $this->cache, $this->php_ext, $this->cache_name . '_finder'); + $finder = new \phpbb\finder($this->filesystem, $this->phpbb_root_path, $this->cache, $this->php_ext, $this->cache_name . '_finder'); + if ($use_all_available) + { + $finder->set_extensions(array_keys($this->all_available())); + } + else + { + $finder->set_extensions(array_keys($this->all_enabled())); + } + return $finder; } } |