Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
populate_migrations
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 4
42
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 run
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
12
 get_step_count
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_task_lang_name
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 *
4 * This file is part of the phpBB Forum Software package.
5 *
6 * @copyright (c) phpBB Limited <https://www.phpbb.com>
7 * @license GNU General Public License, version 2 (GPL-2.0)
8 *
9 * For full copyright and license information, please see
10 * the docs/CREDITS.txt file.
11 *
12 */
13
14namespace phpbb\install\module\install_finish\task;
15
16use phpbb\install\exception\resource_limit_reached_exception;
17use phpbb\install\helper\config;
18use phpbb\install\helper\container_factory;
19
20/**
21 * Populates migrations
22 */
23class populate_migrations extends \phpbb\install\task_base
24{
25    /**
26     * @var config
27     */
28    protected $config;
29
30    /**
31     * @var \phpbb\extension\manager
32     */
33    protected $extension_manager;
34
35    /**
36     * @var \phpbb\db\migrator
37     */
38    protected $migrator;
39
40    /**
41     * Constructor
42     *
43     * @param config            $config        Installer's config
44     * @param container_factory    $container    phpBB's DI contianer
45     */
46    public function __construct(config $config, container_factory $container)
47    {
48        $this->config                = $config;
49        $this->extension_manager    = $container->get('ext.manager');
50        $this->migrator                = $container->get('migrator');
51
52        parent::__construct(true);
53    }
54
55    /**
56     * {@inheritdoc}
57     */
58    public function run()
59    {
60        if (!$this->config->get('populate_migration_refresh_before', false))
61        {
62            if ($this->config->get_time_remaining() < 1)
63            {
64                $this->config->set('populate_migration_refresh_before', true);
65                throw new resource_limit_reached_exception();
66            }
67        }
68
69        $finder = $this->extension_manager->get_finder();
70
71        $migrations = $finder
72            ->core_path('phpbb/db/migration/data/')
73            ->set_extensions(array())
74            ->get_classes();
75        $this->migrator->populate_migrations($migrations);
76    }
77
78    /**
79     * {@inheritdoc}
80     */
81    public static function get_step_count()
82    {
83        return 1;
84    }
85
86    /**
87     * {@inheritdoc}
88     */
89    public function get_task_lang_name()
90    {
91        return 'TASK_POPULATE_MIGRATIONS';
92    }
93}