Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symfony 5.3 LazyCommands are not parsed #39

Open
ericabouaf opened this issue Jul 8, 2021 · 2 comments · May be fixed by #53
Open

Symfony 5.3 LazyCommands are not parsed #39

ericabouaf opened this issue Jul 8, 2021 · 2 comments · May be fixed by #53

Comments

@ericabouaf
Copy link

The @Cron annotations are not parsed on LazyCommands.

Cf. https://symfony.com/blog/new-in-symfony-5-3-lazy-command-description

ericabouaf added a commit to ericabouaf/cronos-bundle that referenced this issue Jul 8, 2021
@ericabouaf
Copy link
Author

The fix above is working, but it is certainly not be the best way to fix this issue...

In https://github.com/mybuilder/cronos-bundle/blob/3.1.2/Command/CommandBase.php#L61, we use the Symfony application to fetch all commands : $commands = $this->getApplication()->all().

Since it may now return LazyCommand instead of our commands, shouldn't cronos-bundle discover itself the Commands class ?

@c33s
Copy link

c33s commented Jun 27, 2022

my workaround:

Exporter/AnnotationCronExporter.php

...
use Symfony\Component\Console\Command\LazyCommand;
...
public function export(array $commands, array $options): CronFormatter
{
	$cron = $this->createCronConfiguration();

	foreach ($commands as $command) {
		if ($command instanceof LazyCommand) {
			$command = $command->getCommand();
		}
		if ($command instanceof Command) {
			$cron = $this->parseAnnotations($cron, $command, $options);
		}
	}

	return $cron;
}
...

@garak garak linked a pull request Jan 8, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants