Compatibility issue symfony < 3.3
Closed this issue · 6 comments
Hi @bpolaszek
I work with OroCRM application which use symfony 2.8 and doctrine 2.5.5.
For compatibility issue I have to change one line in DependencyInjection/Configuration.php
->arrayPrototype()
replaced by
->prototype('array')
And when I implement UserSubscription entity I use json_array doctrine type, it is deprecated since doctrine 2.6
/**
* @var array
*
* @ORM\Column(type="json_array")
*/
private $subscription;
The last problem is that it seems that the controller SubscriptionAction cannot be instantiated because I need https://github.com/dunglas/DunglasActionBundle for compatibility.
Type error: Too few arguments to function BenTools\WebPushBundle\Action\SubscriptionAction::__construct(), 0 passed in /home/sinabs/sites/dev.orocrm.sinabs.fr/app/cache/dev/classes.php on line 2604 and exactly 2 expected
The bundle load the following directories :
->arrayNode('directories')
->info('List of directories relative to the kernel root directory containing classes.')
->prototype('scalar')->end()
->defaultValue([
'../src/*Bundle/Action',
'../src/*Bundle/Command',
'../src/*Bundle/Controller',
'../src/*Bundle/EventSubscriber',
'../src/*Bundle/Twig',
])
->end()
So I try to add custom configuration in config.yml
dunglas_action:
directories:
- %kernel.root_dir%/../vendor/bentools/webpush-bundle/src/Action
But now when I clear cache I have the following error which i don't know how to solve
[Symfony\Component\DependencyInjection\Exception\RuntimeException]
Unable to autowire argument of type "Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface" for the service "bentools\webpushbundle\action\sub
scriptionaction". Multiple services exist for this interface (security.context, security.token_storage, oro_security.token_accessor).
Do you know how to solve this error ?
Hello @AdriwanKenoby,
I'll try to add tests with multiple versions of SF as soon as possible.
Theorically you should not require dunglas/action-bundle - the controller is defined in services.xml
and it should work without it.
Maybe on my setup the autowiring overrides this, I have to check this out.
For Doctrine, change json_array
to json
.
Ben
I've figured out that the controller service must be public or it will not work on SF 2.8. I'll fix this.
Can you please try composer require bentools/webpush-bundle dev-master#21dfd15a9ecf29dbc8b57247872a137a39d3ee89
? I've done a fix that should work with your configuration.
I had remove dunglas/action bundle and test composer require bentools/webpush-bundle dev-fix-2 and it works great.
Thanks a lot for your work @bpolaszek and your help.
In order to work in all cases I have to change line 70 in WebPushManagerRegistry.php
if (is_object($userClass)) {
$userClass = get_class($userClass)
}
by
if (is_object($userClass)) {
$em = $this->container->get('doctrine')->getEntityManager();
$userClass = $em->getMetadataFactory()->getMetadataFor(get_class($userClass))->getName();
}
I will make a PR.
Actually this method accepts either a class name (string) or an object. The lines just before make sure this class or object implements UserInterface
, it retrieves the corresponding manager.
Because of this, at line 70 $userClass
is necessarily a class name implementing Symfony's UserInterface
, which may, or may not, be managed by Doctrine (you can manage your users with an API, for instance.