- πΊπ¦Ukraine podarok Ukraine
git apply compatibility-taxonomy_menu_ui_reroll.patch error: patch failed: src/Service/MenuLinkContentService.php:14 error: src/Service/MenuLinkContentService.php: patch does not apply
needs reroll
also, please, use MR instead of patches, way easier in 21 century
Thanks for this, I need this as well. I wrote my own patch which I was about to create an issue for, then I found this one.
Before this merge request should be accepted please note that I think there are several issues with this patch:Get rid of the _addSubmitHandler function
The function
_addSubmitHandler
in menu_item_extras.module shouldn't be used. This can easily conflict with another module containing the same function.I would suggest adding a method addSubmitHandler to the menu_item_extras.menu_link_content_helper service and call that method instead.
Refactor the entity type check
There are several issues with this code:
use Drupal\node\Entity\Node; use Drupal\taxonomy\Entity\Term; ... if ($parentEntity instanceof Node) { $uri = 'entity:node/' . $parentEntity->id(); } elseif ($parentEntity instanceof Term) { $uri = 'entity:taxonomy_term/' . $parentEntity->id(); }
- The interfaces should be used instead
- A fallback / exception should be there for other entity typesI think it should be refactored like this:
use Drupal\node\Entity\NodeInterface; use Drupal\taxonomy\Entity\TermInterface; ... $uri = ''; if ($parentEntity instanceof NodeInterface) { $uri = 'entity:node/' . $parentEntity->id(); } elseif ($parentEntity instanceof TermInterface) { $uri = 'entity:taxonomy_term/' . $parentEntity->id(); } else { throw new \Exception('Entity type is currently not supported by the Menu Item Extras module'); }
Also I think it may be problemetic to simply refer the NodeInterface and the TermInterface like this, because these namespaces do not exist if either the Node module or the Taxonomy module is not enabled.
The Menu Item Extras module could depend on both modules, but I don't think that would be correct, because the module should be usable without the Taxonomy module. The best solution might be to move parts of this code to a menu_item_extras_taxonomy module, but that will be some extra work.