Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By plach on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.0.x
Introduced in version:
8.0.0-beta5
Issue links:
Description:
Content translation metadata is now accessed through an entity translation wrapper class. The Content Translation handler is responsible to expose field definitions for each metadata item. The wrapper provides methods to access the various metadata values. This approach allows one to provide an alternative set of field definitions for each entity type and to retrieve field values accordingly.
Before:
$metadata = $entity->translation;
$source = $metadata[$langcode]['source'];
$outdated = $metadata[$langcode]['outdated'];
After:
$manager = \Drupal::service('content_translation.manager');
$metadata = $manager->getTranslationMetadata($entity->getTranslation($langcode));
$source = $metadata->getSource();
$outdated = $metadata->isOutdated();
Impacts:
Module developers