From ca69fcf1c7e7e41c166d79efeab210d7f119655c Mon Sep 17 00:00:00 2001 From: Aaron Bauman <aaron@messageagency.com> Date: Thu, 3 Aug 2023 13:06:02 -0400 Subject: [PATCH] Missed the new file --- .../src/Event/SalesforcePullEnqueueEvent.php | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 modules/salesforce_mapping/src/Event/SalesforcePullEnqueueEvent.php diff --git a/modules/salesforce_mapping/src/Event/SalesforcePullEnqueueEvent.php b/modules/salesforce_mapping/src/Event/SalesforcePullEnqueueEvent.php new file mode 100644 index 00000000..3f324d30 --- /dev/null +++ b/modules/salesforce_mapping/src/Event/SalesforcePullEnqueueEvent.php @@ -0,0 +1,147 @@ +<?php + +namespace Drupal\salesforce_mapping\Event; + +use Drupal\salesforce\Event\SalesforceBaseEvent; +use Drupal\salesforce\SelectQueryResult; +use Drupal\salesforce\SFID; +use Drupal\salesforce\SObject; +use Drupal\salesforce_mapping\Entity\SalesforceMappingInterface; + + +/** + * Salesforce Pull Enqueue Event. + */ +class SalesforcePullEnqueueEvent extends SalesforceBaseEvent { + + /** + * The mapping responsible for this pull. + * + * @var SalesforceMappingInterface + */ + protected $mapping; + + /** + * The SelectQueryResult object associated with this pull. + * + * @var SelectQueryResult + */ + protected $records; + + /** + * Current SObject from the loop. + * + * @var SObject + */ + protected $record; + + /** + * Whether to force pull for the given record. + * + * @var bool + */ + protected $forcePull; + + /** + * TRUE or FALSE to indicate if pull is allowed for this event. + * + * @var bool + */ + protected $enqueueAllowed; + + /** + * @param SalesforceMappingInterface $mapping + * @param SelectQueryResult $records + * @param SObject $record + */ + public function __construct(SalesforceMappingInterface $mapping, SelectQueryResult $records, SObject $record, $force_pull){ + $this->mapping = $mapping; + $this->records = $records; + $this->record = $record; + $this->forcePull = $force_pull; + $this->enqueueAllowed = TRUE; + } + + /** + * Get Mapping Interface object + * + * @return SalesforceMappingInterface; + * + */ + public function getMapping() { + return $this->mapping; + } + + /** + * Get all records. + * + * @return SelectQueryResult; + * + */ + public function getRecords() { + return $this->records; + } + + + /** + * Returns SF Object Type. + * @return string + */ + public function getRecordType() { + return $this->record->type(); + } + + /** + * @return SFID + */ + public function getRecordId(){ + return $this->record->id(); + } + + /** + * @return SObject + */ + public function getRecord() { + return $this->record; + } + + /** + * @return array + */ + public function getCurrentRecordFields() { + return $this->record->fields(); + } + + /** + * Disallow queue item. + */ + public function disallowEnqueue() { + $this->enqueueAllowed = FALSE; + return $this; + } + /** + * Will return FALSE if any subscribers have called disallowPull(). + * + * @return bool + * TRUE if pull is allowed, false otherwise. + */ + public function isEnqueueAllowed() { + return $this->enqueueAllowed; + } + /** + * Getter. + * + * @return bool + * Force pull. + */ + public function getForcePull() { + // Legacy backwards compatibility. + // @TODO remove for 8.x-3.3 + if (property_exists($this, 'force_pull')) { + return $this->force_pull; + } + return $this->forcePull; + } +} + + -- GitLab