You are here

class ParseCdfEntityEvent in Acquia Content Hub 8.2

The event fired during importing a CDF into a local entity.

EventSubscribers to this event are responsible for processing the CDFObject into a Drupal entity. If you need to create a CDF parser that acts on an entity already acted upon by the core of ContentHub, you can set a higher priority for your subscriber and stop propagation of subsequent subscribers, or you can set your priority to be lower than the core subscribers and just modify the entity created by ContentHub before it is save. The second option is preferable in most circumstances. Look at how the core module handles file entities for further insight on this approach.

Hierarchy

  • class \Drupal\acquia_contenthub\Event\ParseCdfEntityEvent extends \Symfony\Component\EventDispatcher\Event

Expanded class hierarchy of ParseCdfEntityEvent

9 files declare their use of ParseCdfEntityEvent
ConfigEntityHandler.php in src/EventSubscriber/Cdf/ConfigEntityHandler.php
ConfigEntityLayoutBuilderHandler.php in src/EventSubscriber/Cdf/ConfigEntityLayoutBuilderHandler.php
ContentEntityHandler.php in src/EventSubscriber/Cdf/ContentEntityHandler.php
EntityCdfSerializer.php in src/EntityCdfSerializer.php
ExistingUser.php in src/EventSubscriber/Cdf/ExistingUser.php

... See full list

File

src/Event/ParseCdfEntityEvent.php, line 22

Namespace

Drupal\acquia_contenthub\Event
View source
class ParseCdfEntityEvent extends Event {

  /**
   * The CDF Array to be parsed.
   *
   * @var \Acquia\ContentHubClient\CDF\CDFObject
   */
  protected $cdf;

  /**
   * The dependency stack.
   *
   * @var \Drupal\depcalc\DependencyStack
   */
  protected $stack;

  /**
   * The resulting entity.
   *
   * @var \Drupal\Core\Entity\EntityInterface
   */
  protected $entity;

  /**
   * Whether the set entity is mutable.
   *
   * @var bool
   */
  protected $mutable = TRUE;

  /**
   * ParseCdfEntityEvent constructor.
   *
   * @param \Acquia\ContentHubClient\CDF\CDFObject $cdf
   *   The CDF being parsed.
   * @param \Drupal\depcalc\DependencyStack $stack
   *   The dependency stack object.
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The pre-loaded or created entity for data storage.
   */
  public function __construct(CDFObject $cdf, DependencyStack $stack, EntityInterface $entity = NULL) {
    $this->cdf = $cdf;
    $this->stack = $stack;
    $this->entity = $entity;
  }

  /**
   * Returns the CDF Array.
   *
   * @return \Acquia\ContentHubClient\CDF\CDFObject
   *   The CDF being parsed.
   */
  public function getCdf() {
    return $this->cdf;
  }

  /**
   * Whether the set entity is mutable.
   *
   * @return bool
   *   TRUE if mutable; FALSE otherwise.
   */
  public function isMutable() {
    return $this->mutable;
  }

  /**
   * Sets whether the entity is mutable or not.
   *
   * @param bool $mutable
   *   Set to TRUE if mutable; FALSE otherwise.
   */
  public function setMutable($mutable = TRUE) {
    $this->mutable = $mutable;
  }

  /**
   * Whether an entity has been set or not.
   *
   * @return bool
   *   TRUE if has entity; FALSE otherwise.
   */
  public function hasEntity() {
    return (bool) $this->entity;
  }

  /**
   * Obtains the parsed entity from the CDF.
   *
   * @return \Drupal\Core\Entity\EntityInterface
   *   The entity parsed from the CDF.
   */
  public function getEntity() {
    return $this->entity;
  }

  /**
   * Sets the parsed entity.
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity parsed from the CDF.
   */
  public function setEntity(EntityInterface $entity) {
    $this->entity = $entity;
  }

  /**
   * Get the dependency stack.
   *
   * @return \Drupal\depcalc\DependencyStack
   *   The dependency stack.
   */
  public function getStack() {
    return $this->stack;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ParseCdfEntityEvent::$cdf protected property The CDF Array to be parsed.
ParseCdfEntityEvent::$entity protected property The resulting entity.
ParseCdfEntityEvent::$mutable protected property Whether the set entity is mutable.
ParseCdfEntityEvent::$stack protected property The dependency stack.
ParseCdfEntityEvent::getCdf public function Returns the CDF Array.
ParseCdfEntityEvent::getEntity public function Obtains the parsed entity from the CDF.
ParseCdfEntityEvent::getStack public function Get the dependency stack.
ParseCdfEntityEvent::hasEntity public function Whether an entity has been set or not.
ParseCdfEntityEvent::isMutable public function Whether the set entity is mutable.
ParseCdfEntityEvent::setEntity public function Sets the parsed entity.
ParseCdfEntityEvent::setMutable public function Sets whether the entity is mutable or not.
ParseCdfEntityEvent::__construct public function ParseCdfEntityEvent constructor.