From 7030578bbe9e11c18b5becaf8b06e670e3c2e3cd Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 14 Jul 2013 01:32:34 -0400 Subject: [ticket/11698] Moving all autoloadable files to phpbb/ PHPBB3-11698 --- phpBB/phpbb/extension/base.php | 135 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 phpBB/phpbb/extension/base.php (limited to 'phpBB/phpbb/extension/base.php') diff --git a/phpBB/phpbb/extension/base.php b/phpBB/phpbb/extension/base.php new file mode 100644 index 0000000000..c4462b64d8 --- /dev/null +++ b/phpBB/phpbb/extension/base.php @@ -0,0 +1,135 @@ +container = $container; + $this->extension_finder = $extension_finder; + $this->migrator = $migrator; + + $this->extension_name = $extension_name; + $this->extension_path = $extension_path; + } + + /** + * Single enable step that installs any included migrations + * + * @param mixed $old_state State returned by previous call of this method + * @return false Indicates no further steps are required + */ + public function enable_step($old_state) + { + $migrations = $this->get_migration_file_list(); + + $this->migrator->set_migrations($migrations); + + $this->migrator->update(); + + return !$this->migrator->finished(); + } + + /** + * Single disable step that does nothing + * + * @param mixed $old_state State returned by previous call of this method + * @return false Indicates no further steps are required + */ + public function disable_step($old_state) + { + return false; + } + + /** + * Single purge step that reverts any included and installed migrations + * + * @param mixed $old_state State returned by previous call of this method + * @return false Indicates no further steps are required + */ + public function purge_step($old_state) + { + $migrations = $this->get_migration_file_list(); + + $this->migrator->set_migrations($migrations); + + foreach ($migrations as $migration) + { + while ($this->migrator->migration_state($migration) !== false) + { + $this->migrator->revert($migration); + + return true; + } + } + + return false; + } + + /** + * Get the list of migration files from this extension + * + * @return array + */ + protected function get_migration_file_list() + { + static $migrations = false; + + if ($migrations !== false) + { + return $migrations; + } + + // Only have the finder search in this extension path directory + $migrations = $this->extension_finder + ->extension_directory('/migrations') + ->find_from_extension($this->extension_name, $this->extension_path); + $migrations = $this->extension_finder->get_classes_from_files($migrations); + + return $migrations; + } +} -- cgit v1.2.1 From da2752e4004b296ae5acdd08b7c0a758d8f61e9d Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 14 Jul 2013 13:30:52 -0400 Subject: [ticket/11700] Modify all code to use the new interface names PHPBB3-11700 --- phpBB/phpbb/extension/base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/extension/base.php') diff --git a/phpBB/phpbb/extension/base.php b/phpBB/phpbb/extension/base.php index c4462b64d8..de18998106 100644 --- a/phpBB/phpbb/extension/base.php +++ b/phpBB/phpbb/extension/base.php @@ -22,7 +22,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * * @package extension */ -class phpbb_extension_base implements phpbb_extension_interface +class phpbb_extension_base implements phpbb_extension_extension_interface { /** @var ContainerInterface */ protected $container; -- cgit v1.2.1 From b95fdacdd378877d277e261465da73deb06e50da Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 10 Sep 2013 14:01:09 +0200 Subject: [ticket/11700] Move all recent code to namespaces PHPBB3-11700 --- phpBB/phpbb/extension/base.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb/extension/base.php') diff --git a/phpBB/phpbb/extension/base.php b/phpBB/phpbb/extension/base.php index de18998106..a529cc7961 100644 --- a/phpBB/phpbb/extension/base.php +++ b/phpBB/phpbb/extension/base.php @@ -7,6 +7,8 @@ * */ +namespace phpbb\extension; + /** * @ignore */ @@ -22,15 +24,15 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * * @package extension */ -class phpbb_extension_base implements phpbb_extension_extension_interface +class base implements \phpbb\extension\extension_interface { /** @var ContainerInterface */ protected $container; - /** @var phpbb_extension_finder */ + /** @var \phpbb\extension\finder */ protected $finder; - /** @var phpbb_db_migrator */ + /** @var \phpbb\db\migrator */ protected $migrator; /** @var string */ @@ -43,11 +45,11 @@ class phpbb_extension_base implements phpbb_extension_extension_interface * Constructor * * @param ContainerInterface $container Container object - * @param phpbb_extension_finder $extension_finder + * @param \phpbb\extension\finder $extension_finder * @param string $extension_name Name of this extension (from ext.manager) * @param string $extension_path Relative path to this extension */ - public function __construct(ContainerInterface $container, phpbb_extension_finder $extension_finder, phpbb_db_migrator $migrator, $extension_name, $extension_path) + public function __construct(ContainerInterface $container, \phpbb\extension\finder $extension_finder, \phpbb\db\migrator $migrator, $extension_name, $extension_path) { $this->container = $container; $this->extension_finder = $extension_finder; -- cgit v1.2.1 From 7aa8f6461f1e85cf91931f56b95384e54fec07c2 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 30 Oct 2013 13:05:28 +0100 Subject: [task/code-sniffer] Remove the IN_PHPBB check side-effect from class files. PHPBB3-11980 --- phpBB/phpbb/extension/base.php | 8 -------- 1 file changed, 8 deletions(-) (limited to 'phpBB/phpbb/extension/base.php') diff --git a/phpBB/phpbb/extension/base.php b/phpBB/phpbb/extension/base.php index a529cc7961..1f871750e0 100644 --- a/phpBB/phpbb/extension/base.php +++ b/phpBB/phpbb/extension/base.php @@ -9,14 +9,6 @@ namespace phpbb\extension; -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - use Symfony\Component\DependencyInjection\ContainerInterface; /** -- cgit v1.2.1 From a759704b39fc1c1353f865a633759b1369589b67 Mon Sep 17 00:00:00 2001 From: Yuriy Rusko Date: Tue, 27 May 2014 20:18:06 +0200 Subject: [ticket/12594] Remove @package tags and update file headers PHPBB3-12594 --- phpBB/phpbb/extension/base.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'phpBB/phpbb/extension/base.php') diff --git a/phpBB/phpbb/extension/base.php b/phpBB/phpbb/extension/base.php index 1f871750e0..eb306aeb72 100644 --- a/phpBB/phpbb/extension/base.php +++ b/phpBB/phpbb/extension/base.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ @@ -13,8 +17,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface; /** * A base class for extensions without custom enable/disable/purge code. -* -* @package extension */ class base implements \phpbb\extension\extension_interface { -- cgit v1.2.1 From 183492b01931dec5052e2087f70fa432a2f51b03 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 6 May 2014 18:27:30 +0200 Subject: [ticket/12508] Move \phpbb\extension\finder to \phpbb\finder PHPBB3-12508 --- phpBB/phpbb/extension/base.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/extension/base.php') diff --git a/phpBB/phpbb/extension/base.php b/phpBB/phpbb/extension/base.php index eb306aeb72..cbbd7bc622 100644 --- a/phpBB/phpbb/extension/base.php +++ b/phpBB/phpbb/extension/base.php @@ -23,7 +23,7 @@ class base implements \phpbb\extension\extension_interface /** @var ContainerInterface */ protected $container; - /** @var \phpbb\extension\finder */ + /** @var \phpbb\finder */ protected $finder; /** @var \phpbb\db\migrator */ @@ -39,11 +39,11 @@ class base implements \phpbb\extension\extension_interface * Constructor * * @param ContainerInterface $container Container object - * @param \phpbb\extension\finder $extension_finder + * @param \phpbb\finder $extension_finder * @param string $extension_name Name of this extension (from ext.manager) * @param string $extension_path Relative path to this extension */ - public function __construct(ContainerInterface $container, \phpbb\extension\finder $extension_finder, \phpbb\db\migrator $migrator, $extension_name, $extension_path) + public function __construct(ContainerInterface $container, \phpbb\finder $extension_finder, \phpbb\db\migrator $migrator, $extension_name, $extension_path) { $this->container = $container; $this->extension_finder = $extension_finder; -- cgit v1.2.1 From 519e64205a50b15efa8589901c87f5b21448993a Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 13 Jul 2014 15:44:58 +0200 Subject: [ticket/12847] Allow the extensions to say if they can be enabled PHPBB3-12847 --- phpBB/phpbb/extension/base.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'phpBB/phpbb/extension/base.php') diff --git a/phpBB/phpbb/extension/base.php b/phpBB/phpbb/extension/base.php index cbbd7bc622..288fb7d19c 100644 --- a/phpBB/phpbb/extension/base.php +++ b/phpBB/phpbb/extension/base.php @@ -40,6 +40,7 @@ class base implements \phpbb\extension\extension_interface * * @param ContainerInterface $container Container object * @param \phpbb\finder $extension_finder + * @param \phpbb\db\migrator $migrator * @param string $extension_name Name of this extension (from ext.manager) * @param string $extension_path Relative path to this extension */ @@ -53,6 +54,14 @@ class base implements \phpbb\extension\extension_interface $this->extension_path = $extension_path; } + /** + * {@inheritdoc} + */ + public function is_enableable() + { + return true; + } + /** * Single enable step that installs any included migrations * -- cgit v1.2.1 From ff872a79707200ed7e3e7c25b4ebc7f6f4313b6c Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 10 Sep 2014 19:17:37 +0200 Subject: [ticket/12963] Don't use static var in \extension\base\get_migration_file_list The static var was global to all instance of \phpbb\base and so if two different instances (for two different extensions) were created by the same script they shared the same migrations list. PHPBB3-12963 --- phpBB/phpbb/extension/base.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/extension/base.php') diff --git a/phpBB/phpbb/extension/base.php b/phpBB/phpbb/extension/base.php index 288fb7d19c..e0ccb4c65b 100644 --- a/phpBB/phpbb/extension/base.php +++ b/phpBB/phpbb/extension/base.php @@ -35,6 +35,9 @@ class base implements \phpbb\extension\extension_interface /** @var string */ protected $extension_path; + /** @var string[] */ + private $migrations = false; + /** * Constructor * @@ -122,11 +125,9 @@ class base implements \phpbb\extension\extension_interface */ protected function get_migration_file_list() { - static $migrations = false; - - if ($migrations !== false) + if ($this->migrations !== false) { - return $migrations; + return $this->migrations; } // Only have the finder search in this extension path directory -- cgit v1.2.1 From 72ee4b3a7c4fca67cb226dab3ed27a8afa903144 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 10 Sep 2014 12:08:13 +0200 Subject: [ticket/12963] Load extensions migrations from /migration PHPBB3-12963 --- phpBB/phpbb/extension/base.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/extension/base.php') diff --git a/phpBB/phpbb/extension/base.php b/phpBB/phpbb/extension/base.php index e0ccb4c65b..9cd37ec8b2 100644 --- a/phpBB/phpbb/extension/base.php +++ b/phpBB/phpbb/extension/base.php @@ -132,10 +132,20 @@ class base implements \phpbb\extension\extension_interface // Only have the finder search in this extension path directory $migrations = $this->extension_finder - ->extension_directory('/migrations') + ->extension_directory('/migration') ->find_from_extension($this->extension_name, $this->extension_path); + $migrations = $this->extension_finder->get_classes_from_files($migrations); + // @deprecated to be removed in 3.2 final + $migrations_deprecated = $this->extension_finder + ->extension_directory('/migrations') + ->find_from_extension($this->extension_name, $this->extension_path); + + $migrations_deprecated = $this->extension_finder->get_classes_from_files($migrations_deprecated); + + $migrations = array_merge($migrations, $migrations_deprecated); + return $migrations; } } -- cgit v1.2.1 From 8b16d3141396a11db3ab4ade49af91f2477f5fb6 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 16 Sep 2014 20:18:10 +0200 Subject: [ticket/12963] Edit deprecation message PHPBB3-12963 --- phpBB/phpbb/extension/base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/extension/base.php') diff --git a/phpBB/phpbb/extension/base.php b/phpBB/phpbb/extension/base.php index 9cd37ec8b2..b74026e6ab 100644 --- a/phpBB/phpbb/extension/base.php +++ b/phpBB/phpbb/extension/base.php @@ -137,7 +137,7 @@ class base implements \phpbb\extension\extension_interface $migrations = $this->extension_finder->get_classes_from_files($migrations); - // @deprecated to be removed in 3.2 final + // @deprecated 3.1.0-RC4 (To be removed: 3.2.0) $migrations_deprecated = $this->extension_finder ->extension_directory('/migrations') ->find_from_extension($this->extension_name, $this->extension_path); -- cgit v1.2.1 From c220fa89a1bf5652df6512ad78eb9ba550fe465e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 18 Sep 2014 10:42:21 +0200 Subject: [ticket/12963] Revert back to "migrations" folder name for extensions The issues that can be created with the name change are just too much PHPBB3-12963 --- phpBB/phpbb/extension/base.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'phpBB/phpbb/extension/base.php') diff --git a/phpBB/phpbb/extension/base.php b/phpBB/phpbb/extension/base.php index b74026e6ab..5bb530bad4 100644 --- a/phpBB/phpbb/extension/base.php +++ b/phpBB/phpbb/extension/base.php @@ -132,19 +132,10 @@ class base implements \phpbb\extension\extension_interface // Only have the finder search in this extension path directory $migrations = $this->extension_finder - ->extension_directory('/migration') - ->find_from_extension($this->extension_name, $this->extension_path); - - $migrations = $this->extension_finder->get_classes_from_files($migrations); - - // @deprecated 3.1.0-RC4 (To be removed: 3.2.0) - $migrations_deprecated = $this->extension_finder ->extension_directory('/migrations') ->find_from_extension($this->extension_name, $this->extension_path); - $migrations_deprecated = $this->extension_finder->get_classes_from_files($migrations_deprecated); - - $migrations = array_merge($migrations, $migrations_deprecated); + $migrations = $this->extension_finder->get_classes_from_files($migrations); return $migrations; } -- cgit v1.2.1