安装Symfony2 cmf后,当我尝试查看管理员/信息中心时出现以下错误:
第95行的SonataAdminBundle :: standard_layout.html.twig中不存在“is_granted”函数
答案 0 :(得分:10)
我也花了很多时间挣扎。以下是修复方法:
将SecurityBundle添加到app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
// support for the admin
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
);
// ...
}
在security.yml
文件夹中创建app/config
,例如有了这个演示内容:
security:
encoders:
Symfony\Component\Security\Core\User\User: plaintext
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
providers:
in_memory:
memory:
users:
user: { password: userpass, roles: [ 'ROLE_USER' ] }
admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/
anonymous: ~
http_basic:
realm: "Secured Demo Area"
access_control:
#- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
#- { path: ^/_internal/secure, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 }
并将其加载到app/config/config.yml
:
imports:
- { resource: security.yml }
这对我有用。
答案 1 :(得分:-2)
正如对其他人可能面临此问题的反馈一样:
极致的解决方案有效。显然,用户必须按照
中的描述提供http://symfony.com/doc/master/cmf/tutorials/creating-cms-using-cmf-and-sonata.html