You are here

class EntityExportCsvFieldsEvent in Entity Export CSV 8

Defines the fields event.

This event allow modules to alter the fields supported / enabled per entity type end bundle. Module can also add pseudo field, based of an existing field, if they want export same field several times in distinct format.

Hierarchy

Expanded class hierarchy of EntityExportCsvFieldsEvent

File

src/Event/EntityExportCsvFieldsEvent.php, line 14

Namespace

Drupal\entity_export_csv\Event
View source
class EntityExportCsvFieldsEvent extends Event {

  /**
   * An array of field definition (or label) keyed by the field name.
   *
   * @var array|\Drupal\Core\Field\FieldDefinitionInterface[]
   */
  protected $fields;

  /**
   * The entity type id.
   *
   * @var string
   */
  protected $entity_type_id;

  /**
   * The bundle.
   *
   * @var string
   */
  protected $bundle;

  /**
   * Return the field definition or the label (if false).
   *
   * @var bool
   */
  protected $returnFieldDefinition = FALSE;

  /**
   * Constructs a new EntityExportCsvFieldsSupportedEvent.
   *
   * @param array $fields
   *   The fields supported.
   * @param string $entity_type_id
   *   The entity type id.
   * @param string $bundle
   *   The bundle.
   * @param bool $return_field_definition
   *   Return the field definition or the label if false.
   */
  public function __construct(array $fields, $entity_type_id, $bundle, $return_field_definition) {
    $this->fields = $fields;
    $this->entity_type_id = $entity_type_id;
    $this->bundle = $bundle;
    $this->returnFieldDefinition = $return_field_definition;
  }

  /**
   * Gets the entity.
   *
   * @return string
   *   Gets the entity type id.
   */
  public function getEntityTypeId() {
    return $this->entity_type_id;
  }

  /**
   * Gets the bundle.
   *
   * @return string
   *   The bundle.
   */
  public function getBundle() {
    return $this->bundle;
  }

  /**
   * Should return the field definition ?
   *
   * @return bool
   *   Return the field definition or the label (if false).
   */
  public function shouldReturnFieldDefinition() {
    return $this->returnFieldDefinition;
  }

  /**
   * Gets the fields.
   *
   * @return array
   *   An array of field definitions, or label, keyed by field_name.
   */
  public function getFields() {
    return $this->fields;
  }

  /**
   * Sets the supported fields.
   *
   * @param array $fields
   *   An array of field definitions, or label, keyed by field_name.
   *
   * @return $this
   */
  public function setFields(array $fields) {
    $this->fields = $fields;
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityExportCsvFieldsEvent::$bundle protected property The bundle.
EntityExportCsvFieldsEvent::$entity_type_id protected property The entity type id.
EntityExportCsvFieldsEvent::$fields protected property An array of field definition (or label) keyed by the field name.
EntityExportCsvFieldsEvent::$returnFieldDefinition protected property Return the field definition or the label (if false).
EntityExportCsvFieldsEvent::getBundle public function Gets the bundle.
EntityExportCsvFieldsEvent::getEntityTypeId public function Gets the entity.
EntityExportCsvFieldsEvent::getFields public function Gets the fields.
EntityExportCsvFieldsEvent::setFields public function Sets the supported fields.
EntityExportCsvFieldsEvent::shouldReturnFieldDefinition public function Should return the field definition ?
EntityExportCsvFieldsEvent::__construct public function Constructs a new EntityExportCsvFieldsSupportedEvent.