Completed
Push — master ( b4fb45...fd4491 )
by dima
02:45
created

InstallPackagesCommand::execute()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 22
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 22
rs 9.2
cc 3
eloc 12
nc 3
nop 2
1
<?php
2
3
namespace Frameworkless\Console\Commands;
4
5
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
/**
10
 * Description of HelloWorldCommand
11
 *
12
 * @author Dmitriy
13
 */
14
class InstallPackagesCommand extends Command
15
{
16
    protected function configure()
17
    {
18
        $this->setName('install:packages')
19
            ->setDescription('Install packages migration and assets');
20
    }
21
22
    protected function execute(InputInterface $input, OutputInterface $output)
23
    {
24
		$finder = \Symfony\Component\Finder\Finder::create();
25
26
		$root_path = __DIR__ . "../../../..";
27
28
		$iterator = $finder
29
				->files()
30
				->in($root_path . "/vendor/*/*/db");
31
32
		foreach ($iterator as $file) {
33
34
			if (!copy($file->getRealpath(), $root_path . '/db/' . $file->getRelativePathname())) {
35
			  $output->writeln( sprintf("error copy migration %s...", $file->getRelativePathname()) );
36
			}
37
			else{
38
				$output->writeln( sprintf("copy migration %s", $file->getRelativePathname()) );
39
			}
40
		}
41
		
42
        $output->writeln("completed!");
43
    }
44
}
45