]> Raphaël G. Git Repositories - airbundle/blob - Command/RekeyCommand.php
Cleanup
[airbundle] / Command / RekeyCommand.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\Bundle\DoctrineBundle\Command\DoctrineCommand;
15 use Symfony\Component\Console\Input\InputInterface;
16 use Symfony\Component\Console\Output\OutputInterface;
17
18 use Rapsys\AirBundle\Command;
19 use Rapsys\AirBundle\Entity\Session;
20
21 class RekeyCommand extends DoctrineCommand {
22 //Set failure constant
23 const FAILURE = 1;
24
25 ///Set success constant
26 const SUCCESS = 0;
27
28 ///Configure attribute command
29 protected function configure() {
30 //Configure the class
31 $this
32 //Set name
33 ->setName('rapsysair:rekey')
34 //Set description shown with bin/console list
35 ->setDescription('Rekey sessions')
36 //Set description shown with bin/console --help airlibre:attribute
37 ->setHelp('This command rekey sessions in chronological order');
38 }
39
40 ///Process the attribution
41 protected function execute(InputInterface $input, OutputInterface $output): int {
42 //Fetch doctrine
43 $doctrine = $this->getDoctrine();
44
45 //Rekey sessions
46 if (!$doctrine->getRepository(Session::class)->rekey()) {
47 //Return failure
48 return self::FAILURE;
49 }
50
51 //Return success
52 return self::SUCCESS;
53 }
54
55 /**
56 * Return the bundle alias
57 *
58 * {@inheritdoc}
59 */
60 public function getAlias(): string {
61 return 'rapsys_air';
62 }
63 }