diff options
author | Nathaniel Guse <nathaniel.guse@gmail.com> | 2013-03-03 19:54:22 -0600 |
---|---|---|
committer | Nathaniel Guse <nathaniel.guse@gmail.com> | 2013-03-03 19:54:22 -0600 |
commit | e4f782819968ec44f1dd207dc9de7ec703826d29 (patch) | |
tree | e55e3aa115c561d0522b15c897a86a2de8d208ef /phpBB/includes/extension | |
parent | bee4f8d8185d4ff5278be758db4ea4a814f09b4f (diff) | |
download | forums-e4f782819968ec44f1dd207dc9de7ec703826d29.tar forums-e4f782819968ec44f1dd207dc9de7ec703826d29.tar.gz forums-e4f782819968ec44f1dd207dc9de7ec703826d29.tar.bz2 forums-e4f782819968ec44f1dd207dc9de7ec703826d29.tar.xz forums-e4f782819968ec44f1dd207dc9de7ec703826d29.zip |
[ticket/11386] Send list of migrations instead of using load_migrations
Remove dependency of extension manager for migrator.
Keeping load_migrations function for others to use if they desire
but requiring the finder be sent to it in order to use it.
PHPBB3-11386
Diffstat (limited to 'phpBB/includes/extension')
-rw-r--r-- | phpBB/includes/extension/manager.php | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index 0d760681b9..44a30c6280 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -43,18 +43,20 @@ class phpbb_extension_manager * @param ContainerInterface $container A container * @param phpbb_db_driver $db A database connection * @param phpbb_config $config phpbb_config + * @param phpbb_db_migrator $migrator * @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 phpbb_cache_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 $db, phpbb_config $config, $extension_table, $phpbb_root_path, $php_ext = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext') + public function __construct(ContainerInterface $container, phpbb_db_driver $db, phpbb_config $config, phpbb_db_migrator $migrator, $extension_table, $phpbb_root_path, $php_ext = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext') { $this->container = $container; $this->phpbb_root_path = $phpbb_root_path; $this->db = $db; $this->config = $config; + $this->migrator = $migrator; $this->cache = $cache; $this->php_ext = $php_ext; $this->extension_table = $extension_table; @@ -69,14 +71,6 @@ class phpbb_extension_manager } /** - * Set migrator (get around circular reference) - */ - public function set_migrator(phpbb_db_migrator $migrator) - { - $this->migrator = $migrator; - } - - /** * Loads all extension information from the database * * @return null @@ -528,13 +522,27 @@ class phpbb_extension_manager */ protected function handle_migrations($extension_name, $mode) { - $migrations_path = $this->phpbb_root_path . $this->get_extension_path($extension_name) . 'migrations/'; - if (!file_exists($migrations_path) || !is_dir($migrations_path)) + $extensions = array( + $extension_name => $this->phpbb_root_path . $this->get_extension_path($extension_name), + ); + + $finder = $this->get_finder(); + $migrations = array(); + $file_list = $finder + ->extension_directory('/migrations') + ->find_from_paths($extensions); + + if (empty($file_list)) { return true; } - $migrations = $this->migrator->load_migrations($migrations_path); + foreach ($file_list as $file) + { + $migrations[$file['named_path']] = $file['ext_name']; + } + $migrations = $finder->get_classes_from_files($migrations); + $this->migrator->set_migrations($migrations); // What is a safe limit of execution time? Half the max execution time should be safe. $safe_time_limit = (ini_get('max_execution_time') / 2); |