- 🇦🇺Australia acbramley
the Term parent field no longer uses custom storage (it's a regular ER field) so we should update the IS with an example (hopefully from core) that demonstrates the issue with steps to reproduce if possible
In the Search API module → we use the typed data system to provide type-agnostic indexing for all entities, all their properties and sub-properties, etc.
While this is already working fine for almost all (content) entities and properties, we currently cannot index taxonomy term parents, or any of their properties, since (as I just found out) they use a "custom storage" and are thus, apparently, not accessible via typed data.
To illustrate: we do something like the following.
$item = \Drupal\taxonomy\Entity\Term::load($tid)->getTypedData();
$name = 'name';
$property = $item->get($name);
$main_property = $property->getFieldDefinition()->getMainPropertyName();
foreach ($property as $value) {
$this->indexValue($value->get($main_property)->getValue());
}
This works quite well, but if you use $name = 'parent'
instead, this won't work anymore.
Now, I already know that I can use $property->getFieldDefinition()->hasCustomStorage()
to determine whether the field in question uses custom storage (checking for the proper interface first, of course). My question is if there's something I can do with that knowledge? Is there any generic way to load a property value from a "custom storage", or do I have to apply property-specific logic (ruining the purpose of typed data, in this specific scenario)?
More importantly, though, could we fix this behavior for typed data? I.e., make the above work even for fields with custom storage?
Apparently,
#2543726: Make $term->parent behave like any other entity reference field, to fix REST and Migrate support and de-customize its Views integration →
would move the parent
property back to "normal" storage, and it might then start working with the code above, but the question would still remain valid for other fields with custom storage (like the path
field of the Path module).
Active
11.0 🔥
typed data system
Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
the Term parent field no longer uses custom storage (it's a regular ER field) so we should update the IS with an example (hopefully from core) that demonstrates the issue with steps to reproduce if possible