Add support for External Entities (with Fields)

Created on 16 January 2024, 12 months ago
Updated 31 July 2024, 5 months ago

Problem/Motivation

Because of differences in the implementation of external entities compared to other fielded entity types the default behavior in src/EntityClone/Config/ConfigWithFieldEntityClone.php cloned an external entity, but did not add any of the additional fields.

The primary discrepancy lies in the fact that different external entity types are not bundles of type external entity, but instead each external entity is it's own type. Meaning bundle and type are the same. So in ConfigWithFieldEntityClone, $cloned_entity->getEntityType()->getBundleOf() returned null.

As a result of this behavior, field definitions don't re-use field storage, so for each new external entity that is cloned the field storage definitions must be cloned along with the field definitions. Similarly view and form displays don't follow the same naming convention as other entities.

Steps to reproduce

  1. Install external entities
  2. Create a new external entity with at least one additional field of any type/configuration.
  3. Enable entity clone
  4. Allow external entities and the newly created external entity to be cloned
  5. Clone the newly created external entity (that has additional fields)
  6. Observe that the newly clone external entity shares all configuration, but not any additional fields nor view/form display configuration

Proposed resolution

I've included a patch with a new class, ExternalEntityClone that extends ConfigEntityCloneBase.
It's a modified version of ConfigWithFieldEntityClone that will work with external entities.

Included in the patch is a modification of entity_clone_entity_type_build in entity_cone.module to include an entry in $specific_handler for the external_entity_type, which allows the new class to work with external entities.

This patch has already been tested with local instances of our current site and will likely be included on our stack soon.

Remaining tasks

Testing then merging into the module.

User interface changes

None

API changes

None. This patch and proposed follows the existing patterns and paradigms in this module.

Data model changes

None.

Feature request
Status

Needs review

Version

2.0

Component

Code

Created by

🇺🇸United States devanbicher

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024