It would be nice to have a plugin tracking entities related through Link fields.

Comments

marcoscano created an issue. See original summary.

bryandenijs’s picture

StatusFileSize
new9.55 KB

I created the LinkField plugin, based on the existing EntityReference plugin. Hope it helps!

marcoscano’s picture

Status: Active » Needs review
StatusFileSize
new15.61 KB

@BryanDeNijs thanks for contributing!

I'm afraid we've both been working on the same patch in parallel, sorry about that... :(

Haven't had a chance to look at your patch yet, but will do it now, and hopefully come up with a combined version that should be better than the 2 individual ones! :)

Thanks again!

marcoscano’s picture

StatusFileSize
new7.84 KB
new15.76 KB

@BryanDeNijs the patch from #2 looks quite good!

+++ b/src/Plugin/EntityUsage/Track/LinkField.php
@@ -0,0 +1,255 @@
+ *
+ * @EntityUsageTrack(
+ *   id = "link_field",

Once the field type is field, I think it is maybe more relevant to use the same ID here? Leaving at field for now.

Apart from that, looks like we were well-aligned. I used your parsing method and some other relevant notations as well.

The test is important, every time we include a new feature it should, if possible, be covered with test coverage.

Could you please test this just to double-check it works fine for your use case?

Thanks!

miro_dietiker’s picture

Imho it should not be the job of each plugin to filter the list of usages by existing ones or deal with merges across language. Instead the framework should take care of this itself.

marcoscano’s picture

@miro_dietiker thanks for the feedback! True, there is some code that is common logic inside the plugins. But let's do that modification in a follow-up, I've opened #2950246: Make tracking plugins lighter for that.

Thanks!

  • marcoscano committed a9ec878 on 8.x-1.x authored by BryanDeNijs
    Issue #2949950 by BryanDeNijs, marcoscano, miro_dietiker: Add plugin for...
marcoscano’s picture

Status: Needs review » Fixed

Committed, thanks!

bryandenijs’s picture

Can I ask why you are excluding the link basefields?
I can understand that entity reference basefields are excluded, but I see no reason to also exclude link basefields.

For the project I'm currently working, we want to track entity usage by menu links. This is now prevented, because the link field in a menu link is a basefield.

miro_dietiker’s picture

@BryanDeNijs As this is fixed, please open a new feauture request.

marcoscano’s picture

@BryanDeNijs yeah sorry I may have assumed too quickly the similarity with the entity_reference plugin.
Basically the general idea has been to focus only on user-created fields, but if there's a legitimate use case for allowing tracking through base fields without side effects, I'm not opposed to it. So yes let's continue this conversation in a follow-up issue?

Thanks!

Status: Fixed » Closed (fixed)

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