-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] default admin #3908
Comments
What about check each admin for a boolean $isMainAdmin and then have the default value for admin_code to go with the first admin that it finds and has $isMainAdmin true, when there are multiple admins for an Entity? |
I must say I thought about it, but discarded the idea: although it seems more simple, I can see two issues. First, the |
ping @sonata-project/contributors |
ping @sonata-project/contributors , what do you think about this issue? |
Sounds like a good idea 👍 |
Cool, but I'm still torn on this issue: Either this : # config.yml
sonata_admin:
default_admin:
My\Entity: my_entity_main_admin_id Or something like @clytemnestra suggested, but with null instead of a useless boolean : # admin.yml
services:
my_entity_main_admin_id:
tags:
-
is_main: ~ # If I go with this implementation, I must gather tags and check for uniqueness, so more complicated Can I have your view on this in particular? |
Maybe we can use existing key: # config.yml
sonata_admin:
admin_services:
id.of.admin.service:
entities:
Foo\Entity\Bar
|
Definitely going to do that, I had forgotten about this key! |
… not. This key is meant to configure services that will be injected in all admin services. |
What's the solve for this? |
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Given an entity (or document ?) for which several admin are defined, when you try to reference an object of this type, sonata will not be able to choose and will prompt the user for an
admin_code
options in most cases.Being forced to give this option can get tedious, and can also cause regressions : for instance, if you define and admin, develop a lot of things around it, and then define another admin for the same class, you have to carefully check your application for this error and fix it.
I think this problem could be resolved by injecting where needed a service that would be able to make the right choice when asked for the admin to use for a given class.
The interface to implement would be the following :
I think a good implementation would gather the possible admin services, and discard services that are children admin, and if this does not reduces the number of possible admin to exactly one, then use a mapping model => defaultAdmin .
Whether to give this job to
AdminPool
or create a new class just for this is to be discussed, it turns out it is the class that throws the exception aboutadmin_code
: https://github.com/sonata-project/SonataAdminBundle/blob/3.x/Admin/Pool.php#L186The text was updated successfully, but these errors were encountered: