You are here

public function RemovePathAliasField::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/RemovePathAliasField.php, line 20

Class

RemovePathAliasField
Subscribes to exclude path alias field.

Namespace

Drupal\acquia_contenthub\EventSubscriber\ExcludeContentField

Code

public function shouldExclude(ExcludeEntityFieldEvent $event) : bool {

  // As we are not supporting Drupal version 8.7 and after 8.8 path alias
  // is an entity that's why prevent it from being added to the
  // serialized output.
  return $event
    ->getEntity()
    ->getEntityTypeId() !== 'path_alias' && $event
    ->getFieldName() === 'path';
}