首先,我已经看到了这个问题。
当我尝试将 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.
Run Code Online (Sandbox Code Playgroud)
src/MyBundle/Resources/services.yml:服务:
Symfony\Bundle\AsseticBundle\AsseticBundle:
公众:真实
config/security.yml:安全:
访问控制:
连接:默认
谢谢你的帮助
正如您从评论中已经知道的那样,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);
}
}
Run Code Online (Sandbox Code Playgroud)
并将其添加到您的包中,如官方文档中所述。
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());
}
}
Run Code Online (Sandbox Code Playgroud)
请参阅定义 API文档。
| 归档时间: |
|
| 查看次数: |
1199 次 |
| 最近记录: |