Completed
Push — master ( 52b701...79736e )
by
unknown
05:15
created

Migrate::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 10
rs 9.4286
cc 1
eloc 7
nc 1
nop 2
1
<?php
2
/**
3
 * ownCloud - News
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Bernhard Posselt <[email protected]>
9
 * @copyright Bernhard Posselt 2015
10
 */
11
12
namespace OCA\News\Command;
13
14
use Symfony\Component\Console\Command\Command;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Output\OutputInterface;
17
use Symfony\Component\Console\Helper\ProgressBar;
18
19
use OCA\News\Service\ItemService;
20
21
22
class Migrate extends Command {
23
24
    private $service;
25
26
    public function __construct(ItemService $service) {
27
        parent::__construct();
28
        $this->service = $service;
29
    }
30
31
    protected function configure() {
32
        $this->setName('news:migrate')
33
             ->setDescription('Migrates the database schema. Needed when ' .
34
                              'updating from versions prior to: 7.0.0');
35
    }
36
37
    protected function execute(InputInterface $input, OutputInterface $output) {
38
        $output->writeln(
39
            "\nMigrating data, this could take a while...\n"
40
        );
41
        $progressbar = function ($steps) use ($output) {
42
            return new ProgressBar($output, $steps);
43
        };
44
        $this->service->generateSearchIndices($progressbar);
45
        $output->writeln("\n");
46
    }
47
48
}
49