diff --git a/phpBB/config/installer/container/services_install_finish.yml b/phpBB/config/installer/container/services_install_finish.yml index 8b06ad7d97..eeddf14070 100644 --- a/phpBB/config/installer/container/services_install_finish.yml +++ b/phpBB/config/installer/container/services_install_finish.yml @@ -18,6 +18,15 @@ services: tags: - { name: install_finish, order: 20 } + installer.install_finish.install_viglink: + class: phpbb\install\module\install_finish\task\install_viglink + arguments: + - @installer.helper.container_factory + - @installer.helper.config + - @installer.helper.iohandler + tags: + - { name: install_finish, order: 15 } + installer.module.install_finish_collection: class: phpbb\di\ordered_service_collection arguments: diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index 35cea17a24..73f7f400a6 100644 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -301,6 +301,7 @@ $lang = array_merge($lang, array( 'TASK_ADD_MODULES' => 'Installing modules', // Install finish tasks + 'TASK_INSTALL_VIGLINK' => 'Installing viglink extension', 'TASK_NOTIFY_USER' => 'Sending notification e-mail', 'TASK_POPULATE_MIGRATIONS' => 'Populating migrations', diff --git a/phpBB/phpbb/install/module/install_finish/task/install_viglink.php b/phpBB/phpbb/install/module/install_finish/task/install_viglink.php new file mode 100644 index 0000000000..1facb1eaf4 --- /dev/null +++ b/phpBB/phpbb/install/module/install_finish/task/install_viglink.php @@ -0,0 +1,119 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\install\module\install_finish\task; + +/** + * Installs viglink extension with default config + */ +class install_viglink extends \phpbb\install\task_base +{ + /** + * @var \phpbb\install\helper\config + */ + protected $install_config; + + /** + * @var \phpbb\install\helper\iohandler\iohandler_interface + */ + protected $iohandler; + + /** + * @var \phpbb\config\db + */ + protected $config; + + /** + * @var \phpbb\log\log_interface + */ + protected $log; + + /** + * @var \phpbb\user + */ + protected $user; + + /** @var \phpbb\extension\manager */ + protected $extension_manager; + + /** + * Constructor + * + * @param \phpbb\install\helper\container_factory $container + * @param \phpbb\install\helper\config $install_config + * @param \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) + { + $this->install_config = $install_config; + $this->iohandler = $iohandler; + + $this->log = $container->get('log'); + $this->user = $container->get('user'); + $this->extension_manager = $container->get('ext.manager'); + $this->config = $container->get('config'); + + // Make sure asset version exists in config. Otherwise we might try to + // insert the assets_version setting into the database and cause a + // duplicate entry error. + if (!isset($this->config['assets_version'])) + { + $this->config['assets_version'] = 0; + } + + parent::__construct(true); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->user->session_begin(); + $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)) + { + $this->extension_manager->enable($name); + $this->extension_manager->load_extensions(); + + if (!$this->extension_manager->is_enabled($name)) + { + // Create log + $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($name)); + } + } + else + { + $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array('phpbb/viglink')); + } + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 1; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return 'TASK_INSTALL_VIGLINK'; + } +}