dunglas / DunglasActionBundle

Symfony controllers, redesigned
https://dunglas.fr/2016/01/dunglasactionbundle-symfony-controllers-redesigned/
MIT License
256 stars 14 forks source link

Problem with updating of symfony #80

Open SmirnovW opened 7 years ago

SmirnovW commented 7 years ago

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"

mvrhov commented 7 years ago

You don't need this bundle anymore with sf 3.3. because all features from this bundle are supported natively

Drachenkaetzchen commented 7 years ago

@mvrhov unfortunately no. It seems that Sf3.3 does not inject services to constructors, whereas this bundle does.

mvrhov commented 7 years ago

Sf3.3 is fully autowireable

Simperfit commented 7 years ago

@felicitus You need to enable it, but SF 3.3, 3.4 and 4.0 are fully autowireable

Drachenkaetzchen commented 7 years ago

@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.

dunglas commented 7 years ago

@felicitus check this out: https://github.com/api-platform/demo/pull/15

Drachenkaetzchen commented 7 years ago

@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

Drachenkaetzchen commented 7 years ago

I've also updated the demo app so hopefully this helps somebody:

https://github.com/partkeepr/demo/tree/sf33

dunglas commented 7 years ago

@felicitus would you mind opening a PR with the update?