DunglasActionBundle
DunglasActionBundle copied to clipboard
Problem with updating of symfony
Hi there, I don't know, maybe this is not a problem of DunglasActionBundle. When I try to update symfony to 3.3.* I get next errors:
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:
Fatal error: Uncaught Symfony\Component\DependencyInjection\Exception\AutowiringFailedException: Cannot autowire service "ApiBundle\Controller\TermsController": argument "$terms" o
f method "__construct()" references class "ModelBundle\Builders\Terms" but no such service exists. It cannot be auto-registered because it is from a different root namespace. in /symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php on line 291
Symfony\Component\DependencyInjection\Exception\AutowiringFailedException: Cannot autowire service "ApiBundle\Controller\TermsController": argument "$terms" of method "__construct(
)" references class "ModelBundle\Builders\Terms" but no such service exists. It cannot be auto-registered because it is from a different root namespace. in /symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php on line 291
Call Stack:
1.0250 21820256 1. Symfony\Component\Debug\ErrorHandler->handleException() /symfony/symfony/src/Symfony/Component/Debug/ErrorHandler.p
hp:0
PHP Fatal error: Uncaught Symfony\Component\DependencyInjection\Exception\AutowiringFailedException: Cannot autowire service "ApiBundle\Controller\TermsController": argument "$ter
ms" of method "__construct()" references class "ModelBundle\Builders\Terms" but no such service exists. It cannot be auto-registered because it is from a different root namespace.
in /symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php:291
Stack trace:
#0 /symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php(223): Symfony\Component\DependencyInjection\Compiler\A
utowirePass->autowireMethod(Object(ReflectionMethod), Array)
#1 /vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php(146): Symfony\Component\DependencyInjection\Compiler\A
utowirePass->autowireCalls(Object(ReflectionClass), Array, Array)
#2 //symfony/sy in //symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php o
n line 29
I'm using a "dunglas/action-bundle": "^0.4.1"
You don't need this bundle anymore with sf 3.3. because all features from this bundle are supported natively
@mvrhov unfortunately no. It seems that Sf3.3 does not inject services to constructors, whereas this bundle does.
Sf3.3 is fully autowireable
@felicitus You need to enable it, but SF 3.3, 3.4 and 4.0 are fully autowireable
@Simperfit I have done so, also the defaults are set to enable autowire. I did a test with the official api platform demo, see here: https://github.com/partkeepr/demo/tree/sf33
I added a special action, and when trying to call the action, no arguments are passed. It may be a documentation problem, and I'm happy to document it once I got it working, but right now, I can't see why it doesn't work.
@felicitus check this out: https://github.com/api-platform/demo/pull/15
@dunglas oh I see, what I was missing is this fragment in services.yml:
AppBundle\Action\:
resource: '../../src/AppBundle/Action'
public: true
tags: ['controller.service_arguments']
I will prepare a documentation PR. I'm not the original author of this issue, but I believe the issue could be closed
I've also updated the demo app so hopefully this helps somebody:
https://github.com/partkeepr/demo/tree/sf33
@felicitus would you mind opening a PR with the update?