public function RemoveIdField::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/ RemoveIdField.php, line 20
Class
- RemoveIdField
- Subscribes to exclude entity id field.
Namespace
Drupal\acquia_contenthub\EventSubscriber\ExcludeContentFieldCode
public function shouldExclude(ExcludeEntityFieldEvent $event) : bool {
if ($event
->getEntity()
->getEntityTypeId() === 'entity_subqueue') {
return FALSE;
}
$entity_type = $event
->getEntity()
->getEntityType();
return $event
->getFieldName() === $entity_type
->getKey('id');
}