Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/.editorconfig
/.php-cs-fixer.cache
/.phpunit.cache
/.phpunit.result.cache
/composer.lock
/vendor
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
3.3.2
=====

* (improvement) note


3.3.1
=====

Expand Down
35 changes: 13 additions & 22 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
colors="true"
bootstrap="vendor/autoload.php"
>
<php>
<ini name="error_reporting" value="-1" />
<server name="APP_ENV" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[direct]=0"/>
</php>

<testsuites>
<testsuite name="Bundle tests">
<directory>tests</directory>
<exclude>tests/fixtures</exclude>
</testsuite>
</testsuites>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/13.1/phpunit.xsd" colors="true" bootstrap="vendor/autoload.php" cacheDirectory=".phpunit.cache">
<php>
<ini name="error_reporting" value="-1"/>
<server name="APP_ENV" value="test" force="true"/>
<server name="SHELL_VERBOSITY" value="-1"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[direct]=0"/>
</php>
<testsuites>
<testsuite name="Bundle tests">
<directory>tests</directory>
<exclude>tests/fixtures</exclude>
</testsuite>
</testsuites>
</phpunit>
24 changes: 20 additions & 4 deletions src/Command/QueueTasksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Torr\Cli\Console\Style\TorrStyle;
use Torr\Hosting\Hosting\HostingEnvironment;
use Torr\TaskManager\Exception\Registry\UnknownTaskKeyException;
use Torr\TaskManager\Manager\TaskManager;
use Torr\TaskManager\Registry\TaskRegistry;
Expand All @@ -23,6 +24,7 @@ public function __construct (
private readonly TaskRegistry $taskRegistry,
private readonly TaskManager $taskManager,
private readonly TransportsHelper $receiverHelper,
private readonly HostingEnvironment $hostingEnvironment,
)
{
parent::__construct();
Expand Down Expand Up @@ -53,7 +55,7 @@ protected function execute (InputInterface $input, OutputInterface $output) : in

try
{
$tasksToQueue = $this->getTasksToQueue($input, $io);
[$tasksToQueue, $taskPassedExplicitly] = $this->getTasksToQueue($input, $io);
}
catch (UnknownTaskKeyException $exception)
{
Expand All @@ -79,13 +81,24 @@ protected function execute (InputInterface $input, OutputInterface $output) : in

$io->success("All done.");

if ($this->hostingEnvironment->isDevelopment() && !$taskPassedExplicitly && 1 === \count($tasksToQueue))
{
$io->newLine(2);
$io->comment("If you want to easily requeue this task, you can use the direct command:");
$io->writeln(\sprintf(
"bin/console task-manager:queue %s",
$tasksToQueue[0]->getMetaData()->getKey(),
));
$io->newLine();
}

return self::SUCCESS;
}

/**
* Handles the interaction to get the tasks to queue
*
* @return Task[]
* @return array{0: Task[], 1: bool} the tasks to queue and whether they were passed explicitly
*/
private function getTasksToQueue (InputInterface $input, TorrStyle $io) : array
{
Expand All @@ -94,7 +107,10 @@ private function getTasksToQueue (InputInterface $input, TorrStyle $io) : array

if ([] !== $taskKeysProvidedInArgument)
{
return $this->fetchTasksByKey($taskKeysProvidedInArgument);
return [
$this->fetchTasksByKey($taskKeysProvidedInArgument),
true,
];
}

$flatTasks = [];
Expand Down Expand Up @@ -126,7 +142,7 @@ private function getTasksToQueue (InputInterface $input, TorrStyle $io) : array
$result[] = $flatTasks[$index];
}

return $result;
return [$result, false];
}

/**
Expand Down
Loading