InstallCommand::getBundleDir()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the HeltheTurbolinksBundle package.
5
 *
6
 * (c) Carl Alexander <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Helthe\Bundle\TurbolinksBundle\Command;
13
14
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Output\OutputInterface;
17
use Symfony\Component\Finder\Finder;
18
19
/**
20
 * Command that installs the turbolinks component assets in the bundle resources directory.
21
 *
22
 * @author Carl Alexander <[email protected]>
23
 */
24
class InstallCommand extends ContainerAwareCommand
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Bundle\Framework...d\ContainerAwareCommand has been deprecated with message: since Symfony 4.2, use {@see Command} instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29
    protected function configure()
30
    {
31
        $this
32
            ->setName('helthe:turbolinks:install')
33
            ->setDescription('Install turbolinks public assets into the bundle resources directory')
34
            ->setHelp(<<<EOT
35
The <info>helthe:turbolinks:install</info> command installs turbolinks
36
public assets into the bundle resources directory.
37
38
  <info>php app/console helthe:turbolinks:install</info>
39
EOT
40
            )
41
        ;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    protected function execute(InputInterface $input, OutputInterface $output)
48
    {
49
        $bundleDir = $this->getBundleDir();
50
        $componentDir = $this->getComponentDir();
51
        $filesystem = $this->getContainer()->get('filesystem');
52
53
        $filesystem->mkdir($bundleDir, 0777);
54
55
        $output->writeln('Installing turbolinks assets from <comment>"Helthe\Component\Turbolinks"</comment> into <comment>"Helthe\Bundle\TurbolinksBundle"</comment>');
56
57
        $filesystem->mirror($componentDir, $bundleDir, Finder::create()->ignoreDotFiles(false)->in($componentDir));
58
    }
59
60
    /**
61
     * Get the bundle resources directory.
62
     *
63
     * @return string
64
     */
65
    private function getBundleDir()
66
    {
67
        $rc = new \ReflectionClass('Helthe\Bundle\TurbolinksBundle\HeltheTurbolinksBundle');
68
69
        return dirname($rc->getFileName()) . '/Resources/public';
70
    }
71
72
    /**
73
     * Get the component resources directory.
74
     *
75
     * @return string
76
     */
77
    private function getComponentDir()
78
    {
79
        $rc = new \ReflectionClass('Helthe\Component\Turbolinks\Turbolinks');
80
81
        return dirname($rc->getFileName()) . '/Resources/public';
82
    }
83
}
84