class ExcludeEntityFieldEvent in Acquia Content Hub 8.2
Event fired when serializing individual entity fields for syndication.
Subscribers to this event will exclude entity fields for the CDF serialization process. $this->isExcludedField will prevent the key/value from being syndicated.
Hierarchy
- class \Drupal\acquia_contenthub\Event\ExcludeEntityFieldEvent extends \Symfony\Component\EventDispatcher\Event
Expanded class hierarchy of ExcludeEntityFieldEvent
See also
\Drupal\acquia_contenthub\AcquiaContentHubEvents
12 files declare their use of ExcludeEntityFieldEvent
- ContentEntityHandler.php in src/
EventSubscriber/ Cdf/ ContentEntityHandler.php - ExcludeContentFieldBase.php in src/
EventSubscriber/ ExcludeContentField/ ExcludeContentFieldBase.php - RemoveIdField.php in src/
EventSubscriber/ ExcludeContentField/ RemoveIdField.php - RemoveIdFieldTest.php in tests/
src/ Kernel/ EventSubscriber/ ExcludeContentField/ RemoveIdFieldTest.php - RemoveLanguageField.php in src/
EventSubscriber/ ExcludeContentField/ RemoveLanguageField.php
File
- src/
Event/ ExcludeEntityFieldEvent.php, line 18
Namespace
Drupal\acquia_contenthub\EventView source
class ExcludeEntityFieldEvent extends Event {
/**
* The entity being serialized.
*
* @var \Drupal\Core\Entity\EntityInterface
*/
protected $entity;
/**
* The name of the field being serialized.
*
* @var string
*/
protected $fieldName;
/**
* The "exclude" flag.
*
* If set to TRUE, the field will not be added to the CDF object.
*
* @var bool
*/
protected $isExcludedField = FALSE;
/**
* The field being serialized.
*
* @var \Drupal\Core\Field\FieldItemListInterface
*/
protected $field;
/**
* SerializeCdfEntityFieldEvent constructor.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity to which the field belongs.
* @param string $field_name
* The name of the field.
* @param \Drupal\Core\Field\FieldItemListInterface $field
* The field item list object.
*/
public function __construct(EntityInterface $entity, string $field_name, FieldItemListInterface $field) {
$this->entity = $entity;
$this->fieldName = $field_name;
$this->field = $field;
}
/**
* Get the entity being processed.
*
* @return \Drupal\Core\Entity\EntityInterface
* The entity being processed.
*/
public function getEntity() : EntityInterface {
return $this->entity;
}
/**
* The field item list object.
*
* @return \Drupal\Core\Field\FieldItemListInterface
* Field item list object.
*/
public function getField() : FieldItemListInterface {
return $this->field;
}
/**
* The name of the field.
*
* @return string
* Field name.
*/
public function getFieldName() : string {
return $this->fieldName;
}
/**
* Sets the "exclude" flag.
*/
public function exclude() {
$this->isExcludedField = TRUE;
}
/**
* Returns the "exclude" flag state.
*
* @return bool
* "Exclude" flag state.
*/
public function isExcluded() : bool {
return $this->isExcludedField;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ExcludeEntityFieldEvent:: |
protected | property | The entity being serialized. | |
ExcludeEntityFieldEvent:: |
protected | property | The field being serialized. | |
ExcludeEntityFieldEvent:: |
protected | property | The name of the field being serialized. | |
ExcludeEntityFieldEvent:: |
protected | property | The "exclude" flag. | |
ExcludeEntityFieldEvent:: |
public | function | Sets the "exclude" flag. | |
ExcludeEntityFieldEvent:: |
public | function | Get the entity being processed. | |
ExcludeEntityFieldEvent:: |
public | function | The field item list object. | |
ExcludeEntityFieldEvent:: |
public | function | The name of the field. | |
ExcludeEntityFieldEvent:: |
public | function | Returns the "exclude" flag state. | |
ExcludeEntityFieldEvent:: |
public | function | SerializeCdfEntityFieldEvent constructor. |