1 <?php 
declare(strict_types
=1); 
   4  * This file is part of the Rapsys AirBundle package. 
   6  * (c) Raphaël Gertz <symfony@rapsys.eu> 
   8  * For the full copyright and license information, please view the LICENSE 
   9  * file that was distributed with this source code. 
  12 namespace Rapsys\AirBundle
; 
  14 use Doctrine\Persistence\ManagerRegistry
; 
  16 use Symfony\Component\Console\Command\Command 
as BaseCommand
; 
  17 use Symfony\Component\Routing\RouterInterface
; 
  18 use Symfony\Contracts\Translation\TranslatorInterface
; 
  20 use Rapsys\AirBundle\RapsysAirBundle
; 
  22 use Rapsys\PackBundle\Util\SluggerUtil
; 
  27 class Command 
extends BaseCommand 
{ 
  33          * @param ManagerRegistry $doctrine The doctrine instance 
  34          * @param RouterInterface $router The router instance 
  35          * @param SluggerUtil $slugger The slugger instance 
  36          * @param TranslatorInterface $translator The translator instance 
  37          * @param string $locale The default locale 
  39         public function __construct(protected ManagerRegistry 
$doctrine, protected string $locale, protected RouterInterface 
$router, protected SluggerUtil 
$slugger, protected TranslatorInterface 
$translator, protected ?string $name = null) { 
  41                 $this->name 
= $this->name 
?? static::getName(); 
  43                 //Call parent constructor 
  44                 parent
::__construct($this->name
); 
  47                 if (!empty($this->description
)) { 
  49                         $this->setDescription($this->description
); 
  53                 if (!empty($this->help
)) { 
  55                         $this->setHelp($this->help
); 
  59                 $context = $this->router
->getContext(); 
  62                 $context->setHost($_ENV['RAPSYSAIR_HOSTNAME']); 
  65                 $context->setScheme($_ENV['RAPSYSAIR_SCHEME'] ?? 'https'); 
  71          * Return the command name 
  73         public function getName(): string { 
  75                 if ($npos = strrpos(static::class, '\\')) { 
  83                 //With trailing command 
  84                 if (substr(static::class, -strlen('Command'), strlen('Command')) === 'Command') { 
  86                         $bpos = strlen(static::class) - $npos - strlen('Command'); 
  90                         $bpos = strlen(static::class) - $npos; 
  93                 //Return command alias 
  94                 return RapsysAirBundle
::getAlias().':'.strtolower(substr(static::class, $npos, $bpos));