Add suppor for symfony's 3.3 service locator#73
Add suppor for symfony's 3.3 service locator#73mvrhov wants to merge 2 commits intopomm-project:masterfrom
Conversation
|
Failures are not because of my PR. |
|
@sanpii This one is continuation of a previous one. It would be nice to have it 2.3 |
Sorry, the 2.3 is already in release candidate phase, it’s not possible to add new feature at this point. |
|
Is it possible to add it to the 2.4 milestone then? |
Yes, of course, except if there is a BC break. |
|
This is a bit unfortunate. As SF 3.3 will be out at the end of the month and using this bundle with 3.3 will immediately result in a deprecation warnings |
It’s a good excuse to make a new release quickly 😄 |
7868690 to
edf7678
Compare
Which one ? I updated to SF 3.3 and I didn't have deprecation warning from PommBundle. |
|
Only if you use the autowiring. |
|
Right, the |
| @@ -10,8 +10,8 @@ | |||
| namespace PommProject\PommBundle\Model; | |||
There was a problem hiding this comment.
I don’t undestand the goal of changes in this file. The ContainerAwareTrait already requires a ContainerInterface.
There was a problem hiding this comment.
ContainerAware is not compatible with PSR container. And service locator in Sf3.3 returns PSR container interface, Previous sf version their own.
| @@ -11,8 +11,8 @@ | |||
|
|
|||
There was a problem hiding this comment.
I don’t undestand the goal of changes in this file. The ContainerAwareTrait already requires a ContainerInterface.
| $definitions = []; | ||
|
|
||
| $poolerToService = []; | ||
| $gteSf33 = class_exists('Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass'); |
| ->setAutowiringTypes([$old->getClass()]) //set this one as a default for autowire | ||
| ; | ||
|
|
||
| if ($gteSf33) { |
There was a problem hiding this comment.
I think it’s a good idea to split this method into two functions to reduce complexity and length of this one.
There was a problem hiding this comment.
IMO there is no need.
| use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
| use Symfony\Component\DependencyInjection\ContainerAwareTrait; | ||
| use Symfony\Component\DependencyInjection\ContainerInterface; | ||
| use Psr\Container\ContainerInterface as PsrContainer; |
There was a problem hiding this comment.
you should rename it in PsrContainerInterface to do like in symfony code.
| /** | ||
| * @param PsrContainer|ContainerInterface $container | ||
| */ | ||
| public function setContainer($container) |
There was a problem hiding this comment.
You can type hint with the PsrContainerInterface, The ContainerInterface extends it so you can inject both without the if block below
There was a problem hiding this comment.
No I cannot. Because we need to be compatible with sf < 3.3
There was a problem hiding this comment.
indeed, I didn't thought about that... sorry
edf7678 to
9995cc2
Compare
|
@sanpii Can we get this merged into the master please. It's annoying to use a local fork. |
|
So in two months time the sf 4.0 will be released and this PR is till not merged. |
|
I don’t understand the complexity of this PR. For me, it should be something like this: if (version_compare(\Symfony\Component\HttpKernel\Kernel::VERSION, '3.3', '>=')) {
$container->setAlias($class, $id);
} else {
$new->addAutowiringType($class);
} |
|
@sanpii Isn't running this on each loop a little bit expensive? I know that this is run once but still. |
Yes, it’s probably a good idea. |
9995cc2 to
e1f308d
Compare
|
Done |
|
@sanpii ping. This is slowly getting annoying. I have this open for 8 moths. And it's still not merged. This bundle could have been sf4 compatible 8 moths ago. |
f37f096 to
57b6999
Compare
57b6999 to
45f9b1a
Compare
|
@sanpii This one is rebased now and should be a part of 2.4 |
|
Tests seem to pass except phpcs is complaining about something but it doesn't tell about what. |
|
@mvrhov for phpcs : |
45f9b1a to
5ccad45
Compare
|
Fixed. Thanks |
This adapts model and model layer poolers to the symfony 3.3 and their service locator, and a new way to define the service to be autowireable. It also gets rid of the deprecation notices.