1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 14:00:31 +02:00

[ticket/12847] Allow the extensions to say if they can be enabled

PHPBB3-12847
This commit is contained in:
Tristan Darricau
2014-07-13 15:44:58 +02:00
parent dd78b564e5
commit 519e64205a
9 changed files with 97 additions and 2 deletions

View File

@@ -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
*

View File

@@ -19,6 +19,13 @@ namespace phpbb\extension;
*/
interface extension_interface
{
/**
* Indicate whether or not the extension can be enabled.
*
* @return bool
*/
public function is_enableable();
/**
* enable_step is executed on enabling an extension until it returns false.
*

View File

@@ -177,6 +177,12 @@ class manager
$old_state = (isset($this->extensions[$name]['ext_state'])) ? unserialize($this->extensions[$name]['ext_state']) : false;
$extension = $this->get_extension($name);
if (!$extension->is_enableable())
{
return false;
}
$state = $extension->enable_step($old_state);
$active = ($state === false);