diff options
author | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
commit | bf6655a534a6775d30cafa67bd801276bda1d98d (patch) | |
tree | c6381e3f6c81c33eab72508f410b165ba05f7e9c /vendor/symfony/console/Messenger/RunCommandMessageHandler.php | |
parent | 94d67a4b51f8e62e7d518cce26a526ae1ec48278 (diff) | |
download | AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.zip |
VERSION 0.2 doctrine ORM et entités
Diffstat (limited to 'vendor/symfony/console/Messenger/RunCommandMessageHandler.php')
-rw-r--r-- | vendor/symfony/console/Messenger/RunCommandMessageHandler.php | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/vendor/symfony/console/Messenger/RunCommandMessageHandler.php b/vendor/symfony/console/Messenger/RunCommandMessageHandler.php new file mode 100644 index 0000000..1bc4994 --- /dev/null +++ b/vendor/symfony/console/Messenger/RunCommandMessageHandler.php | |||
@@ -0,0 +1,49 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
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 Symfony\Component\Console\Messenger; | ||
13 | |||
14 | use Symfony\Component\Console\Application; | ||
15 | use Symfony\Component\Console\Command\Command; | ||
16 | use Symfony\Component\Console\Exception\RunCommandFailedException; | ||
17 | use Symfony\Component\Console\Input\StringInput; | ||
18 | use Symfony\Component\Console\Output\BufferedOutput; | ||
19 | |||
20 | /** | ||
21 | * @author Kevin Bond <kevinbond@gmail.com> | ||
22 | */ | ||
23 | final class RunCommandMessageHandler | ||
24 | { | ||
25 | public function __construct( | ||
26 | private readonly Application $application, | ||
27 | ) { | ||
28 | } | ||
29 | |||
30 | public function __invoke(RunCommandMessage $message): RunCommandContext | ||
31 | { | ||
32 | $input = new StringInput($message->input); | ||
33 | $output = new BufferedOutput(); | ||
34 | |||
35 | $this->application->setCatchExceptions($message->catchExceptions); | ||
36 | |||
37 | try { | ||
38 | $exitCode = $this->application->run($input, $output); | ||
39 | } catch (\Throwable $e) { | ||
40 | throw new RunCommandFailedException($e, new RunCommandContext($message, Command::FAILURE, $output->fetch())); | ||
41 | } | ||
42 | |||
43 | if ($message->throwOnFailure && Command::SUCCESS !== $exitCode) { | ||
44 | throw new RunCommandFailedException(sprintf('Command "%s" exited with code "%s".', $message->input, $exitCode), new RunCommandContext($message, $exitCode, $output->fetch())); | ||
45 | } | ||
46 | |||
47 | return new RunCommandContext($message, $exitCode, $output->fetch()); | ||
48 | } | ||
49 | } | ||