Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Console.php
Go to the documentation of this file.
1 <?php
7 
9 use Symfony\Component\Console\Output\OutputInterface;
10 
11 class Console
12 {
18  protected $_messages = [
19  Log::GENERATION_SUCCESS => 'Generated classes:',
20  Log::GENERATION_ERROR => 'Errors during class generation:',
21  Log::COMPILATION_ERROR => 'Errors during compilation:',
22  Log::CONFIGURATION_ERROR => 'Errors during configuration scanning:',
23  ];
24 
30  protected $console;
31 
35  public function __construct(OutputInterface $output)
36  {
37  $this->console = $output;
38  }
39 
46  public function write(array $data)
47  {
48  $errorsCount = 0;
49  foreach ($data as $type => $classes) {
50  if (!count($classes)) {
51  continue;
52  }
53  $this->console->writeln($this->getStartTag($type) . $this->_messages[$type] . $this->getEndTag($type));
54  foreach ($classes as $className => $messages) {
55  if (count($messages)) {
56  $this->console->writeln($this->getStartTag($type) . "\t" . $className . $this->getEndTag($type));
57  foreach ($messages as $message) {
58  if ($message) {
59  $this->console->writeln(
60  $this->getStartTag($type) . "\t\t" . $message . $this->getEndTag($type)
61  );
63  $errorsCount++;
64  }
65  }
66  }
67  }
68  }
69  }
70 
71  if ($errorsCount) {
72  $this->console->writeln('<error>' . 'Total Errors Count: ' . $errorsCount . '</error>');
73  }
74  }
75 
82  private function getStartTag($type)
83  {
85  return '<info>';
86  } else {
87  return '<error>';
88  }
89  }
90 
97  private function getEndTag($type)
98  {
100  return '</info>';
101  } else {
102  return '</error>';
103  }
104  }
105 }
$message
$type
Definition: item.phtml:13
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31