1 | <?php |
||
18 | class TestCommand extends ContainerAwareCommand |
||
19 | { |
||
20 | private $container; |
||
21 | |||
22 | protected function configure() |
||
23 | { |
||
24 | parent::configure(); |
||
25 | |||
26 | $this->setName('liipfunctionaltestbundle:test') |
||
27 | ->setDescription('Test command'); |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @param InputInterface $input |
||
32 | * @param OutputInterface $output |
||
33 | */ |
||
34 | protected function initialize(InputInterface $input, OutputInterface $output) |
||
35 | { |
||
36 | parent::initialize($input, $output); |
||
37 | |||
38 | $this->container = $this->getContainer(); |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * @param InputInterface $input |
||
43 | * @param OutputInterface $output |
||
44 | */ |
||
45 | protected function execute(InputInterface $input, OutputInterface $output) |
||
46 | { |
||
47 | // Symfony version check |
||
48 | $version = \Symfony\Component\HttpKernel\Kernel::VERSION_ID; |
||
49 | $output->writeln('Symfony version: '.$version); |
||
50 | $output->writeln('Environment: '.$this->container->get('kernel')->getEnvironment()); |
||
51 | $output->writeln('Verbosity level set: '.$output->getVerbosity()); |
||
52 | |||
53 | // Check for the version of Symfony: 20803 is the 2.8 |
||
54 | if ($version >= 20803) { |
||
55 | $output->writeln('Environment: '.$this->container->get('kernel')->getEnvironment(), OutputInterface::VERBOSITY_NORMAL); |
||
56 | |||
57 | // Write a line with OutputInterface::VERBOSITY_NORMAL (also if this level is set by default by Console) |
||
58 | $output->writeln('Verbosity level: NORMAL', OutputInterface::VERBOSITY_NORMAL); |
||
59 | |||
60 | // Write a line with OutputInterface::VERBOSITY_VERBOSE |
||
61 | $output->writeln('Verbosity level: VERBOSE', OutputInterface::VERBOSITY_VERBOSE); |
||
62 | |||
63 | // Write a line with OutputInterface::VERBOSITY_VERY_VERBOSE |
||
64 | $output->writeln('Verbosity level: VERY_VERBOSE', OutputInterface::VERBOSITY_VERY_VERBOSE); |
||
65 | |||
66 | // Write a line with OutputInterface::VERBOSITY_DEBUG |
||
67 | $output->writeln('Verbosity level: DEBUG', OutputInterface::VERBOSITY_DEBUG); |
||
68 | } else { |
||
69 | if ($output->getVerbosity() >= OutputInterface::VERBOSITY_NORMAL) { |
||
70 | $output->writeln('Verbosity level: NORMAL'); |
||
71 | } |
||
72 | |||
73 | if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { |
||
74 | $output->writeln('Verbosity level: VERBOSE'); |
||
75 | } |
||
76 | |||
77 | if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) { |
||
78 | $output->writeln('Verbosity level: VERY_VERBOSE'); |
||
79 | } |
||
80 | |||
81 | if ($output->getVerbosity() == OutputInterface::VERBOSITY_DEBUG) { |
||
82 | $output->writeln('Verbosity level: DEBUG'); |
||
83 | } |
||
84 | } |
||
85 | } |
||
86 | } |
||
87 |