Symfony2 SyliusRbacBundle设置

时间:2015-05-11 22:35:24

标签: symfony sylius

我正在探索为我的应用程序使用SyliusRbacBundle的选项。我设法将它与FosUserBundle一起安装。当我到达设置部分时,我在运行命令时遇到以下错误' sylius:rbac:initialize'按照此处的说明操作:http://docs.sylius.org/en/latest/bundles/SyliusRbacBundle/setup.html#setup-roles-and-permissions-in-the-database

Initializing Sylius RBAC roles and permissions.
Adding permission "Update product". (app.product_update)
Adding permission "Create product". (app.product_create)
Adding permission "Manage product". (app.product_manage)

  [Doctrine\DBAL\DBALException]                                                
  An exception occurred while executing 'INSERT INTO sylius_role (code, name,  
   description, security_roles, tree_left, tree_right, tree_level, created_at  
  , updated_at, parent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params  
   ["root", "Root", null, "a:0:{}", null, null, null, "2015-05-11 16:45:34",   
  "2015-05-11 16:45:34", null]:                                                
  SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'tree_left' ca  
  nnot be null

  [PDOException]                                                               
  SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'tree_left' ca  
  nnot be null                                                                 



sylius:rbac:initialize

这就是我的config.yml的样子:

sylius_rbac:
    driver: doctrine/orm
    security_roles:
            ROLE_ADMINISTRATION_ACCESS: Can access backend
    roles:
        app.admin:
            name: Administrator
            description: Administrator
        app.product_manager:
            name: Product Manager
            description: muchos productos
            permissions: [app.product_update, app.product_create]
    roles_hierarchy:
            app.admin: [app.product_manager]
    permissions:
        app.product_update: Update product
        app.product_create: Create product
        app.product_manage: Manage product
    permissions_hierarchy:
            app.product_manage: [app.product_create, app.product_update]

任何人都知道如何解决它?

谢谢!

1 个答案:

答案 0 :(得分:1)

DataSource ds; this.conn = ds.getConnection(); 使用tree behaviour中的Atlantic18/DoctrineExtensions

您可以使用stof/StofDoctrineExtensionsBundle在Symfony系统中使用它。

安装完成后,您需要在Sylius/Rbac中启用树行为,例如..

app/config/config.yml

这应该使听众正确注册,然后自动填充你的字段。