Skip to content

Commit

Permalink
[TASK] Use attribute in commands (#237)
Browse files Browse the repository at this point in the history
The CreateWizardCommand can't be adjusted to use the attribute as it is set to `schedulable: false` (which is not possible with the Symfony attribute).

Additionally, the DoSomethingCommand is defined as final.

Releases: main
  • Loading branch information
brotkrueml authored Mar 6, 2024
1 parent 52e31e6 commit e45bd0e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
- Use Configuration/user.tsconfig (#214)
- Add return type to `ModuleController->initializeAction()` (#233)
- Use PHP attribute for tagging event listener (#236)
- Use PHP attribute for tagging commands where applicable (#237)

### Fixed
- Dynamic properties in ModuleController (#221)
Expand Down
7 changes: 6 additions & 1 deletion Classes/Command/DoSomethingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@

namespace T3docs\Examples\Command;

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class DoSomethingCommand extends Command
#[AsCommand(
name: 'examples:dosomething',
description: 'A command that does nothing and always succeeds.',
)]
final class DoSomethingCommand extends Command
{
protected function configure(): void
{
Expand Down
5 changes: 5 additions & 0 deletions Classes/Command/MeowInformationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@
namespace T3docs\Examples\Command;

use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use T3docs\Examples\Http\MeowInformationRequester;

#[AsCommand(
name: 'examples:meow',
description: 'Meow Information',
)]
final class MeowInformationCommand extends Command
{
public function __construct(
Expand Down
12 changes: 0 additions & 12 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ services:
tags:
- name: linkvalidator.linktype

T3docs\Examples\Command\DoSomethingCommand:
tags:
- name: console.command
command: 'examples:dosomething'
description: 'A command that does nothing and always succeeds.'

T3docs\Examples\Command\CreateWizardCommand:
tags:
- name: console.command
Expand All @@ -26,12 +20,6 @@ services:
hidden: true
schedulable: false

T3docs\Examples\Command\MeowInformationCommand:
tags:
- name: 'console.command'
command: 'examples:meow'
description: 'Meow Information'

T3docs\Examples\Controller\Haiku\DetailController:
public: true

Expand Down

0 comments on commit e45bd0e

Please sign in to comment.