1 <?php
 2 
 3 use Symfony\Component\Console\Command\Command;
 4 use Symfony\Component\Console\Input\InputInterface;
 5 use Symfony\Component\Console\Output\OutputInterface;
 6 use Symfony\Component\Console\Style\SymfonyStyle;
 7 
 8 /**
 9  * @package redaxo\core
10  */
11 abstract class rex_console_command extends Command
12 {
13     /** @var null|rex_package */
14     protected $package;
15 
16     public function setPackage(rex_package $package = null)
17     {
18         $this->package = $package;
19 
20         return $this;
21     }
22 
23     /**
24      * @return null|rex_package In core commands it returns `null`, otherwise the corresponding package object
25      */
26     public function getPackage()
27     {
28         return $this->package;
29     }
30 
31     protected function getStyle(InputInterface $input, OutputInterface $output)
32     {
33         return new SymfonyStyle($input, $output);
34     }
35 
36     /**
37      * Decodes a html message for use in the CLI, e.g. provided by rex_i18n.
38      *
39      * @param string $message A html message
40      *
41      * @return string A cli optimzed message
42      */
43     protected function decodeMessage($message)
44     {
45         $message = preg_replace('/<br ?\/?>\r?\n?/', "\n", $message);
46         $message = strip_tags($message);
47 
48         return htmlspecialchars_decode($message, ENT_QUOTES);
49     }
50 }
51