首先,我已经看到了this question。
当我尝试将Symfony 3.3更新为3.4时,我得到了这个弃用:
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.
src/MyBundle/Resources/services.yml
:services: Symfony\Bundle\AsseticBundle\AsseticBundle: public: true
config/security.yml
:security: acl: connection: default
感谢您的帮助
答案 0 :(得分:4)
正如您在评论中所知,assetic-bundle
已被弃用,因此您无需更改其服务定义即可在Symfony 4上进行迁移。
但一般来说,如果要覆盖外部服务配置,可以实现自定义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);
}
}
并按照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());
}
}
请参阅Definition API文档。