From fc90d8335327ab9f3a4989e6a16349c794a500a2 Mon Sep 17 00:00:00 2001 From: W0rma Date: Tue, 1 Oct 2024 08:07:25 +0200 Subject: [PATCH 1/2] [Scheduler] Add example about how to pass arguments to a Symfony command --- scheduler.rst | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/scheduler.rst b/scheduler.rst index 160ba26e0cb..a77d2239259 100644 --- a/scheduler.rst +++ b/scheduler.rst @@ -473,6 +473,20 @@ The attribute takes more parameters to customize the trigger:: // defines the timezone to use #[AsCronTask('0 0 * * *', timezone: 'Africa/Malabo')] +Arguments/options for Symfony commands are passed as plain string:: + + use Symfony\Component\Console\Command\Command; + + #[AsCronTask('0 0 * * *', arguments: 'arg --my-option')] + class MyCommand extends Command + { + protected function configure(): void + { + $this->addArgument('my-arg'); + $this->addOption('my-option'); + } + } + .. versionadded:: 6.4 The :class:`Symfony\\Component\\Scheduler\\Attribute\\AsCronTask` attribute @@ -522,6 +536,20 @@ The ``#[AsPeriodicTask]`` attribute takes many parameters to customize the trigg } } +Arguments/options for Symfony commands are passed as plain string:: + + use Symfony\Component\Console\Command\Command; + + #[AsPeriodicTask(frequency: '1 day', arguments: 'arg --my-option')] + class MyCommand extends Command + { + protected function configure(): void + { + $this->addArgument('my-arg'); + $this->addOption('my-option'); + } + } + .. versionadded:: 6.4 The :class:`Symfony\\Component\\Scheduler\\Attribute\\AsPeriodicTask` attribute From 35df8ae759bf455557cb9f9b530c02231cc8ced1 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 22 Jan 2025 09:23:07 +0100 Subject: [PATCH 2/2] Reword --- scheduler.rst | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/scheduler.rst b/scheduler.rst index 6cebb354137..5bac82d98ae 100644 --- a/scheduler.rst +++ b/scheduler.rst @@ -473,19 +473,10 @@ The attribute takes more parameters to customize the trigger:: // defines the timezone to use #[AsCronTask('0 0 * * *', timezone: 'Africa/Malabo')] -Arguments/options for Symfony commands are passed as plain string:: - - use Symfony\Component\Console\Command\Command; - - #[AsCronTask('0 0 * * *', arguments: 'arg --my-option')] + // when applying this attribute to a Symfony console command, you can pass + // arguments and options to the command using the 'arguments' option: + #[AsCronTask('0 0 * * *', arguments: 'some_argument --some-option --another-option=some_value')] class MyCommand extends Command - { - protected function configure(): void - { - $this->addArgument('my-arg'); - $this->addOption('my-option'); - } - } .. versionadded:: 6.4 @@ -536,19 +527,10 @@ The ``#[AsPeriodicTask]`` attribute takes many parameters to customize the trigg } } -Arguments/options for Symfony commands are passed as plain string:: - - use Symfony\Component\Console\Command\Command; - - #[AsPeriodicTask(frequency: '1 day', arguments: 'arg --my-option')] + // when applying this attribute to a Symfony console command, you can pass + // arguments and options to the command using the 'arguments' option: + #[AsPeriodicTask(frequency: '1 day', arguments: 'some_argument --some-option --another-option=some_value')] class MyCommand extends Command - { - protected function configure(): void - { - $this->addArgument('my-arg'); - $this->addOption('my-option'); - } - } .. versionadded:: 6.4