doumou1864 2015-11-07 12:22
浏览 26
已采纳

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 ;)

  • 写回答

1条回答 默认 最新

  • dongtao9158 2015-11-13 21:51
    关注

    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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图