- Issue created by @longwave
Discovered in 🐛 Error on publish-all API Needs work , controller autowiring fails in some cases. You can autowire controllers as services:
routing.yml:
experience_builder.api.publish_all:
path: '/xb/api/publish-all'
defaults:
_controller: '\Drupal\experience_builder\Controller\ApiPublishAllController'
services.yml:
Drupal\experience_builder\Controller\ApiPublishAllController: {}
However the leading backslash in the controller definition results in an autowiring failure:
ArgumentCountError: Too few arguments to function Drupal\experience_builder\Controller\ApiPublishAllController::__construct(), 0 passed in xb-dev/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php on line 39 and exactly 4 expected
Trim the leading backslash from the controller definition either when setting up routing, or in ControllerResolver, or perhaps in ClassResolver.
Decide where the fix should lie. ClassResolver would cover more cases, but is it safe to always trim leading backslashes?
Active
11.0 🔥
routing system