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
- class \Drupal\acquia_contenthub\EventSubscriber\ExcludeContentField\RemoveLanguageField
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'
1 service uses RemoveLanguageField
File
- src/
EventSubscriber/ ExcludeContentField/ RemoveLanguageField.php, line 10
Namespace
Drupal\acquia_contenthub\EventSubscriber\ExcludeContentFieldView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ExcludeContentFieldBase:: |
public | function | Sets the "exclude" flag. | |
ExcludeContentFieldBase:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
RemoveLanguageField:: |
public static | property |
Priority of the subscriber. Overrides ExcludeContentFieldBase:: |
|
RemoveLanguageField:: |
public | function |
Prevent entity fields from being added to the serialized output. Overrides ExcludeContentFieldBase:: |