You are here

class ContentHubEntityEligibilityEvent in Acquia Content Hub 8.2

Event fired for eligibility of an entity to POST to ContentHub.

Subscribers to this event should manipulate $this->setEligibility() to prevent entities from being considered eligible for ContentHub POSTing. Entities are considered eligible by default.

Hierarchy

Expanded class hierarchy of ContentHubEntityEligibilityEvent

See also

\Drupal\acquia_contenthub_publisher\ContentHubPublisherEvents

16 files declare their use of ContentHubEntityEligibilityEvent
acquia_contenthub_publisher.module in modules/acquia_contenthub_publisher/acquia_contenthub_publisher.module
Drupal Module: Acquia Content Hub - Publisher.
EntityTypeOrBundleExclude.php in modules/acquia_contenthub_publisher/src/EventSubscriber/EnqueueEligibility/EntityTypeOrBundleExclude.php
FileIsTemporary.php in modules/acquia_contenthub_publisher/src/EventSubscriber/EnqueueEligibility/FileIsTemporary.php
FileSchemeIsSupported.php in modules/acquia_contenthub_publisher/src/EventSubscriber/EnqueueEligibility/FileSchemeIsSupported.php
ImportedEntity.php in modules/acquia_contenthub_publisher/src/EventSubscriber/EnqueueEligibility/ImportedEntity.php

... See full list

File

modules/acquia_contenthub_publisher/src/Event/ContentHubEntityEligibilityEvent.php, line 17

Namespace

Drupal\acquia_contenthub_publisher\Event
View source
class ContentHubEntityEligibilityEvent extends Event {

  /**
   * The entity being evaluated for eligibility.
   *
   * @var \Drupal\Core\Entity\EntityInterface
   */
  protected $entity;

  /**
   * The operation being performed.
   *
   * Should be a value of "insert" or "update".
   *
   * @var string
   */
  protected $operation;

  /**
   * Whether the entity is eligible for the ContentHub queue.
   *
   * @var bool
   */
  protected $eligibility = TRUE;

  /**
   * Whether the entity should go through a full dependency calculation.
   *
   * @var bool
   */
  protected $calculateDependencies = TRUE;

  /**
   * ContentHubEntityEligibilityEvent constructor.
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity being evaluated for eligibility.
   * @param string $op
   *   Whether this is being inserted or updated.
   */
  public function __construct(EntityInterface $entity, $op) {
    $this->entity = $entity;
    $this->operation = $op;
  }

  /**
   * The entity being evaluated for eligibility.
   *
   * @return \Drupal\Core\Entity\EntityInterface
   *   The entity that is being evaluated for eligibility.
   */
  public function getEntity() {
    return $this->entity;
  }

  /**
   * The operation being performed.
   *
   * @return string
   *   The operation identifier that's being performed.
   */
  public function getOperation() {
    return $this->operation;
  }

  /**
   * Whether the entity is eligible for the ContentHub queue.
   *
   * @return bool
   *   TRUE if eligible; FALSE otherwise.
   */
  public function getEligibility() : bool {
    return $this->eligibility;
  }

  /**
   * Set the eligibility of this entity for the ContentHub queue.
   *
   * @param bool $eligible
   *   TRUE if eligible; FALSE otherwise.
   *
   * @throws \Exception
   */
  public function setEligibility($eligible) {
    if (!is_bool($eligible)) {
      throw new \Exception("Eligibility must be a boolean value.");
    }
    $this->eligibility = $eligible;
  }

  /**
   * Whether the entity should go through a full dependency calculation.
   *
   * @return bool
   *   TRUE if full dependency calculation should be performed; FALSE otherwise.
   */
  public function getCalculateDependencies() : bool {
    return $this->calculateDependencies;
  }

  /**
   * Set whether the entity should go through a full dependency calculation.
   *
   * @param bool $calculate_dependencies
   *   TRUE if full dependency calculation should be performed; FALSE otherwise.
   *
   * @throws \Exception
   */
  public function setCalculateDependencies($calculate_dependencies) {
    if (!is_bool($calculate_dependencies)) {
      throw new \Exception("calculateDependencies must be a boolean value.");
    }
    $this->calculateDependencies = $calculate_dependencies;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContentHubEntityEligibilityEvent::$calculateDependencies protected property Whether the entity should go through a full dependency calculation.
ContentHubEntityEligibilityEvent::$eligibility protected property Whether the entity is eligible for the ContentHub queue.
ContentHubEntityEligibilityEvent::$entity protected property The entity being evaluated for eligibility.
ContentHubEntityEligibilityEvent::$operation protected property The operation being performed.
ContentHubEntityEligibilityEvent::getCalculateDependencies public function Whether the entity should go through a full dependency calculation.
ContentHubEntityEligibilityEvent::getEligibility public function Whether the entity is eligible for the ContentHub queue.
ContentHubEntityEligibilityEvent::getEntity public function The entity being evaluated for eligibility.
ContentHubEntityEligibilityEvent::getOperation public function The operation being performed.
ContentHubEntityEligibilityEvent::setCalculateDependencies public function Set whether the entity should go through a full dependency calculation.
ContentHubEntityEligibilityEvent::setEligibility public function Set the eligibility of this entity for the ContentHub queue.
ContentHubEntityEligibilityEvent::__construct public function ContentHubEntityEligibilityEvent constructor.