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.
In the constructor of the
ContainerUtil
you are retrieving a lot of services from the Symfony Container:https://github.com/heimrichhannot/contao-utils-bundle/blob/153bf15f619748e9e54f139eae7681884635fb06/src/Container/ContainerUtil.php#L36-L42
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:Instead of getting the services from the container, you need to use dependency injection.