Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"file_locator" service or alias has been removed #7

Closed
fritzmg opened this issue Apr 18, 2019 · 0 comments
Closed

"file_locator" service or alias has been removed #7

fritzmg opened this issue Apr 18, 2019 · 0 comments
Assignees

Comments

@fritzmg
Copy link

fritzmg commented Apr 18, 2019

In the constructor of the ContainerUtil you are retrieving a lot of services from the Symfony Container:

public function __construct(ContainerInterface $container)
{
$this->framework = $container->get('contao.framework');
$this->fileLocator = $container->get('file_locator');
$this->scopeMatcher = $container->get('contao.routing.scope_matcher');
$this->container = $container;
}

This will not work in the most recent Symfony versions however, since some of these services are not public. It will lead to the following error for example:

[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
    The "file_locator" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.


  Exception trace:
   () at …\c47dev\vendor\symfony\dependency-injection\Container.php:263
   Symfony\Component\DependencyInjection\Container->make() at …\c47dev\vendor\symfony\dependency-injection\Container.php:225
   Symfony\Component\DependencyInjection\Container->get() at …\c47dev\vendor\heimrichhannot\contao-utils-bundle\src\Container\ContainerUtil.php:39
   HeimrichHannot\UtilsBundle\Container\ContainerUtil->__construct() at …\c47dev\var\cache\prod\ContainerXM42E9V\getHuh_Utils_ContainerService.php:11

Instead of getting the services from the container, you need to use dependency injection.

@koertho koertho self-assigned this Apr 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants