5

After installing Symfony2 cmf, when I tried to view the admin / dashboard I have the following error:

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

2 Answers 2

10

I struggled with that quite a lot of time, too. Here's how to fix it:

Add the SecurityBundle to app/AppKernel.php

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

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

Create a security.yml in your app/config folder, e.g. with this demo content:

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 }

and load it it your app/config/config.yml:

imports:
    - { resource: security.yml }

That worked for me.

0
-2

Just as a feedback to whoever else might face this issue :

acme's solution works. Apparently, users MUST be provided as described in

http://symfony.com/doc/master/cmf/tutorials/creating-cms-using-cmf-and-sonata.html

2
  • 2
    This should just have been an up vote for Acme's answer possibly with a comment. your post is not a new answer
    – Anigel
    May 16, 2013 at 11:18
  • 1
    I am really sorry, but I could neither update (due to th elack of reputation) nor could I comment.
    – Jan
    May 17, 2013 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.