Search code examples
symfonyaclsylius

Sylius/rbac-bundle for existing Symfony2 application


I have to implement sylius/rbac-bundle for ACL in existing Symfony2 application. I have seen I suppose everything that can be googled out about the topic, but nowhere to see an example.

How can I do that? I have User entity. What do I do with it now by using this new bundle?

I installed sylius/rbac-bundle with all required dependencies.

"sylius/resource": "0.14.*@dev",
"sylius/translation": "0.14.*@dev",
"sylius/translation-bundle": "0.14.*@dev",
"sylius/storage": "0.14.*@dev",
"sylius/resource-bundle": "0.14.*@dev",
"sylius/rbac": "0.14.*@dev",
"sylius/rbac-bundle": "0.14.*@dev"

and added this to AppKernel:

new Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),
new Sylius\Bundle\TranslationBundle\SyliusTranslationBundle(),
new Sylius\Bundle\ResourceBundle\SyliusResourceBundle(),
new Sylius\Bundle\RbacBundle\SyliusRbacBundle(),

I see there is a console command:

sylius:rbac:initialize

but now the php app/console results in following error:

[Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]
The service "sylius.translatable.listener" has a dependency on a non-existent parameter "sylius.translation.mapping". 
Did you mean one of these: "sylius.translation.default.mapping", "sylius_translation.driver"? 

Any ideas on what might be wrong?


Solution

  • You'll need to also configure Sylius TranslationBundle

    sylius_translation:
        default_mapping:
            translatable:
                field: translations
                currentLocale: currentLocale
                fallbackLocale: fallbackLocale
            translation:
                field: translatable
                locale: locale