Use external_entities to declare Unomi types as Drupal entities

Created on 24 July 2023, over 1 year ago
Updated 3 August 2023, over 1 year ago

Problem/Motivation

The external_entities module ( https://www.drupal.org/project/external_entities ) lets you define an entity type where the entities come from external data.

Which is basically what Unomi entities are (profiles, rules, segments, events, etc).

If we could use this, we'd get a lot more admin UI OOTB -- I'm still experimenting to see what it gives us. But at the moment, I'm feeling like I'm reinventing the wheel each time I set up a new UI section for a new type of data from Unomi.

However, the module is currently geared only towards configuring external entity types in the admin UI -- see Define entity types programmatically Active . Our use case would require defining them in code.

We probably don't need to wait for that issue - we could subclass various things.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom joachim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @joachim
  • 🇬🇧United Kingdom joachim

    Update: I've made quite a lot of progress with this.

    I've got Unomi entities defined as Drupal entities. There's a lot less boilerplate code for the admin UI, but to counterbalance that, there's lots more code to declare things to the entity system - entity type class, storage client and field mapper plugins, and then (hopefully) temporary code to work around Define entity types programmatically Active .

    I prefer it like this, because it's code that works with existing, standard systems.

    However, as it's a big change I'd like input from the project owner -- should this be a new major version of this module, or should it be a forked new project?

  • 🇬🇧United Kingdom joachim

    I've hit a bit of an issue -- the entity list builder makes a remote request to run the entity query, and THEN runs a request for EVERY entity to load it to show in the list.

    I'm sure there's a way to work around it, but it might end up being fiddly.

    - making the EE storage client plugin cache the query result won't work, because Unomi list queries don't return complete entities, AFAICT they return what's inside the metadata property of a full entity.
    - changing the query to return all the data won't work - it's totally changing how entity queries work, which is they just return IDs
    - we could override list builder's load() method so it doesn't do a query, just a loadMultiple(). But then we don't get the paging functionality which would have scaling implications for the list pages of profiles and events

  • 🇬🇧United Kingdom joachim

    Pushed work in progress to a branch.

    > - we could override list builder's load() method so it doesn't do a query, just a loadMultiple(). But then we don't get the paging functionality which would have scaling implications for the list pages of profiles and events

    I'm leaning towards a variation of this -- we add a new method to the storage backend for queries that return metadata.

Production build 0.71.5 2024