Skip to content

Commit

Permalink
[general] Application contaner (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Jun 30, 2024
1 parent 48f2de6 commit d5098b4
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 72 deletions.
36 changes: 23 additions & 13 deletions src/Commands/Execute.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ protected function execute(Input\InputInterface $input, Output\OutputInterface $

$io = new Style\SymfonyStyle($input, $output);

$io->title($this->translator->translate('//virtual-connector.cmd.execute.title'));
$io->title((string) $this->translator->translate('//virtual-connector.cmd.execute.title'));

$io->note($this->translator->translate('//virtual-connector.cmd.execute.subtitle'));
$io->note((string) $this->translator->translate('//virtual-connector.cmd.execute.subtitle'));

if ($input->getOption('no-interaction') === false) {
$question = new Console\Question\ConfirmationQuestion(
$this->translator->translate('//virtual-connector.cmd.base.questions.continue'),
(string) $this->translator->translate('//virtual-connector.cmd.base.questions.continue'),
false,
);

Expand Down Expand Up @@ -141,7 +141,9 @@ protected function execute(Input\InputInterface $input, Output\OutputInterface $

if ($connector === null) {
$io->warning(
$this->translator->translate('//virtual-connector.cmd.execute.messages.connector.notFound'),
(string) $this->translator->translate(
'//virtual-connector.cmd.execute.messages.connector.notFound',
),
);

return Console\Command\Command::FAILURE;
Expand All @@ -166,7 +168,9 @@ protected function execute(Input\InputInterface $input, Output\OutputInterface $
}

if (count($connectors) === 0) {
$io->warning($this->translator->translate('//virtual-connector.cmd.base.messages.noConnectors'));
$io->warning(
(string) $this->translator->translate('//virtual-connector.cmd.base.messages.noConnectors'),
);

return Console\Command\Command::SUCCESS;
}
Expand All @@ -184,15 +188,17 @@ protected function execute(Input\InputInterface $input, Output\OutputInterface $

if ($connector === null) {
$io->warning(
$this->translator->translate('//virtual-connector.cmd.execute.messages.connector.notFound'),
(string) $this->translator->translate(
'//virtual-connector.cmd.execute.messages.connector.notFound',
),
);

return Console\Command\Command::FAILURE;
}

if ($input->getOption('no-interaction') === false) {
$question = new Console\Question\ConfirmationQuestion(
$this->translator->translate(
(string) $this->translator->translate(
'//virtual-connector.cmd.execute.questions.execute',
['connector' => $connector->getName() ?? $connector->getIdentifier()],
),
Expand All @@ -205,18 +211,18 @@ protected function execute(Input\InputInterface $input, Output\OutputInterface $
}
} else {
$question = new Console\Question\ChoiceQuestion(
$this->translator->translate('//virtual-connector.cmd.execute.questions.select.connector'),
(string) $this->translator->translate('//virtual-connector.cmd.execute.questions.select.connector'),
array_values($connectors),
);
$question->setErrorMessage(
$this->translator->translate('//virtual-connector.cmd.base.messages.answerNotValid'),
(string) $this->translator->translate('//virtual-connector.cmd.base.messages.answerNotValid'),
);
$question->setValidator(
function (string|int|null $answer) use ($connectors): Documents\Connectors\Connector {
if ($answer === null) {
throw new Exceptions\Runtime(
sprintf(
$this->translator->translate(
(string) $this->translator->translate(
'//virtual-connector.cmd.base.messages.answerNotValid',
),
$answer,
Expand Down Expand Up @@ -246,7 +252,9 @@ function (string|int|null $answer) use ($connectors): Documents\Connectors\Conne

throw new Exceptions\Runtime(
sprintf(
$this->translator->translate('//virtual-connector.cmd.base.messages.answerNotValid'),
(string) $this->translator->translate(
'//virtual-connector.cmd.base.messages.answerNotValid',
),
$answer,
),
);
Expand All @@ -259,7 +267,9 @@ function (string|int|null $answer) use ($connectors): Documents\Connectors\Conne
}

if (!$connector->isEnabled()) {
$io->warning($this->translator->translate('//virtual-connector.cmd.execute.messages.connector.disabled'));
$io->warning(
(string) $this->translator->translate('//virtual-connector.cmd.execute.messages.connector.disabled'),
);

return Console\Command\Command::SUCCESS;
}
Expand All @@ -273,7 +283,7 @@ function (string|int|null $answer) use ($connectors): Documents\Connectors\Conne
]), $output);

if ($result !== Console\Command\Command::SUCCESS) {
$io->error($this->translator->translate('//virtual-connector.cmd.execute.messages.error'));
$io->error((string) $this->translator->translate('//virtual-connector.cmd.execute.messages.error'));

return Console\Command\Command::FAILURE;
}
Expand Down
Loading

0 comments on commit d5098b4

Please sign in to comment.