You are here

class EntityPreSaveEvent in YAML Content 8

Same name and namespace in other branches
  1. 8.2 src/Event/EntityPreSaveEvent.php \Drupal\yaml_content\Event\EntityPreSaveEvent

Wraps a yaml content entity pre-save event for event listeners.

Hierarchy

  • class \Drupal\yaml_content\Event\EventBase extends \Symfony\Component\EventDispatcher\Event

Expanded class hierarchy of EntityPreSaveEvent

2 files declare their use of EntityPreSaveEvent
ContentLoader.php in src/ContentLoader/ContentLoader.php
MenuHierarchySubscriber.php in src/EventSubscriber/MenuHierarchySubscriber.php

File

src/Event/EntityPreSaveEvent.php, line 11

Namespace

Drupal\yaml_content\Event
View source
class EntityPreSaveEvent extends EventBase {

  /**
   * The entity prepared to be saved.
   *
   * @var \Drupal\Core\Entity\EntityInterface
   */
  protected $entity;

  /**
   * The parsed content from the file used to create the entity.
   *
   * @var array
   */
  protected $contentData;

  /**
   * Constructs a yaml content entity pre-save event object.
   *
   * @param \Drupal\yaml_content\ContentLoader\ContentLoaderInterface $loader
   *   The active Content Loader that triggered the event.
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity loaded with content and prepared for saving.
   * @param array $content_data
   *   The parsed content loaded from the content file resulting in this entity.
   */
  public function __construct(ContentLoaderInterface $loader, EntityInterface $entity, array $content_data) {
    parent::__construct($loader);
    $this->entity = $entity;
    $this->contentData = $content_data;
  }

  /**
   * Gets the entity that is populated and prepared for saving.
   *
   * @return \Drupal\Core\Entity\EntityInterface
   *   The created entity prepared to be saved.
   */
  public function getEntity() {
    return $this->entity;
  }

  /**
   * Gets the parsed content loaded from the content file to create the entity.
   *
   * @return array
   *   The parsed content from the file used to create the entity.
   */
  public function getContentData() {
    return $this->contentData;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityPreSaveEvent::$contentData protected property The parsed content from the file used to create the entity.
EntityPreSaveEvent::$entity protected property The entity prepared to be saved.
EntityPreSaveEvent::getContentData public function Gets the parsed content loaded from the content file to create the entity.
EntityPreSaveEvent::getEntity public function Gets the entity that is populated and prepared for saving.
EntityPreSaveEvent::__construct public function Constructs a yaml content entity pre-save event object. Overrides EventBase::__construct
EventBase::$contentLoader protected property The ContentLoader being actively executed and triggering the event.
EventBase::getContentLoader public function Gets the ContentLoader object that triggered the event.