gpt4 book ai didi

symfony - SonataAdminBundle 中不存在函数 "is_granted"

转载 作者:行者123 更新时间:2023-12-02 16:46:43 27 4
gpt4 key购买 nike

安装后Symfony2 cmf ,当我尝试查看管理/仪表板时,出现以下错误:

The function "is_granted" does not exist in SonataAdminBundle :: standard_layout.html.twig at line 95

最佳答案

我也为此苦苦挣扎了很多时间。修复方法如下:

将 SecurityBundle 添加到 app/AppKernel.php

public function registerBundles()
{
$bundles = array(
// ...

// support for the admin
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
);
// ...
}

app/config 文件夹中创建一个 security.yml,例如与此演示内容:

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 }

这对我有用。

关于symfony - SonataAdminBundle 中不存在函数 "is_granted",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15299919/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com