|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Potievdev\SlimRbac\Console; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Application; |
|
6
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
7
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
8
|
|
|
|
|
9
|
|
|
class SlimRbacConsoleApplication extends Application |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* Class Constructor. |
|
13
|
|
|
* |
|
14
|
|
|
* Initialize the SlimRbac console application. |
|
15
|
|
|
* |
|
16
|
|
|
* @param string $version The Application Version |
|
17
|
|
|
*/ |
|
18
|
|
|
public function __construct(string $version = '1.0.0') |
|
19
|
|
|
{ |
|
20
|
|
|
parent::__construct('https://github.com/potievdev/slim_rbac?v=' . $version); |
|
21
|
|
|
|
|
22
|
|
|
$this->addCommands([ |
|
23
|
|
|
new Command\CreateConfigCommand(), |
|
24
|
|
|
new Command\MigrateDatabaseCommand(), |
|
25
|
|
|
new Command\RollbackDatabaseCommand(), |
|
26
|
|
|
]); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Runs the current application. |
|
31
|
|
|
* |
|
32
|
|
|
* @param InputInterface $input An Input instance |
|
33
|
|
|
* @param OutputInterface $output An Output instance |
|
34
|
|
|
* @return integer 0 if everything went fine, or an error code |
|
35
|
|
|
* @throws \Throwable |
|
36
|
|
|
*/ |
|
37
|
|
|
public function doRun(InputInterface $input, OutputInterface $output): int |
|
38
|
|
|
{ |
|
39
|
|
|
// always show the version information except when the user invokes the help |
|
40
|
|
|
// command as that already does it |
|
41
|
|
|
if (false === $input->hasParameterOption(['--help', '-h']) && null !== $input->getFirstArgument()) { |
|
42
|
|
|
$output->writeln($this->getLongVersion()); |
|
43
|
|
|
$output->writeln('Slim Role Based Access Control Middleware'); |
|
44
|
|
|
$output->writeln(''); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
return parent::doRun($input, $output); |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|