You are here

class RemovePathAliasField in Acquia Content Hub 8.2

Subscribes to exclude path alias field.

Hierarchy

  • class \Drupal\acquia_contenthub\EventSubscriber\ExcludeContentField\ExcludeContentFieldBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of RemovePathAliasField

1 file declares its use of RemovePathAliasField
RemovePathAliasFieldTest.php in tests/src/Kernel/EventSubscriber/ExcludeContentField/RemovePathAliasFieldTest.php
1 string reference to 'RemovePathAliasField'
acquia_contenthub.services.yml in ./acquia_contenthub.services.yml
acquia_contenthub.services.yml
1 service uses RemovePathAliasField
path.field.cdf.exclude in ./acquia_contenthub.services.yml
Drupal\acquia_contenthub\EventSubscriber\ExcludeContentField\RemovePathAliasField

File

src/EventSubscriber/ExcludeContentField/RemovePathAliasField.php, line 10

Namespace

Drupal\acquia_contenthub\EventSubscriber\ExcludeContentField
View source
class RemovePathAliasField extends ExcludeContentFieldBase {

  /**
   * {@inheritdoc}
   */
  public static $priority = 60;

  /**
   * {@inheritDoc}
   */
  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';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ExcludeContentFieldBase::excludeContentField public function Sets the "exclude" flag.
ExcludeContentFieldBase::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
RemovePathAliasField::$priority public static property Priority of the subscriber. Overrides ExcludeContentFieldBase::$priority
RemovePathAliasField::shouldExclude public function Prevent entity fields from being added to the serialized output. Overrides ExcludeContentFieldBase::shouldExclude