Feature: #107151 - Add AsNonSchedulableCommand attribute for CLI commands
See forge#107151
Description
With forge#101567 the usage of Symfony's # attribute
has been introduced, which allows configuring a Symfony CLI command
with a corresponding name, description and further options.
It however lacked TYPO3's custom implementation of the schedulable
option, which allows flagging a CLI command to be not allowed to be
scheduled via the Administration > Scheduler backend module.
Note
The top-level backend modules were renamed in TYPO3 v14. The module now called Administration was formerly named System, and the module now called System was formerly named Admin Tools.
For details, see: Feature: #107628 – Improved backend module naming and structure.
This previously required tagging such a command with the
schedulable: false tag attribute in the Services. or
Services. definition.
For this, the PHP attribute
As has been
introduced. Any Symfony Command can use this empty attribute. The automatic
Scheduler registry will ignore any command with this tag.
By default, a Symfony Command remains schedulable using the regular Symfony
attribute. To prevent redundancy, the new attribute
# should be used only on top of that.
Another advantage is that an IDE like PhpStorm is capable of showing all usages of that attribute inside a project.
Impact
Developers can now fully embrace using the Symfony
#
attribute and still be able to declare a non-schedulable execution within
the scope of the same class, without any service registration.
This is achieved by using the
# in addition
to the
# attribute.
Example
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use TYPO3\CMS\Core\Attribute\AsNonSchedulableCommand;
#[AsCommand('myextension:import', 'Import data from external source')]
#[AsNonSchedulableCommand]
final class ImportCommand extends Command
{
// ...
}