First of all, very useful module, thanks.
Problem/Motivation
For instance \Drupal\base_field_override_ui\Controller\BaseFieldOverrideController::addAccess function always gets empty string for $bundle parameter... And in some cases for me it is required to construct
Steps to reproduce
Proposed resolution
When I have time I will take a look, and try to fix this
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork base_field_override_ui-3203857
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
geek-merlinI get a WSOD as a result of this, trying to add a base field override for a commerce order item:
Comment #3
geek-merlinSome quick debugging:
- Routes are altered in \Drupal\base_field_override_ui\Routing\RouteSubscriber::alterRoutes
- The throwing access callback is \Drupal\base_field_override_ui\Controller\BaseFieldOverrideController::addAccess
Strange enough, for e.g. Node title it "works"
- /admin/structure/types/manage/example_content_type/fields/base-field-override/title/add => works
- \Drupal\node\Entity\Node field_ui_base_route = "entity.node_type.edit_form"
- \Drupal\node\Entity\NodeType "edit-form" = "/admin/structure/types/manage/{node_type}"
...but for Order item unit pride, it breaks:
- /admin/commerce/config/order-item-types/c4c_share/edit/fields/base-field-override/unit_price/add => throws
- \Drupal\commerce_order\Entity\OrderItem field_ui_base_route = "entity.commerce_order_item_type.edit_form"
- \Drupal\commerce_order\Entity\OrderItemType "edit-form" = "/admin/commerce/config/order-item-types/{commerce_order_item_type}/edit"
The only difference i see is that for order item, the route has a component after the bundle, but i can't phantasize how that can make a difference.
I also did not test, if the node access check gets the correct bundle, or if it just does not throw.
Comment #6
mnico commentedHi, I just made a merge request that would fix the problem. ;)
Regards
Comment #7
geek-merlinChapeau, that was really quick!
I can confirm that the MR fixes the issue for me, it allows me to add and delete a base field override for order items.
Code looks straightforward, the solution is like i'd have guessed.
One nit: I'd suggest inlining the getParametersFromRouteMatch() method (factoring out seems more confusion than clarification to me). YMMV.
Comment #8
mnico commentedThanks. Well I was reviewing the implementation and I realized that the RouteMatch service is required only to extract the bundle property in the addAccess method. In the other methods it is not necessary. So with this I remove the getParametersFromRouteMatch method.
Regards
Comment #9
holo96 commentedSolved issue for me.
Comment #10
geek-merlinI also can confirm worksforme.
Comment #12
mnico commentedThanks!
Comment #13
geek-merlinThanks for mergin quickly!