symfony/symfony — pull request #11955 by nicoschoenmaker (2014-09-19 14:25:46+00:00)
Title: [Console] Added the CommandInterface and the CommandDecorator.

For a project I needed to make sure multiple commands can run only once. There was some code duplication between the commands, which I didn't like. I though it was a nice idea to create a ```@RunOnce``` annotation. When I tried to implement this, I found that it's a bit hard to [decorate](http://symfony.com/doc/current/components/dependency_injection/advanced.html#decorating-services) a command that is created as a [service](http://symfony.com/doc/current/cookbook/console/console_command.html#register-commands-in-the-service-container).

This pull request makes this a lot easier. Should this be accepted I'd only have to subclass the ```CommandDecorator``` and override the ```run``` method with this behaviour.

Solution: Created a ```CommandInterface``` implemented by ```Command``` and ```CommandDecorator```.

I could also imagine a decorator that logs when a command was started and ended. Or one that changes a duplicate name, or..

| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR | None yet