Is it possible to have two Sonata Admin Panel Bundles in one Symfony application? How can I achieve this?
As KondukterCRO mentioned, it is possible to have only one Sonata Admin installation per Symfony project.
However, if you need, you can have:
Two dashboards, for example have one native dashboard and for second dashboard - make a custom action + template
Two sets of entities with different access rights. Alhthough all Sonata Admin pages will have one comon prefix - you still can separate access rights to Sonata Admin pages with simple rules in security.yml >> access_control section, or more complex rules - in every admin class, in method ::isGranted()
Related
I am doing a back office under symfony and easy admin bundle and FOSUserBundle. I would like to know if it was possible when the admin connects in his space, he sees only the normal users, which do not have the role admin only.
or separate administrators from normal users.
I ask the question because using Sonata I know it's possible, but since I have to do it under easyadmin I do not know if it's feasible.
I have been trying to do this for a while now and I would like to know if it was possible.
Merci d'avance :)
In easy admin bundle you can filter entities with a DQL FILTER see the documentation here
You can use this for dislplaying only normal users.
you can try this filter:
dql_filter: "entity.roles NOT LIKE '%%env(ROLE_ADMIN)%%'"
as you seem to be French-speaking, here is a very interesting article about easyadminbundle
is it possible to get multiple Admin Dashboards within one project?
Like:
/admin/ got all stuff my admin can do
/user/ got only user stuff
/mod/ part for my moderator
Actually i only have /admin/ with full administration dashboard.
I don't want to use Roles for this - i really wand to have another url for each section
I used sonataadmin and really like some features, like creating an entity and its related entity in the same page. I want to use it for frontend user also. Is it possable to use sonamaadmin for both backend and frontend users? Or is there another bundle allowing me to create an entity and its related entity in the same page?
Those are just form types, provided by the SonataAdminBundle. You can use them in any form.
You probably looking for the sonata_type_model or sonata_type_collection. See the documentation for more information.
Of course you can use Sonata Admin in both, although will be like only having a backend and made the correct security configuration for two kind of users. About entity and its related entities in the same page, that has nothing to do with Sonata, this can be achieved with symfony simple and embed forms.
i'm little confused..
I'm using sonata admin bundle in my project and i'd like to install user management for this, tell me please do i really have to install sonata user bundle? (i was using this tutorial http://domitable.com/content/getting-started-symfony-23-sonata-admin-user-bundles ) or only fos user bundle will be enought? i'm asking this becouse i want to install as little dependiendes as possible.
honestly the best way for me would be to use only my custom user bundle with custom user entity..(if need be only my class + FOS)
Do i have to use easy-extends to generate my user entity class or default doctrine generate entity is okay?
What about sonata ACL in this sitaution?
what is the best way to resolve this issue?
I'll try my best with what I have. Basically, SonataUserBundle is only useful if you want to manage the users via SonataAdmin.
FosUserBundle is simply a bundle that manages users and some actions such as login, but from the point of view of a user. That is, it does not have the tools built in for an admin to manage users.
Therefore, to manage the users, you need SonataAdmin and SonataUser.
If you easy extends SonataUser, then you could transfer your custom entity in the extended bundle. That is a way you could do it.
ACL is a complete different thing, read here for more information:http://symfony.com/fr/doc/current/cookbook/security/acl.html
I have Sonata Admin set up with ACLs. I have different users, groups and permissions which work fine. To achieve this, i followed the Sonata Admin documentation on ACLs.
So here is my question: What is a clean way to ensure that backend (admin) users can only view, edit and delete the entities they created with Symfony's and Sonata Admin's built-in ACL mechanisms? Sonata Admin automatically stores the owner (creator) of the object once it is persisted in the ACL tables (from the Sonata docs):
Owner:
when an object is created, the currently logged in user is set as owner for
that object and is granted all access for that object;
The same question has already been answered on Stackoverflow, but the answer does not explain in detail how to solve it with ACLs.
There is a new Symfony bundle doing just that: https://github.com/coopTilleuls/CoopTilleulsAclSonataAdminExtensionBundle
All you need to do is enable ACL in Sonata Admin, install the bundle and activate it. Pretty easy and effective, I use it in my Symfony2 project with Sonata Admin 2.2.
I saw 2 ways to do that:
Create a custom AclVoter
Override your Admin Class' CreateQuery()
I was not able to do any of these for doing the very simple thing that I needed, but I think this is the idea.
Actually this is one of many Symfony things on which I spent many hours and thousands lines of code without big success... Such simple needs should not be as much pain in the arse...
Don't grant the EDIT permission to the users. They can edit the instances they own but not others' instances.
I use this configuration:
#app/config/config.yml
sonata_admin:
security:
information:
STAFF: [VIEW, LIST, CREATE]
EDITOR: [OPERATOR, EXPORT]
ADMIN: [MASTER]
Documentation