-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathApplication.php
More file actions
45 lines (35 loc) · 1.09 KB
/
Copy pathApplication.php
File metadata and controls
45 lines (35 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
declare(strict_types=1);
namespace Dot\Cli;
use Exception;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Throwable;
class Application extends \Symfony\Component\Console\Application
{
private FileLockerInterface $fileLocker;
public function __construct(FileLockerInterface $fileLocker, array $config)
{
parent::__construct($config['name'] ?? 'UNKNOWN', $config['version'] ?? 'UNKNOWN');
$this->fileLocker = $fileLocker;
}
public function __destruct()
{
$this->fileLocker->unlock();
}
/**
* @throws Throwable
*/
public function doRun(InputInterface $input, OutputInterface $output): int
{
$this->fileLocker->setCommandName($this->getCommandName($input));
try {
$this->fileLocker->lock();
} catch (Exception $exception) {
$output->writeln($exception->getMessage());
return Command::FAILURE;
}
return parent::doRun($input, $output);
}
}