You are here

class RemoveLanguageField in Acquia Content Hub 8.2

Subscribes to entity field serialization to handle language reference.

Hierarchy

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

Expanded class hierarchy of RemoveLanguageField

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

File

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

Namespace

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

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

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

}

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.
RemoveLanguageField::$priority public static property Priority of the subscriber. Overrides ExcludeContentFieldBase::$priority
RemoveLanguageField::shouldExclude public function Prevent entity fields from being added to the serialized output. Overrides ExcludeContentFieldBase::shouldExclude