diff --git a/modules/salesforce_mapping/src/Form/MappedObjectDeleteForm.php b/modules/salesforce_mapping/src/Form/MappedObjectDeleteForm.php index b17640e1fe97a22a11894a041182f825b3b60599..1ae560b4dc33007db62f9e23a4386057f754ddaa 100644 --- a/modules/salesforce_mapping/src/Form/MappedObjectDeleteForm.php +++ b/modules/salesforce_mapping/src/Form/MappedObjectDeleteForm.php @@ -5,6 +5,7 @@ namespace Drupal\salesforce_mapping\Form; use Drupal\Core\Entity\ContentEntityConfirmFormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\salesforce\Event\SalesforceNoticeEvent; +use Drupal\salesforce\Event\SalesforceEvents; /** * Provides a form for deleting a salesforce_mapped_oject entity. diff --git a/modules/salesforce_mapping/src/Form/MappedObjectForm.php b/modules/salesforce_mapping/src/Form/MappedObjectForm.php index b3b08d16db807aa0dffe2382e9f257811b21a7ca..09067d42da48b91184ce86542d3138c6111b7545 100644 --- a/modules/salesforce_mapping/src/Form/MappedObjectForm.php +++ b/modules/salesforce_mapping/src/Form/MappedObjectForm.php @@ -9,9 +9,9 @@ use Drupal\Core\Routing\RouteMatchInterface; use Drupal\salesforce\Rest\RestClientInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\salesforce\Event\SalesforceErrorEvent; +use Drupal\salesforce\Event\SalesforceEvents; use Symfony\Component\EventDispatcher\EventDispatcherInterface; - /** * Salesforce Mapping Form base. */ diff --git a/modules/salesforce_mapping/src/Plugin/SalesforceMappingField/RelatedProperties.php b/modules/salesforce_mapping/src/Plugin/SalesforceMappingField/RelatedProperties.php index 2d3343e9d67057c2ca7ddafd6014b6e85006240e..11749a553bdd536c0f73802ff51fa1a425aa20de 100644 --- a/modules/salesforce_mapping/src/Plugin/SalesforceMappingField/RelatedProperties.php +++ b/modules/salesforce_mapping/src/Plugin/SalesforceMappingField/RelatedProperties.php @@ -8,6 +8,7 @@ use Drupal\field\Field; use Drupal\salesforce\Event\SalesforceErrorEvent; use Drupal\salesforce_mapping\Entity\SalesforceMappingInterface; use Drupal\salesforce_mapping\SalesforceMappingFieldPluginBase; +use Drupal\salesforce\Event\SalesforceEvents; /** * Adapter for entity Reference and fields. diff --git a/modules/salesforce_pull/src/DeleteHandler.php b/modules/salesforce_pull/src/DeleteHandler.php index dd46864296e471e2f7dea4a45781d8df48d7a03b..9ef44bc6ea9d01c167f00e576b25721162d10a0b 100644 --- a/modules/salesforce_pull/src/DeleteHandler.php +++ b/modules/salesforce_pull/src/DeleteHandler.php @@ -4,6 +4,8 @@ namespace Drupal\salesforce_pull; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\State\StateInterface; +use Drupal\salesforce\Event\SalesforceEvents; +use Drupal\salesforce\Event\SalesforceWarningEvent; use Drupal\salesforce\Event\SalesforceErrorEvent; use Drupal\salesforce\Event\SalesforceNoticeEvent; use Drupal\salesforce\Rest\RestClientInterface; @@ -154,7 +156,7 @@ class DeleteHandler { '%id' => $mapped_object->entity_id->value, '%sfid' => $record['id'], ]; - $this->eventDispatcher->dispatch((NULL, $message, $args)); + $this->eventDispatcher->dispatch(SalesforceEvents::NOTICE, new SalesforceNoticeEvent(NULL, $message, $args)); $mapped_object->delete(); return; } @@ -169,7 +171,7 @@ class DeleteHandler { '%id' => $mapped_object->id(), '%sfid' => $record['id'], ]; - $this->eventDispatcher->dispatch((NULL, $message, $args)); + $this->eventDispatcher->dispatch(SalesforceEvents::WARNING, new SalesforceWarningEvent(NULL, $message, $args)); // @TODO should we delete a mapped object whose parent mapping no longer exists? Feels like someone else's job. // $mapped_object->delete(); return; @@ -190,7 +192,7 @@ class DeleteHandler { '%id' => $mapped_object->entity_id, '%sfid' => $record['id'], ]; - $this->eventDispatcher->dispatch((NULL, $message, $args)); + $this->eventDispatcher->dispatch(SalesforceEvents::NOTICE, new SalesforceNoticeEvent(NULL, $message, $args)); } catch (\Exception $e) { $this->eventDispatcher->dispatch(SalesforceEvents::ERROR, new SalesforceErrorEvent($e)); diff --git a/modules/salesforce_pull/tests/src/Unit/DeleteHandlerTest.php b/modules/salesforce_pull/tests/src/Unit/DeleteHandlerTest.php index 3b418275676777e3d8f07a0e7a030587a1481a9b..eeabd9e21f424972261a95e7ce00469c749f84a6 100644 --- a/modules/salesforce_pull/tests/src/Unit/DeleteHandlerTest.php +++ b/modules/salesforce_pull/tests/src/Unit/DeleteHandlerTest.php @@ -52,6 +52,7 @@ class DeleteHandlerTest extends UnitTestCase { $prophecy = $this->prophesize(Entity::CLASS); $prophecy->delete()->willReturn(TRUE); $prophecy->id()->willReturn(1); + $prophecy->label()->willReturn('foo'); $this->entity = $prophecy->reveal(); $this->mapping = $this->getMock(SalesforceMappingInterface::CLASS); @@ -137,7 +138,7 @@ class DeleteHandlerTest extends UnitTestCase { // mock event dispatcher $prophecy = $this->prophesize(ContainerAwareEventDispatcher::CLASS); - $prophecy->dispatch(Argument::any())->willReturn(); + $prophecy->dispatch(Argument::any(), Argument::any())->willReturn(); $this->ed = $prophecy->reveal(); // Mock server. @@ -160,22 +161,14 @@ class DeleteHandlerTest extends UnitTestCase { } /** -<<<<<<< HEAD * Test object creation. -======= - * Test object instantiation. ->>>>>>> 8.x-3.x */ public function testObject() { $this->assertTrue($this->dh instanceof DeleteHandler); } /** -<<<<<<< HEAD * Test processDeletedRecords. -======= - * Test handler operation, good data. ->>>>>>> 8.x-3.x */ public function testGetUpdatedRecords() { $result = $this->dh->processDeletedRecords(); diff --git a/modules/salesforce_pull/tests/src/Unit/QueueHandlerTest.php b/modules/salesforce_pull/tests/src/Unit/QueueHandlerTest.php index a7a9e557f6e627a2f6f66ebd25d0e03d047a1d80..8f9d8916c6042df942ca7ade3be86252aab18806 100644 --- a/modules/salesforce_pull/tests/src/Unit/QueueHandlerTest.php +++ b/modules/salesforce_pull/tests/src/Unit/QueueHandlerTest.php @@ -90,7 +90,7 @@ class QueueHandlerTest extends UnitTestCase { // mock event dispatcher $prophecy = $this->prophesize(ContainerAwareEventDispatcher::CLASS); - $prophecy->dispatch(Argument::any())->willReturn(); + $prophecy->dispatch(Argument::any(), Argument::any())->willReturn(); $this->ed = $prophecy->reveal(); // mock server diff --git a/modules/salesforce_push/src/PushQueue.php b/modules/salesforce_push/src/PushQueue.php index c68212fb735375501f268c7666e3194172223d34..865526bb2d715caaf2d6d27b3ebbc92d67e88321 100644 --- a/modules/salesforce_push/src/PushQueue.php +++ b/modules/salesforce_push/src/PushQueue.php @@ -14,6 +14,7 @@ use Drupal\salesforce\EntityNotFoundException; use Drupal\salesforce\Event\SalesforceErrorEvent; use Drupal\salesforce\Event\SalesforceNoticeEvent; use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Drupal\salesforce\Event\SalesforceEvents; /** * Salesforce push queue. diff --git a/src/Form/AuthorizeForm.php b/src/Form/AuthorizeForm.php index 993456136b960e40aff16e6243d4b51e5090d6a7..0ceaaf6031122c2554fc980fa8c995d3be255f2d 100644 --- a/src/Form/AuthorizeForm.php +++ b/src/Form/AuthorizeForm.php @@ -11,6 +11,8 @@ use Drupal\salesforce\Rest\RestClientInterface; use GuzzleHttp\Exception\RequestException; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Drupal\salesforce\Event\SalesforceEvents; +use Drupal\salesforce\Event\SalesforceErrorEvent; /** * Creates authorization form for Salesforce.