Skip to content

Commit

Permalink
In case of LazyCommands, we instantiate it to read annotations on the…
Browse files Browse the repository at this point in the history
… right class (mybuilder#39)
  • Loading branch information
ericabouaf committed Jul 8, 2021
1 parent b384882 commit f915076
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Exporter/AnnotationCronExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use MyBuilder\Bundle\CronosBundle\Annotation\Cron as CronAnnotation;
use MyBuilder\Cronos\Formatter\Cron as CronFormatter;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Command\LazyCommand;

class AnnotationCronExporter
{
Expand Down Expand Up @@ -55,6 +56,11 @@ private function createCronConfiguration(): CronFormatter

private function parseAnnotations(CronFormatter $cron, Command $command, array $options): CronFormatter
{
// Since 5.3, the Symfony Application returns LazyCommand when it can instead of instantiating them
if (class_exists(LazyCommand::class) && $command instanceof LazyCommand) {
$command = $command->getCommand();
}

foreach ($this->getAnnotations($command) as $annotation) {
if ($this->annotationBelongsToServer($annotation, $options['serverName'])) {
$cron = $this->addLine($command, $annotation, $options, $cron);
Expand Down

0 comments on commit f915076

Please sign in to comment.