Symfony2最佳实践可编辑文本奏鸣曲管理包

I'm working on a symfony2 project using sonata admin bundle. I have some editable text on my website like "presentation" "actually" etc...

I found a solution but it does not feel like its the good way to do.

I've created an Entity EditableText where I map a key with a content like :

key => "presentation" content => "this is my presentation"

and I do the same for all of my EditableText.

Doing it this way leads me to a list of EditableText in my sonata admin bundle which is not "user friendly" for a non tech guy. If he removes a row, the website can't find the content ... etc ...

I would like to have in sonata a field where the user can edit each texts somewhere, but cannot modify they key or delete a row or something.

I don't mind changing my conception.

If you have any tips, suggestions, ...

Thanks and sorry for my english ;)

If you want to keep your concept you can restrict access for an editor by using a role based security approach. You could grant the editor just the ROLES LIST, VIEW, EDIT as described in the security section of the SonataAdminBundle documentation. This way the admin (you) can create the entities with the needed keys for your website and the editor could view and update them.

As an example: when you have defined your admin service as sonata.admin.editable_text

you have to assign the roles

  • ROLE_SONATA_ADMIN_EDITABLE_TEXT_LIST
  • ROLE_SONATA_ADMIN_EDITABLE_TEXT_VIEW
  • and ROLE_SONATA_ADMIN_EDITABLE_TEXT_EDIT

You could than easily group these roles into one role using the role_hierarchy directive of the security configuration:

security:
# ...
role_hierarchy:

    # group the roles for your convenience, 
    ROLE_SONATA_EDITOR:
        - ROLE_SONATA_ADMIN_EDITABLE_TEXT_LIST
        - ROLE_SONATA_ADMIN_EDITABLE_TEXT_VIEW
        - ROLE_SONATA_ADMIN_EDITABLE_TEXT_EDIT