Closed js-aw closed 1 year ago
Quick fix, add this to your services.yaml:
OutputDataConfigToolkitBundle\Controller\ClassController:
calls:
- [setContainer, ['@service_container']]
OutputDataConfigToolkitBundle\Controller\AdminController:
calls:
- [setContainer, ['@service_container' ]]
Nevermind, this creates other problems, better use this:
<?php
namespace AppBundle\DependencyInjection\CompilerPass;
use OutputDataConfigToolkitBundle\Controller\AdminController;
use OutputDataConfigToolkitBundle\Controller\ClassController;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
class OutputDataConfigToolkitFixPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
$classDefinition = $container->getDefinition(ClassController::class);
$classDefinition->addMethodCall('setContainer', [new Reference('service_container')]);
$adminDefinition = $container->getDefinition(AdminController::class);
$adminDefinition->addMethodCall('setContainer', [new Reference('service_container')]);
}
}
and add it in your AppBundle 'build' method:
$container->addCompilerPass(new OutputDataConfigToolkitFixPass());
great, i had helped myself in the meantime with a fork. but your suggestion is better, works thx.
we also check if this is fixed on v5.0
we also check if this is fixed on v5.0
On 5.0 it works because it's injected in the constructor
In 4.1.11 could be just calling the setter injection in the parent do? https://github.com/pimcore/output-data-config-toolkit/blob/5fb1ed4aa0cf2999cdc46caa4bb49b5ca4d83fde/src/Controller/AdminController.php#L36 https://github.com/pimcore/pimcore/blob/8a435ad49a1b40e4a7ab0a7603b6557a4fe520a0/bundles/AdminBundle/Controller/AdminController.php#L57-L61
Fixed by #103
Expected behavior
open the output config tab on an dataobject in pimcore backend then choose output channel
Actual behavior
opening the output config tab produces the following error with pimcore 10.6 and OutputDataConfigToolkitBundle 4.1.11:
Service "translator" not found: even though it exists in the app's container, the container inside "OutputDataConfigToolkitBundle\Controller\AdminController" is a smaller service locator that only knows about the "Pimcore\Security\User\TokenStorageUserResolver", "doctrine", "form.factory", "http_kernel", "message_bus", "messenger.default_bus", "parameter_bag", "pimcore.templating", "pimcore_admin.serializer", "request_stack", "router", "security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "serializer", "session" and "twig" services. Try using dependency injection instead.
solution: change $translator = $this->get('translator'); to $translator = $this->translator; in output-data-config-toolkit-bundle/src/Controller/AdminController.php
Steps to reproduce
open the output config tab on an dataobject in pimcore backend. pimcore 10.6.x OutputDataConfigToolkitBundle: 4.1.11