From fc90d8335327ab9f3a4989e6a16349c794a500a2 Mon Sep 17 00:00:00 2001 From: W0rma Date: Tue, 1 Oct 2024 08:07:25 +0200 Subject: [PATCH] [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