mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 05:50:42 +02:00
[ticket/14492] Install all packaged extensions by default
PHPBB3-14492
This commit is contained in:
@@ -14,9 +14,9 @@
|
||||
namespace phpbb\install\module\install_finish\task;
|
||||
|
||||
/**
|
||||
* Installs viglink extension with default config
|
||||
* Installs extensions that exist in ext folder upon install
|
||||
*/
|
||||
class install_viglink extends \phpbb\install\task_base
|
||||
class install_extensions extends \phpbb\install\task_base
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\install\helper\config
|
||||
@@ -46,14 +46,18 @@ class install_viglink extends \phpbb\install\task_base
|
||||
/** @var \phpbb\extension\manager */
|
||||
protected $extension_manager;
|
||||
|
||||
/** @var \Symfony\Component\Finder\Finder */
|
||||
protected $finder;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\install\helper\container_factory $container
|
||||
* @param \phpbb\install\helper\config $install_config
|
||||
* @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler
|
||||
* @param string $phpbb_root_path phpBB root path
|
||||
*/
|
||||
public function __construct(\phpbb\install\helper\container_factory $container, \phpbb\install\helper\config $install_config, \phpbb\install\helper\iohandler\iohandler_interface $iohandler)
|
||||
public function __construct(\phpbb\install\helper\container_factory $container, \phpbb\install\helper\config $install_config, \phpbb\install\helper\iohandler\iohandler_interface $iohandler, $phpbb_root_path)
|
||||
{
|
||||
$this->install_config = $install_config;
|
||||
$this->iohandler = $iohandler;
|
||||
@@ -62,6 +66,12 @@ class install_viglink extends \phpbb\install\task_base
|
||||
$this->user = $container->get('user');
|
||||
$this->extension_manager = $container->get('ext.manager');
|
||||
$this->config = $container->get('config');
|
||||
$this->finder = new \Symfony\Component\Finder\Finder();
|
||||
$this->finder->in($phpbb_root_path . 'ext/')
|
||||
->ignoreUnreadableDirs()
|
||||
->depth('< 3')
|
||||
->files()
|
||||
->name('composer.json');
|
||||
|
||||
// Make sure asset version exists in config. Otherwise we might try to
|
||||
// insert the assets_version setting into the database and cause a
|
||||
@@ -83,21 +93,27 @@ class install_viglink extends \phpbb\install\task_base
|
||||
$this->user->setup(array('common', 'acp/common', 'cli'));
|
||||
$name = 'phpbb/viglink';
|
||||
|
||||
// Should be available by default but make sure it is
|
||||
if ($this->extension_manager->is_available($name))
|
||||
// Find available extensions
|
||||
foreach ($this->finder as $file)
|
||||
{
|
||||
$this->extension_manager->enable($name);
|
||||
$this->extension_manager->load_extensions();
|
||||
/** @var \SplFileInfo $file */
|
||||
$ext_name = preg_replace('#(.+ext[\\/\\\])#', '', dirname($file->getRealPath()));
|
||||
|
||||
if (!$this->extension_manager->is_enabled($name))
|
||||
if ($this->extension_manager->is_available($ext_name))
|
||||
{
|
||||
// Create log
|
||||
$this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($name));
|
||||
$this->extension_manager->enable($ext_name);
|
||||
$this->extension_manager->load_extensions();
|
||||
|
||||
if (!$this->extension_manager->is_enabled($ext_name))
|
||||
{
|
||||
// Create log
|
||||
$this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array($ext_name));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array('phpbb/viglink'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +130,6 @@ class install_viglink extends \phpbb\install\task_base
|
||||
*/
|
||||
public function get_task_lang_name()
|
||||
{
|
||||
return 'TASK_INSTALL_VIGLINK';
|
||||
return 'TASK_INSTALL_EXTENSIONS';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user