]> Raphaël G. Git Repositories - airbundle/blob - Command.php
6f4a8eeb6f6e68f2cd425b1aa1597e04c1a94d05
[airbundle] / 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 //With default name
97 //TODO: XXX: see how to make it works
98 /*if (isset(self::$defaultName)) {
99 $this->name = self::$defaultName;
100 }
101
102 //With default description
103 if (isset(self::$defaultDescription)) {
104 $this->name = self::$defaultDescription;
105 }*/
106 }
107
108 /**
109 * Return the bundle alias
110 *
111 * {@inheritdoc}
112 */
113 public function getAlias(): string {
114 return RapsysAirBundle::getAlias();
115 }
116 }