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