Skip to content

[FrameworkBundle] Add a framework aware base command #23632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

[FrameworkBundle] Add a framework aware base command #23632

wants to merge 1 commit into from

Conversation

ro0NL
Copy link
Contributor

@ro0NL ro0NL commented Jul 23, 2017

Q A
Branch? 3.4
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #23529
License MIT
Doc PR symfony/symfony-docs#...

Enables deprecating ContainerAwareCommand (#21623) by providing a base command that is kernel aware, thus container aware.

Core could heavily use this as of 4.0, and basically fixes IDE's on getApplication.

@chalasr
Copy link
Member

chalasr commented Jul 25, 2017

Not sure about this one. It's kind of equivalent to ContainerAwareCommand, that we don't need for deprecating it (the core is ready for that).

@ro0NL
Copy link
Contributor Author

ro0NL commented Jul 26, 2017

It's kind of equivalent to ContainerAwareCommand

Agree. We should definitively choose one, not having both.

First; i think it's ok for framework commands to rely on the framework application (getApplication()->getKernel()), it that's needed. After #23624 all framework commands rely on this. This PR creates a safeguard for that approach as currently we blindly assume this method exists.

Note kernel-aware and container-aware are semantically 2 different approaches for a command, currently we do both in the framework and ContainerAwareCommand wires both. With kernel aware you rely on the kernel container, not just any injected container (as implied by container aware).

Imo. it's good to be explicit, either be kernel aware (extend Command from this PR), or be container aware (implement ContainerAwareInterface or inject as a service yourself) but dont mix&match.

@chalasr
Copy link
Member

chalasr commented Jul 27, 2017

This PR creates a safeguard for that approach as currently we blindly assume this method exists.

Agree on the intent here, IDEs complain about it and we probably don't want to duplicate this instanceof check everywhere.
Technically there is a BC break here: currently these commands can work with any base Application subclass providing a Kernel getKernel(), so should we deprecate first?
I would remove the getContainer() shortcut also.

Last remaining concern: is it worth it at all? I think we need more opinions

Copy link
Contributor

@ogizanagi ogizanagi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least I agree about removing the getContainer method.

return parent::getApplication();
}

protected function getKernel()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing docblock for the return.

@ro0NL
Copy link
Contributor Author

ro0NL commented Jul 29, 2017

Removed getContainer()

Last remaining concern: is it worth it at all? I think we need more opinions

I see a few options;

  • this PR, update base class in 4.0 where needed
  • add safeguards (instanceof) where needed
  • favor kernel injection and dont rely on Application to be a framework application
  • dont do anything; it works by convention

@fabpot
Copy link
Member

fabpot commented Jul 29, 2017

Not worth it if you ask me.

@ro0NL
Copy link
Contributor Author

ro0NL commented Jul 31, 2017

Right. Lets leave it asis then 👍

@ro0NL ro0NL closed this Jul 31, 2017
@ro0NL ro0NL deleted the framework/base-command branch July 31, 2017 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants