Skip to content

Commit

Permalink
[Scheduler] Add example about how to pass arguments to a Symfony command
Browse files Browse the repository at this point in the history
  • Loading branch information
W0rma committed Oct 1, 2024
1 parent 7b081aa commit fc90d83
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions scheduler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fc90d83

Please sign in to comment.