As part of the broader effort to minimize the amount of boilerplate needed to create custom entities, I'd like to get rid of the various *.links.*.yml files. As a first step, this issue tackles *.links.action.yml. If there is an entity collection and either an add page or an add form, then we generate an action link from the former to the latter.

I chose this one to get the ball rolling, because in my opinion it is almost 100% makes sense for all entity types in terms of functionality. So hopefully we can discuss whether people like the implementation or have other ideas.

I have been using the code in production for a while now, although I just thought of the trick to use a custom action class to get the translation right when writing the patch. I also added a small test, although it's not amazing in terms of coverage I hope it suffices for now.

Once this lands or if at least this gets some approval/traction, I think we can tackle the other types of links step by step.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tstoeckler created an issue. See original summary.

Status: Needs review » Needs work

The last submitted patch, entity-action-links.patch, failed testing. View results

tstoeckler’s picture

Status: Needs work » Needs review
FileSize
543 bytes
9.48 KB

Damn it, I forget the @group every time. I added the other two, just because the other functional tests had them as well, not sure why, as usually that would be setup by phpunit.xml, no?

tstoeckler’s picture

webflo’s picture

+++ b/src/Menu/EntityAddLocalAction.php
@@ -0,0 +1,80 @@
+    foreach ($entity_types as $entity_type_id => $entity_type) {

The entity type could be derived from the plugin id by default. No need to iterate over all entity type definitions.

tstoeckler’s picture

FileSize
3.84 KB
9.53 KB

Thanks for the review! Makes sense, fixed.

webflo’s picture

I like the patch, i have to write these yaml files all the time.

  • bojanz committed 060c406 on 8.x-1.x authored by tstoeckler
    Issue #2921844 by tstoeckler: Allow auto-generating local actions for...
bojanz’s picture

Status: Needs review » Fixed

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.