public function RemoveLanguageField::shouldExclude in Acquia Content Hub 8.2
Prevent entity fields from being added to the serialized output.
Parameters
\Drupal\acquia_contenthub\Event\ExcludeEntityFieldEvent $event: The content entity field serialization event.
Overrides ExcludeContentFieldBase::shouldExclude
File
- src/
EventSubscriber/ ExcludeContentField/ RemoveLanguageField.php, line 20
Class
- RemoveLanguageField
- Subscribes to entity field serialization to handle language reference.
Namespace
Drupal\acquia_contenthub\EventSubscriber\ExcludeContentFieldCode
public function shouldExclude(ExcludeEntityFieldEvent $event) : bool {
if ('language' !== $event
->getField()
->getFieldDefinition()
->getType()) {
return FALSE;
}
// Do not syndicate the "langcode" entity type key because Drupal will do
// its own determination of things like "default_langcode" if values are
// present in that field.
return $event
->getFieldName() === $event
->getEntity()
->getEntityType()
->getKey('langcode');
}