sites_group_overrides-1.x-dev/src/Event/SyncFieldToEntity.php

src/Event/SyncFieldToEntity.php
<?php

declare(strict_types=1);

namespace Drupal\sites_group_overrides\Event;

use Drupal\Component\EventDispatcher\Event;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Field\FieldItemListInterface;

/**
 * Event that is dispatched on the field sync.
 */
class SyncFieldToEntity extends Event {

  /**
   * The event name.
   */
  const EVENT_NAME = 'sites_grout_overrides.sync_field_to_entity';

  /**
   * Constructs a SyncFieldToEntity event.
   *
   * @param \Drupal\Core\Entity\FieldableEntityInterface $entity
   *   The sync goes into this entity.
   * @param string $fieldName
   *   The field name on the entity that is synced.
   * @param \Drupal\Core\Field\FieldItemListInterface $field
   *   The field on the corresponding relationship.
   */
  public function __construct(
    protected FieldableEntityInterface $entity,
    protected string $fieldName,
    protected FieldItemListInterface $field,
  ) {}

  /**
   * Get the entity.
   *
   * @return \Drupal\Core\Entity\FieldableEntityInterface
   *   The sync goes into this entity.
   */
  public function getEntity(): FieldableEntityInterface {
    return $this->entity;
  }

  /**
   * Get the field from the relationship.
   *
   * @return \Drupal\Core\Field\FieldItemListInterface
   *   The field on the relationship.
   */
  public function getField(): FieldItemListInterface {
    return $this->field;
  }

  /**
   * Get the field name on the entity.
   *
   * @return \Drupal\Core\Field\FieldItemListInterface
   *   The field name on the entity that is synced.
   */
  public function getFieldName(): string {
    return $this->fieldName;
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc