0

I'm trying to implement ACL to restric comments on FOSCommentBundle to users role. I followed step by step the Bundles Doc but shows me an error:

The definition for "acl" has no class.

Thats my app/config/config.yml

fos_comment:
db_driver: orm
class:
    model:
        comment: BackEndBundle\Entity\Comment
        thread: BackEndBundle\Entity\Thread
        vote: BackEndBundle\Entity\Vote      

acl: true
service:
    acl:
        thread:  fos_comment.acl.thread.roles
        comment: fos_comment.acl.comment.roles
        vote:    fos_comment.acl.vote.roles
    manager:
        thread:  fos_comment.manager.thread.acl
        comment: fos_comment.manager.comment.acl
        vote:    fos_comment.manager.vote.acl

acl_roles:
    comment:
        create: IS_AUTHENTICATED_ANONYMOUSLY
        view: IS_AUTHENTICATED_ANONYMOUSLY
        edit: ROLE_ADMIN
        delete: ROLE_ADMIN
    thread:
        create: IS_AUTHENTICATED_ANONYMOUSLY
        view: IS_AUTHENTICATED_ANONYMOUSLY
        edit: ROLE_ADMIN
        delete: ROLE_ADMIN
    vote:
        create: IS_AUTHENTICATED_ANONYMOUSLY
        view: IS_AUTHENTICATED_ANONYMOUSLY
        edit: ROLE_ADMIN
        delete: ROLE_ADMIN       
assetic:
  bundles: [ "FOSCommentBundle" ]

I thought that symfony3 didn't have the ACL installed so i tried to with commands but gives me the same error "The definition for "acl" has no class".

Thats my app/config/services.yml

parameters:    

services:
     acl:
      connection: default
Pillow
  • 103
  • 2
  • 9

1 Answers1

1

You don't have to add ACL configuration to app/config/services.yml. The bundle, FOSCommentBundle in this case, has its own config file for services.

Just install the bundle via Composer and add the bundle into AppKernel.php

$bundles = [
...
new FOS\CommentBundle\FOSCommentBundle(),
...

If you have done all above, just remove the acl: connection: default from app/config/services.yml and it should work. You can check if there are FOSCommentBundle services available by bin\console debug:container fos_comment.

Jan Rydrych
  • 2,188
  • 2
  • 13
  • 18
  • Thanks now don't show any error and works good. But still dn't show edit and delete buttons. I'll keep trying Thanks. – Pillow May 10 '17 at 17:02