You are here

class SalesforcePullEvent in Salesforce Suite 5.0.x

Same name and namespace in other branches
  1. 8.4 modules/salesforce_mapping/src/Event/SalesforcePullEvent.php \Drupal\salesforce_mapping\Event\SalesforcePullEvent
  2. 8.3 modules/salesforce_mapping/src/Event/SalesforcePullEvent.php \Drupal\salesforce_mapping\Event\SalesforcePullEvent

Salesforce pull event.

Hierarchy

Expanded class hierarchy of SalesforcePullEvent

4 files declare their use of SalesforcePullEvent
MappedObject.php in modules/salesforce_mapping/src/Entity/MappedObject.php
PullBase.php in modules/salesforce_pull/src/Plugin/QueueWorker/PullBase.php
PullBaseTest.php in modules/salesforce_pull/tests/src/Unit/PullBaseTest.php
SalesforceExampleSubscriber.php in modules/salesforce_example/src/EventSubscriber/SalesforceExampleSubscriber.php

File

modules/salesforce_mapping/src/Event/SalesforcePullEvent.php, line 11

Namespace

Drupal\salesforce_mapping\Event
View source
class SalesforcePullEvent extends SalesforceBaseEvent {

  /**
   * The mapping responsible for this pull.
   *
   * @var \Drupal\salesforce_mapping\Entity\SalesforceMappingInterface
   */
  protected $mapping;

  /**
   * The mapped object associated with this pull.
   *
   * @var \Drupal\salesforce_mapping\Entity\MappedObjectInterface
   */
  protected $mappedObject;

  /**
   * The Drupal entity into which the data is being pulled.
   *
   * @var \Drupal\Core\Entity\FieldableEntityInterface
   */
  protected $entity;

  /**
   * The pull operation.
   *
   * One of:
   * \Drupal\salesforce_mapping\MappingConstants::SALESFORCE_MAPPING_SYNC_SF_CREATE
   * \Drupal\salesforce_mapping\MappingConstants::SALESFORCE_MAPPING_SYNC_SF_UPDATE
   * \Drupal\salesforce_mapping\MappingConstants::SALESFORCE_MAPPING_SYNC_SF_DELETE.
   *
   * @var string
   */
  protected $op;

  /**
   * TRUE or FALSE to indicate if pull is allowed for this event.
   *
   * @var bool
   */
  protected $pullAllowed;

  /**
   * SalesforcePullEvent constructor.
   *
   * @param \Drupal\salesforce_mapping\Entity\MappedObjectInterface $mappedObject
   *   The mapped object.
   * @param string $op
   *   The operation.
   */
  public function __construct(MappedObjectInterface $mappedObject, $op) {
    $this->mappedObject = $mappedObject;
    $this->entity = $mappedObject
      ->getMappedEntity();
    $this->mapping = $mappedObject
      ->getMapping();
    $this->op = $op;
    $this->pullAllowed = TRUE;
  }

  /**
   * Getter.
   *
   * @return \Drupal\Core\Entity\FieldableEntityInterface
   *   The entity.
   */
  public function getEntity() {
    return $this->entity;
  }

  /**
   * Getter.
   *
   * @return \Drupal\salesforce_mapping\Entity\SalesforceMappingInterface
   *   The mapping interface.
   */
  public function getMapping() {
    return $this->mapping;
  }

  /**
   * Getter.
   *
   * @return \Drupal\salesforce_mapping\Entity\MappedObjectInterface
   *   The mapped object.
   */
  public function getMappedObject() {
    return $this->mappedObject;
  }

  /**
   * Getter for the pull operation.
   *
   * One of:
   * \Drupal\salesforce_mapping\MappingConstants::SALESFORCE_MAPPING_SYNC_SF_CREATE
   * \Drupal\salesforce_mapping\MappingConstants::SALESFORCE_MAPPING_SYNC_SF_UPDATE
   * \Drupal\salesforce_mapping\MappingConstants::SALESFORCE_MAPPING_SYNC_SF_DELETE.
   *
   * @return string
   *   The op.
   */
  public function getOp() {
    return $this->op;
  }

  /**
   * Disallow and stop pull for the current queue item.
   */
  public function disallowPull() {
    $this->pullAllowed = FALSE;
    return $this;
  }

  /**
   * Will return FALSE if any subscribers have called disallowPull().
   *
   * @return bool
   *   TRUE if pull is allowed, false otherwise.
   */
  public function isPullAllowed() {
    return $this->pullAllowed;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SalesforcePullEvent::$entity protected property The Drupal entity into which the data is being pulled.
SalesforcePullEvent::$mappedObject protected property The mapped object associated with this pull.
SalesforcePullEvent::$mapping protected property The mapping responsible for this pull.
SalesforcePullEvent::$op protected property The pull operation.
SalesforcePullEvent::$pullAllowed protected property TRUE or FALSE to indicate if pull is allowed for this event.
SalesforcePullEvent::disallowPull public function Disallow and stop pull for the current queue item.
SalesforcePullEvent::getEntity public function Getter.
SalesforcePullEvent::getMappedObject public function Getter.
SalesforcePullEvent::getMapping public function Getter.
SalesforcePullEvent::getOp public function Getter for the pull operation.
SalesforcePullEvent::isPullAllowed public function Will return FALSE if any subscribers have called disallowPull().
SalesforcePullEvent::__construct public function SalesforcePullEvent constructor.