]> Raphaël G. Git Repositories - airbundle/blob - Command/Command.php
Update controller base class name
[airbundle] / Command / Command.php
1 <?php declare(strict_types=1);
2
3 /*
4 * This file is part of the Rapsys AirBundle package.
5 *
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
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 Rapsys\AirBundle\Command;
13
14 use Doctrine\Persistence\ManagerRegistry;
15 use Symfony\Component\Console\Command\Command as BaseCommand;
16 use Symfony\Component\Routing\RouterInterface;
17 use Symfony\Contracts\Translation\TranslatorInterface;
18
19 use Rapsys\AirBundle\RapsysAirBundle;
20
21 use Rapsys\PackBundle\Util\SluggerUtil;
22
23 class Command extends BaseCommand {
24 /**
25 * Doctrine instance
26 *
27 * @var ManagerRegistry
28 */
29 protected ManagerRegistry $doctrine;
30
31 /**
32 * Router instance
33 *
34 * @var RouterInterface
35 */
36 protected RouterInterface $router;
37
38 /**
39 * Slugger instance
40 *
41 * @var SluggerUtil
42 */
43 protected SluggerUtil $slugger;
44
45 /**
46 * Translator instance
47 *
48 * @var TranslatorInterface
49 */
50 protected TranslatorInterface $translator;
51
52 /**
53 * Locale
54 *
55 * @var string
56 */
57 protected string $locale;
58
59 /**
60 * Creates new command
61 *
62 * @param ManagerRegistry $doctrine The doctrine instance
63 * @param RouterInterface $router The router instance
64 * @param SluggerUtil $slugger The slugger instance
65 * @param TranslatorInterface $translator The translator instance
66 * @param string $locale The default locale
67 */
68 public function __construct(ManagerRegistry $doctrine, RouterInterface $router, SluggerUtil $slugger, TranslatorInterface $translator, string $locale) {
69 //Call parent constructor
70 parent::__construct();
71
72 //Set doctrine
73 $this->doctrine = $doctrine;
74
75 //Set router
76 $this->router = $router;
77
78 //Set slugger
79 $this->slugger = $slugger;
80
81 //Get router context
82 $context = $this->router->getContext();
83
84 //Set host
85 $context->setHost('airlibre.eu');
86
87 //Set scheme
88 $context->setScheme('https');
89
90 //Set the translator
91 $this->translator = $translator;
92
93 //Set locale
94 $this->locale = $locale;
95 }
96
97 /**
98 * Return the bundle alias
99 *
100 * {@inheritdoc}
101 */
102 public function getAlias(): string {
103 return RapsysAirBundle::getAlias();
104 }
105 }