Mathi9121
Mathi9121

Reputation: 21

The "assetic.filter_manager" service is private [Symfony 3.4]

First, I already saw this question.

When I try to update Symfony 3.3 to 3.4, I've got this deprecations :

User Deprecated: The "assetic.filter_manager" service is private, getting  it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead.

User Deprecated: The "assetic.filter.cssrewrite" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead.

The "security.acl" configuration key is deprecated since Symfony 3.4 and will be removed in 4.0. Install symfony/acl-bundle and use the "acl" key instead.
  1. I try adding this in src/MyBundle/Resources/services.yml:
services:
    Symfony\Bundle\AsseticBundle\AsseticBundle:
        public: true
  1. I installed acl-bundle. The file config/security.yml:
security:
    acl:
        connection: default

Thanks for your help

Upvotes: 1

Views: 1753

Answers (1)

DrKey
DrKey

Reputation: 3495

As you already know from comments, assetic-bundle is deprecated and therefore you're able to migrate on Symfony 4 without changing its service definition.

But generally speaking, if you want to override an external service configuration, you can implement a custom CompilerPass

namespace AppBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class OverrideServiceCompilerPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container)
    {
        $container->getDefinition('assetic.filter_manager')->setPublic(true);
        $container->getDefinition('assetic.filter.cssrewrite')->setPublic(true);
    }
}

and add it to your bundle as stated in the official documentation.

namespace AppBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use AppBundle\DependencyInjection\Compiler\OverrideServiceCompilerPass;

class AppBundle extends Bundle
{
    public function build(ContainerBuilder $container)
    {
        parent::build($container);
        $container->addCompilerPass(new OverrideServiceCompilerPass());
    }
}

Refer to Definition API documentation.

Upvotes: 5

Related Questions