diff --git a/modules/salesforce_address/salesforce_address.info.yml b/modules/salesforce_address/salesforce_address.info.yml index c5d0049428e74b6e00270b053d359dd2c8261531..8931430036efde8533f5ede31c00d175c81204b9 100644 --- a/modules/salesforce_address/salesforce_address.info.yml +++ b/modules/salesforce_address/salesforce_address.info.yml @@ -1,7 +1,7 @@ name: Salesforce Address type: module description: A custom Address Field Widget for Salesforce compatibility. -core_version_requirement: ^8.7.7 || ^9 +core_version_requirement: ^9.1 package: Salesforce dependencies: - address:address diff --git a/modules/salesforce_example/salesforce_example.info.yml b/modules/salesforce_example/salesforce_example.info.yml index 576c654b65b8eb8018d81ee210553b80860148de..d021e892902119657cdd275153a1e59cb4dc9248 100644 --- a/modules/salesforce_example/salesforce_example.info.yml +++ b/modules/salesforce_example/salesforce_example.info.yml @@ -1,7 +1,7 @@ name: Salesforce Example type: module description: Salesforce Examples -core_version_requirement: ^8.7.7 || ^9 +core_version_requirement: ^9.1 package: Salesforce dependencies: - salesforce:salesforce_push diff --git a/modules/salesforce_jwt/salesforce_jwt.info.yml b/modules/salesforce_jwt/salesforce_jwt.info.yml index 390e4ed9e9518cb90c69c825a5b65da301954f02..c9b7dc1593fa0e5a8b83017f978cad96f37d87bc 100644 --- a/modules/salesforce_jwt/salesforce_jwt.info.yml +++ b/modules/salesforce_jwt/salesforce_jwt.info.yml @@ -1,7 +1,7 @@ name: Salesforce JWT Auth Provider type: module description: Provides key-based Salesforce authentication. -core_version_requirement: ^8.7.7 || ^9 +core_version_requirement: ^9.1 package: Salesforce configure: salesforce.auth_config dependencies: diff --git a/modules/salesforce_logger/salesforce_logger.info.yml b/modules/salesforce_logger/salesforce_logger.info.yml index 2dc3e376adc5334b2cc6fbfbb83117142bc8d05d..b86658dffeec5dc2cdaf0f6691452f54d8e59ea4 100644 --- a/modules/salesforce_logger/salesforce_logger.info.yml +++ b/modules/salesforce_logger/salesforce_logger.info.yml @@ -1,7 +1,7 @@ name: Salesforce Logger type: module description: Consolidated logging for Salesforce Log events. -core_version_requirement: ^8.7.7 || ^9 +core_version_requirement: ^9.1 package: Salesforce configure: salesforce_logger.settings dependencies: diff --git a/modules/salesforce_mapping/salesforce_mapping.info.yml b/modules/salesforce_mapping/salesforce_mapping.info.yml index 4295447841d6160c49f1f615f9c1af6b5f6c053a..ffe53f7aefa6120da7bc964c782f4ab408898cdd 100644 --- a/modules/salesforce_mapping/salesforce_mapping.info.yml +++ b/modules/salesforce_mapping/salesforce_mapping.info.yml @@ -2,7 +2,7 @@ name: Salesforce Mapping type: module description: Map Drupal entities to Salesforce objects. package: Salesforce -core_version_requirement: ^8.7.7 || ^9 +core_version_requirement: ^9.1 dependencies: - salesforce:salesforce - dynamic_entity_reference:dynamic_entity_reference diff --git a/modules/salesforce_mapping/src/Entity/MappedObject.php b/modules/salesforce_mapping/src/Entity/MappedObject.php index a0171f05dd3d9396f95521f4e8d7352c3e22decd..630e7faf44c56d71800d561d3e6a39bca1867f02 100644 --- a/modules/salesforce_mapping/src/Entity/MappedObject.php +++ b/modules/salesforce_mapping/src/Entity/MappedObject.php @@ -395,8 +395,8 @@ class MappedObject extends RevisionableContentEntityBase implements MappedObject // Previously hook_salesforce_push_params_alter. $params = new PushParams($mapping, $drupal_entity); $this->eventDispatcher()->dispatch( - SalesforceEvents::PUSH_PARAMS, - new SalesforcePushParamsEvent($this, $params) + new SalesforcePushParamsEvent($this, $params), + SalesforceEvents::PUSH_PARAMS ); // @TODO is this the right place for this logic to live? @@ -449,8 +449,8 @@ class MappedObject extends RevisionableContentEntityBase implements MappedObject // Previously hook_salesforce_push_success. $this->eventDispatcher()->dispatch( - SalesforceEvents::PUSH_SUCCESS, - new SalesforcePushParamsEvent($this, $params) + new SalesforcePushParamsEvent($this, $params), + SalesforceEvents::PUSH_SUCCESS ); return $result; @@ -547,13 +547,14 @@ class MappedObject extends RevisionableContentEntityBase implements MappedObject '@sffield' => $field->config('salesforce_field'), '@sfid' => $this->sfid(), ]; - $this->eventDispatcher()->dispatch(SalesforceEvents::NOTICE, new SalesforceNoticeEvent($e, $message, $args)); + $this->eventDispatcher() + ->dispatch(new SalesforceNoticeEvent($e, $message, $args), SalesforceEvents::NOTICE); continue; } $this->eventDispatcher()->dispatch( - SalesforceEvents::PULL_ENTITY_VALUE, - new SalesforcePullEntityValueEvent($value, $field, $this) + new SalesforcePullEntityValueEvent($value, $field, $this), + SalesforceEvents::PULL_ENTITY_VALUE ); try { // If $value is TypedData, it should have been set during pullValue(). @@ -573,17 +574,17 @@ class MappedObject extends RevisionableContentEntityBase implements MappedObject '@did' => $drupal_entity->id(), '@v' => $value, ]; - $this->eventDispatcher()->dispatch(SalesforceEvents::WARNING, new SalesforceWarningEvent($e, $message, $args)); + $this->eventDispatcher()->dispatch(new SalesforceWarningEvent($e, $message, $args), SalesforceEvents::WARNING); continue; } } // @TODO: Event dispatching and entity saving should not be happening in this context, but inside a controller. This class needs to be more model-like. $this->eventDispatcher()->dispatch( - SalesforceEvents::PULL_PRESAVE, new SalesforcePullEvent($this, $drupal_entity->isNew() ? MappingConstants::SALESFORCE_MAPPING_SYNC_SF_CREATE - : MappingConstants::SALESFORCE_MAPPING_SYNC_SF_UPDATE) + : MappingConstants::SALESFORCE_MAPPING_SYNC_SF_UPDATE), + SalesforceEvents::PULL_PRESAVE ); // Set a flag here to indicate that a pull is happening, to avoid diff --git a/modules/salesforce_mapping/src/SalesforceMappingFieldPluginBase.php b/modules/salesforce_mapping/src/SalesforceMappingFieldPluginBase.php index 8319f888c2e9ff292abf6077b5bb745c7e4b842c..69f4b5d50e4c56751a0d939b804322f3f72f962e 100644 --- a/modules/salesforce_mapping/src/SalesforceMappingFieldPluginBase.php +++ b/modules/salesforce_mapping/src/SalesforceMappingFieldPluginBase.php @@ -189,7 +189,7 @@ abstract class SalesforceMappingFieldPluginBase extends PluginBase implements Sa $field_definition = $describe->getField($this->config('salesforce_field')); } catch (\Exception $e) { - $this->eventDispatcher->dispatch(SalesforceEvents::WARNING, new SalesforceWarningEvent($e, 'Field definition not found for %describe.%field', ['%describe' => $describe->getName(), '%field' => $this->config('salesforce_field')])); + $this->eventDispatcher->dispatch(new SalesforceWarningEvent($e, 'Field definition not found for %describe.%field', ['%describe' => $describe->getName(), '%field' => $this->config('salesforce_field')]), SalesforceEvents::WARNING); // If getField throws, however, just return the raw value. return $value; } diff --git a/modules/salesforce_mapping/tests/src/Functional/PushParamsTest.php b/modules/salesforce_mapping/tests/src/Functional/PushParamsTest.php index 87bd0bfa62011b50ca67e5f926fd1c61d78bec08..55eac14e4a19bb56009baf3118217203dae232ca 100644 --- a/modules/salesforce_mapping/tests/src/Functional/PushParamsTest.php +++ b/modules/salesforce_mapping/tests/src/Functional/PushParamsTest.php @@ -30,7 +30,7 @@ class PushParamsTest extends BrowserTestBase { * * @var array */ - public static $modules = [ + protected static $modules = [ 'typed_data', 'dynamic_entity_reference', 'salesforce_mapping', diff --git a/modules/salesforce_mapping/tests/src/Unit/MappedObjectTest.php b/modules/salesforce_mapping/tests/src/Unit/MappedObjectTest.php index 6ceca2244ab057b80e6c1485322f32dde2df0215..3622aeb3568ba93fc40306409e1bd0f1dad00693 100644 --- a/modules/salesforce_mapping/tests/src/Unit/MappedObjectTest.php +++ b/modules/salesforce_mapping/tests/src/Unit/MappedObjectTest.php @@ -30,12 +30,12 @@ class MappedObjectTest extends UnitTestCase { * * @var array */ - static public $modules = ['salesforce_mapping']; + static protected $modules = ['salesforce_mapping']; /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->entityTypeId = $this->randomMachineName(); diff --git a/modules/salesforce_mapping/tests/src/Unit/SalesforceMappingStorageTest.php b/modules/salesforce_mapping/tests/src/Unit/SalesforceMappingStorageTest.php index 2485b3522146b12f860b80294f465c6c1b9c92ce..c6c3621bb2e48bb3375ad10aa43543f4dfce0495 100644 --- a/modules/salesforce_mapping/tests/src/Unit/SalesforceMappingStorageTest.php +++ b/modules/salesforce_mapping/tests/src/Unit/SalesforceMappingStorageTest.php @@ -72,7 +72,7 @@ class SalesforceMappingStorageTest extends UnitTestCase { * * @covers ::__construct */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->entityTypeId = 'test_entity_type'; diff --git a/modules/salesforce_mapping/tests/src/Unit/SalesforceMappingTest.php b/modules/salesforce_mapping/tests/src/Unit/SalesforceMappingTest.php index fd8697861d0f703010c9cbcac5117af86cbad992..0ae99397189d7798e348c3d15a27252d5ffd1e27 100644 --- a/modules/salesforce_mapping/tests/src/Unit/SalesforceMappingTest.php +++ b/modules/salesforce_mapping/tests/src/Unit/SalesforceMappingTest.php @@ -26,12 +26,12 @@ class SalesforceMappingTest extends UnitTestCase { * * @var array */ - static public $modules = ['salesforce_mapping']; + static protected $modules = ['salesforce_mapping']; /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->id = $this->randomMachineName(); @@ -168,9 +168,15 @@ class SalesforceMappingTest extends UnitTestCase { $expectedQuery->fields[] = 'Id'; $expectedQuery->fields[] = $this->mapping->getPullTriggerDate(); $expectedQuery->order[$this->mapping->getPullTriggerDate()] = 'ASC'; - $this->assertArrayEquals($expectedQuery->fields, $query->fields); - $this->assertArrayEquals($expectedQuery->order, $query->order); - $this->assertArrayEquals($expectedQuery->conditions, $query->conditions); + ksort($expectedQuery->fields); + ksort($query->fields); + $this->assertEquals($expectedQuery->fields, $query->fields); + ksort($expectedQuery->order); + ksort($query->order); + $this->assertEquals($expectedQuery->order, $query->order); + ksort($expectedQuery->conditions); + ksort($query->conditions); + $this->assertEquals($expectedQuery->conditions, $query->conditions); $this->assertEquals($expectedQuery->objectType, $query->objectType); $this->assertEquals($expectedQuery->limit, $query->limit); } diff --git a/modules/salesforce_mapping_ui/salesforce_mapping_ui.info.yml b/modules/salesforce_mapping_ui/salesforce_mapping_ui.info.yml index 3c932ced7542fc97c450b479a1b26e7030b7c08a..2f9dfe4af2d08817d2722b22062241f61e151cdc 100644 --- a/modules/salesforce_mapping_ui/salesforce_mapping_ui.info.yml +++ b/modules/salesforce_mapping_ui/salesforce_mapping_ui.info.yml @@ -2,7 +2,7 @@ name: Salesforce Mapping UI type: module description: User interface for managing Salesforce mappings. package: Salesforce -core_version_requirement: ^8.7.7 || ^9 +core_version_requirement: ^9.1 configure: entity.salesforce_mapping.list dependencies: - salesforce:salesforce_mapping diff --git a/modules/salesforce_mapping_ui/src/Form/MappedObjectDeleteForm.php b/modules/salesforce_mapping_ui/src/Form/MappedObjectDeleteForm.php index 07754326dbf3586fc433edfc4221792dd9493b02..73df4480640064d18e9fdd08058cd196570635b9 100644 --- a/modules/salesforce_mapping_ui/src/Form/MappedObjectDeleteForm.php +++ b/modules/salesforce_mapping_ui/src/Form/MappedObjectDeleteForm.php @@ -48,7 +48,7 @@ class MappedObjectDeleteForm extends ContentEntityConfirmFormBase { $form_state->setRedirectUrl($mapped_object->getMappedEntity()->toUrl()); $message = 'MappedObject @sfid deleted.'; $args = ['@sfid' => $mapped_object->salesforce_id->value]; - \Drupal::service('event_dispatcher')->dispatch(SalesforceEvents::NOTICE, new SalesforceNoticeEvent(NULL, $message, $args)); + \Drupal::service('event_dispatcher')->dispatch(new SalesforceNoticeEvent(NULL, $message, $args), SalesforceEvents::NOTICE); $mapped_object->delete(); } diff --git a/modules/salesforce_mapping_ui/src/Form/MappedObjectForm.php b/modules/salesforce_mapping_ui/src/Form/MappedObjectForm.php index d05c804b34205ffb07f983154b5c823b207697a3..0933c70767bdbdddc0fab30335e2eeb82fc3c5e7 100644 --- a/modules/salesforce_mapping_ui/src/Form/MappedObjectForm.php +++ b/modules/salesforce_mapping_ui/src/Form/MappedObjectForm.php @@ -197,7 +197,7 @@ class MappedObjectForm extends ContentEntityForm { } catch (\Exception $e) { $mapped_object->delete(); - $this->eventDispatcher->dispatch(SalesforceEvents::ERROR, new SalesforceErrorEvent($e)); + $this->eventDispatcher->dispatch(new SalesforceErrorEvent($e), SalesforceEvents::ERROR); $this->messenger()->addError($this->t('Push failed with an exception: %exception', ['%exception' => $e->getMessage()])); $form_state->setRebuild(); return; @@ -239,7 +239,7 @@ class MappedObjectForm extends ContentEntityForm { $mapped_object->pull(); } catch (\Exception $e) { - $this->eventDispatcher->dispatch(SalesforceEvents::ERROR, new SalesforceErrorEvent($e)); + $this->eventDispatcher->dispatch(new SalesforceErrorEvent($e), SalesforceEvents::ERROR); $this->messenger()->addError($this->t('Pull failed with an exception: %exception', ['%exception' => $e->getMessage()])); $form_state->setRebuild(); return; diff --git a/modules/salesforce_mapping_ui/src/Form/SalesforceMappingFormCrudBase.php b/modules/salesforce_mapping_ui/src/Form/SalesforceMappingFormCrudBase.php index a4fbc1fcf7f268d8d534a1474a52f416a083a7ef..97152ad2d486cc96a1a44fa430734499f01b27f9 100644 --- a/modules/salesforce_mapping_ui/src/Form/SalesforceMappingFormCrudBase.php +++ b/modules/salesforce_mapping_ui/src/Form/SalesforceMappingFormCrudBase.php @@ -384,7 +384,7 @@ abstract class SalesforceMappingFormCrudBase extends SalesforceMappingFormBase { } catch (\Exception $e) { $form_state->setError($form['pull']['pull_where_clause'], $this->t('Test pull query returned an error. Please check logs for error details.')); - \Drupal::service('event_dispatcher')->dispatch(SalesforceEvents::ERROR, new SalesforceErrorEvent($e)); + \Drupal::service('event_dispatcher')->dispatch(new SalesforceErrorEvent($e), SalesforceEvents::ERROR); } } } diff --git a/modules/salesforce_mapping_ui/src/Tests/SalesforceMappingCrudFormTest.php b/modules/salesforce_mapping_ui/src/Tests/SalesforceMappingCrudFormTest.php index c83d28417e1ec09e49488290739b151f8ebb56f3..b5142749efcc8438dde3be1bd06867df747a7af1 100644 --- a/modules/salesforce_mapping_ui/src/Tests/SalesforceMappingCrudFormTest.php +++ b/modules/salesforce_mapping_ui/src/Tests/SalesforceMappingCrudFormTest.php @@ -48,7 +48,7 @@ class SalesforceMappingCrudFormTest extends BrowserTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); // Admin salesforce user. @@ -77,8 +77,8 @@ class SalesforceMappingCrudFormTest extends BrowserTestBase { $mapping = $mappingStorage->load($mapping_name); // Make sure mapping was saved correctly. - $this->assertEqual($mapping->id(), $mapping_name); - $this->assertEqual($mapping->label(), $mapping_name); + $this->assertEquals($mapping->id(), $mapping_name); + $this->assertEquals($mapping->label(), $mapping_name); /* Salesforce Mapping Edit Form */ // Need to rebuild caches before proceeding to edit link. @@ -90,7 +90,7 @@ class SalesforceMappingCrudFormTest extends BrowserTestBase { 'salesforce_object_type' => 'Contact', ]; $this->drupalPostForm('admin/structure/salesforce/mappings/manage/' . $mapping_name, $post, $this->t('Save')); - $this->assertFieldByName('label', $post['label']); + $this->assertSession()->fieldValueEquals('label', $post['label']); // Test simply adding a field plugin of every possible type. This is not // great coverage, but will at least make sure our plugin definitions don't @@ -107,14 +107,14 @@ class SalesforceMappingCrudFormTest extends BrowserTestBase { $post['buttons[field_type]'] = $definition['id']; $this->drupalPostForm(NULL, $post, $this->t('Add a field mapping to get started')); // Confirm that the new field shows up: - $this->assertText($definition['label']); + $this->assertSession()->pageTextContains($definition['label']); // @TODO need an interface for field plugins that will tell us which config values are applicable. // Add all components of this field plugin to our post array to build up the mapping. - $this->assertElementPresent("[name='field_mappings[$i][config][drupal_field_value]'], [name='field_mappings[$i][config][drupal_field_value][setting]']"); - $this->assertElementPresent("[name='field_mappings[$i][config][salesforce_field]'], [name='field_mappings[$i][config][drupal_constant]']"); - $this->assertField("field_mappings[$i][config][description]"); - $this->assertField("field_mappings[$i][config][direction]"); + $this->assertSession()->elementExists('css', "[name='field_mappings[$i][config][drupal_field_value]'], [name='field_mappings[$i][config][drupal_field_value][setting]']"); + $this->assertSession()->elementExists('css', "[name='field_mappings[$i][config][salesforce_field]'], [name='field_mappings[$i][config][drupal_constant]']"); + $this->assertSession()->fieldExists("field_mappings[$i][config][description]"); + $this->assertSession()->fieldExists("field_mappings[$i][config][direction]"); $this->assertSession()->hiddenFieldExists("field_mappings[$i][drupal_field_type]"); if ($this->getSession()->getPage()->find('css', "select[name='field_mappings[$i][config][salesforce_field]'] option[value='LastName']")) { $post["field_mappings[$i][config][salesforce_field]"] = 'LastName'; diff --git a/modules/salesforce_oauth/salesforce_oauth.info.yml b/modules/salesforce_oauth/salesforce_oauth.info.yml index 74987b349be508749e486fe4c8ef5ba0bc75c7d9..a8c15b9a5b26cd19aabe6d39ac76d25edbd72fd2 100644 --- a/modules/salesforce_oauth/salesforce_oauth.info.yml +++ b/modules/salesforce_oauth/salesforce_oauth.info.yml @@ -1,7 +1,7 @@ name: Salesforce OAuth user-agent Provider type: module description: Provides user-agent-based Salesforce OAuth authentication. -core_version_requirement: ^8.7.7 || ^9 +core_version_requirement: ^9.1 package: Salesforce configure: salesforce.auth_config dependencies: diff --git a/modules/salesforce_pull/salesforce_pull.drush.inc b/modules/salesforce_pull/salesforce_pull.drush.inc index 64a1efd4f950990bf169b270c0cb83d64a7578e2..067e49b04657d89a7a3e62eeb30ca14c2721da66 100644 --- a/modules/salesforce_pull/salesforce_pull.drush.inc +++ b/modules/salesforce_pull/salesforce_pull.drush.inc @@ -125,8 +125,8 @@ function drush_salesforce_pull_sf_pull_query($name) { } \Drupal::service('event_dispatcher')->dispatch( - SalesforceEvents::PULL_QUERY, - new SalesforceQueryEvent($mapping, $soql) + new SalesforceQueryEvent($mapping, $soql), + SalesforceEvents::PULL_QUERY ); drush_log(dt('!mapping: Issuing pull query: !query', ['!query' => (string) $soql, '!mapping' => $mapping->id()]), 'notice'); @@ -231,8 +231,8 @@ function drush_salesforce_pull_sf_pull_file($file, $name = NULL) { foreach ($queries as $soql) { \Drupal::service('event_dispatcher')->dispatch( - SalesforceEvents::PULL_QUERY, - new SalesforceQueryEvent($mapping, $soql) + new SalesforceQueryEvent($mapping, $soql), + SalesforceEvents::PULL_QUERY ); drush_log(dt('Issuing pull query: !query', ['!query' => (string) $soql])); diff --git a/modules/salesforce_pull/salesforce_pull.info.yml b/modules/salesforce_pull/salesforce_pull.info.yml index ed75a8d62626ba9ec0f6295c2a9ed4405768e76d..5b49712314e2da21713181ec72456aa4fd85d271 100644 --- a/modules/salesforce_pull/salesforce_pull.info.yml +++ b/modules/salesforce_pull/salesforce_pull.info.yml @@ -2,6 +2,6 @@ name: Salesforce Pull type: module description: Imports objects from Salesforce based on mappings defined in Salesforce Mapping. package: Salesforce -core_version_requirement: ^8.7.7 || ^9 +core_version_requirement: ^9.1 dependencies: - salesforce:salesforce_mapping diff --git a/modules/salesforce_pull/src/Commands/SalesforcePullCommands.php b/modules/salesforce_pull/src/Commands/SalesforcePullCommands.php index 675d37a7d4142f364c7e1a6a0b6999981bcfd51d..9d62425c6c4c871b490a16458796404a14ef9f86 100644 --- a/modules/salesforce_pull/src/Commands/SalesforcePullCommands.php +++ b/modules/salesforce_pull/src/Commands/SalesforcePullCommands.php @@ -183,8 +183,8 @@ class SalesforcePullCommands extends SalesforceMappingCommandsBase { } $this->eventDispatcher->dispatch( - SalesforceEvents::PULL_QUERY, - new SalesforceQueryEvent($mapping, $soql) + new SalesforceQueryEvent($mapping, $soql), + SalesforceEvents::PULL_QUERY ); $this->logger()->info(dt('!mapping: Issuing pull query: !query', [ @@ -290,8 +290,8 @@ class SalesforcePullCommands extends SalesforceMappingCommandsBase { foreach ($queries as $soql) { $this->eventDispatcher->dispatch( - SalesforceEvents::PULL_QUERY, - new SalesforceQueryEvent($mapping, $soql) + new SalesforceQueryEvent($mapping, $soql), + SalesforceEvents::PULL_QUERY ); $this->logger()->info(dt('Issuing pull query: !query', ['!query' => (string) $soql])); diff --git a/modules/salesforce_pull/src/Controller/PullController.php b/modules/salesforce_pull/src/Controller/PullController.php index ae2ff4b316ca5202450ba5cf4386eb29ff24c12a..20884110692ccdb77077cbb7ebe50367432f585b 100644 --- a/modules/salesforce_pull/src/Controller/PullController.php +++ b/modules/salesforce_pull/src/Controller/PullController.php @@ -195,7 +195,7 @@ class PullController extends ControllerBase { $count = 0; while ((!$this->getTimeLimit() || time() < $end) && ($item = $queue->claimItem())) { try { - $this->eventDispatcher->dispatch(SalesforceEvents::NOTICE, new SalesforceNoticeEvent(NULL, 'Processing item @id from @name queue.', ['@name' => QueueHandler::PULL_QUEUE_NAME, '@id' => $item->item_id])); + $this->eventDispatcher->dispatch(new SalesforceNoticeEvent(NULL, 'Processing item @id from @name queue.', ['@name' => QueueHandler::PULL_QUEUE_NAME, '@id' => $item->item_id]), SalesforceEvents::NOTICE); $worker->processItem($item->data); $queue->deleteItem($item); $count++; @@ -212,11 +212,11 @@ class PullController extends ControllerBase { } } $elapsed = microtime(TRUE) - $start; - $this->eventDispatcher->dispatch(SalesforceEvents::NOTICE, new SalesforceNoticeEvent(NULL, 'Processed @count items from the @name queue in @elapsed sec.', [ + $this->eventDispatcher->dispatch(new SalesforceNoticeEvent(NULL, 'Processed @count items from the @name queue in @elapsed sec.', [ '@count' => $count, '@name' => QueueHandler::PULL_QUEUE_NAME, '@elapsed' => round($elapsed, 2), - ])); + ]), SalesforceEvents::NOTICE); } } diff --git a/modules/salesforce_pull/src/DeleteHandler.php b/modules/salesforce_pull/src/DeleteHandler.php index 2b1ef837f2a30433421cfe30061d3008c4078b79..1fe0df0a5f86333e13ec6f53d28419dae22dd36d 100644 --- a/modules/salesforce_pull/src/DeleteHandler.php +++ b/modules/salesforce_pull/src/DeleteHandler.php @@ -180,7 +180,7 @@ class DeleteHandler { '%id' => $mapped_object->entity_id->value, '%sfid' => $record['id'], ]; - $this->eventDispatcher->dispatch(SalesforceEvents::NOTICE, new SalesforceNoticeEvent(NULL, $message, $args)); + $this->eventDispatcher->dispatch(new SalesforceNoticeEvent(NULL, $message, $args), SalesforceEvents::NOTICE); $mapped_object->delete(); return; } @@ -194,7 +194,7 @@ class DeleteHandler { '%id' => $mapped_object->id(), '%sfid' => $record['id'], ]; - $this->eventDispatcher->dispatch(SalesforceEvents::WARNING, new SalesforceWarningEvent(NULL, $message, $args)); + $this->eventDispatcher->dispatch(new SalesforceWarningEvent(NULL, $message, $args), SalesforceEvents::WARNING); // @TODO should we delete a mapped object whose parent mapping no longer exists? Feels like someone else's job. // $mapped_object->delete(); return; @@ -206,7 +206,7 @@ class DeleteHandler { // Before attempting the final delete, give other modules a chance to disallow it. $deleteAllowedEvent = new SalesforceDeleteAllowedEvent($mapped_object); - $this->eventDispatcher->dispatch(SalesforceEvents::DELETE_ALLOWED, $deleteAllowedEvent); + $this->eventDispatcher->dispatch($deleteAllowedEvent, SalesforceEvents::DELETE_ALLOWED); if ($deleteAllowedEvent->isDeleteAllowed() === FALSE) { return; } @@ -222,10 +222,10 @@ class DeleteHandler { '%id' => $mapped_object->entity_id, '%sfid' => $record['id'], ]; - $this->eventDispatcher->dispatch(SalesforceEvents::NOTICE, new SalesforceNoticeEvent(NULL, $message, $args)); + $this->eventDispatcher->dispatch(new SalesforceNoticeEvent(NULL, $message, $args), SalesforceEvents::NOTICE); } catch (\Exception $e) { - $this->eventDispatcher->dispatch(SalesforceEvents::ERROR, new SalesforceErrorEvent($e)); + $this->eventDispatcher->dispatch(new SalesforceErrorEvent($e), SalesforceEvents::ERROR); // If mapped entity couldn't be deleted, do not delete the mapped // object. return; diff --git a/modules/salesforce_pull/src/Plugin/QueueWorker/PullBase.php b/modules/salesforce_pull/src/Plugin/QueueWorker/PullBase.php index e7d7955f716fbeec46a05964417759dde376deae..12231db35810a2334a8b607dadc11c98fd70b668 100644 --- a/modules/salesforce_pull/src/Plugin/QueueWorker/PullBase.php +++ b/modules/salesforce_pull/src/Plugin/QueueWorker/PullBase.php @@ -157,7 +157,7 @@ abstract class PullBase extends QueueWorkerBase implements ContainerFactoryPlugi try { $entity = $mapped_object->getMappedEntity(); if (!$entity) { - $this->eventDispatcher->dispatch(SalesforceEvents::ERROR, new SalesforceErrorEvent(NULL, 'Drupal entity existed at one time for Salesforce object %sfobjectid, but does not currently exist.', ['%sfobjectid' => (string) $sf_object->id()])); + $this->eventDispatcher->dispatch(new SalesforceErrorEvent(NULL, 'Drupal entity existed at one time for Salesforce object %sfobjectid, but does not currently exist.', ['%sfobjectid' => (string) $sf_object->id()]), SalesforceEvents::ERROR); return; } @@ -188,8 +188,7 @@ abstract class PullBase extends QueueWorkerBase implements ContainerFactoryPlugi ) { $params = new PushParams($mapping, $entity); $this->eventDispatcher->dispatch( - SalesforceEvents::PUSH_PARAMS, - new SalesforcePushParamsEvent($mapped_object, $params) + new SalesforcePushParamsEvent($mapped_object, $params), SalesforceEvents::PUSH_PARAMS ); // Get just the key param and send that. $key_field = $mapping->getKeyField(); @@ -205,23 +204,22 @@ abstract class PullBase extends QueueWorkerBase implements ContainerFactoryPlugi } $event = $this->eventDispatcher->dispatch( - SalesforceEvents::PULL_PREPULL, - new SalesforcePullEvent($mapped_object, MappingConstants::SALESFORCE_MAPPING_SYNC_SF_UPDATE) + new SalesforcePullEvent($mapped_object, MappingConstants::SALESFORCE_MAPPING_SYNC_SF_UPDATE), SalesforceEvents::PULL_PREPULL ); if (!$event->isPullAllowed()) { - $this->eventDispatcher->dispatch(SalesforceEvents::NOTICE, new SalesforceNoticeEvent(NULL, 'Pull was not allowed for %label with %sfid', ['%label' => $entity->label(), '%sfid' => (string) $sf_object->id()])); + $this->eventDispatcher->dispatch(new SalesforceNoticeEvent(NULL, 'Pull was not allowed for %label with %sfid', ['%label' => $entity->label(), '%sfid' => (string) $sf_object->id()]), SalesforceEvents::NOTICE); return FALSE; } if ($sf_record_updated > $entity_updated || $mapped_object->force_pull || $force_pull) { // Set fields values on the Drupal entity. $mapped_object->pull(); - $this->eventDispatcher->dispatch(SalesforceEvents::NOTICE, new SalesforceNoticeEvent(NULL, 'Updated entity %label associated with Salesforce Object ID: %sfid', ['%label' => $entity->label(), '%sfid' => (string) $sf_object->id()])); + $this->eventDispatcher->dispatch(new SalesforceNoticeEvent(NULL, 'Updated entity %label associated with Salesforce Object ID: %sfid', ['%label' => $entity->label(), '%sfid' => (string) $sf_object->id()]), SalesforceEvents::NOTICE); return MappingConstants::SALESFORCE_MAPPING_SYNC_SF_UPDATE; } } catch (\Exception $e) { - $this->eventDispatcher->dispatch(SalesforceEvents::WARNING, new SalesforceErrorEvent($e, 'Failed to update entity %label from Salesforce object %sfobjectid.', ['%label' => (isset($entity)) ? $entity->label() : "Unknown", '%sfobjectid' => (string) $sf_object->id()])); + $this->eventDispatcher->dispatch(new SalesforceErrorEvent($e, 'Failed to update entity %label from Salesforce object %sfobjectid.', ['%label' => (isset($entity)) ? $entity->label() : "Unknown", '%sfobjectid' => (string) $sf_object->id()]), SalesforceEvents::WARNING); // Throwing a new exception keeps current item in cron queue. throw $e; } @@ -277,11 +275,10 @@ abstract class PullBase extends QueueWorkerBase implements ContainerFactoryPlugi ->setSalesforceRecord($sf_object); $event = $this->eventDispatcher->dispatch( - SalesforceEvents::PULL_PREPULL, - new SalesforcePullEvent($mapped_object, MappingConstants::SALESFORCE_MAPPING_SYNC_SF_CREATE) + new SalesforcePullEvent($mapped_object, MappingConstants::SALESFORCE_MAPPING_SYNC_SF_CREATE), SalesforceEvents::PULL_PREPULL ); if (!$event->isPullAllowed()) { - $this->eventDispatcher->dispatch(SalesforceEvents::NOTICE, new SalesforceNoticeEvent(NULL, 'Pull was not allowed for %label with %sfid', ['%label' => $entity->label(), '%sfid' => (string) $sf_object->id()])); + $this->eventDispatcher->dispatch(new SalesforceNoticeEvent(NULL, 'Pull was not allowed for %label with %sfid', ['%label' => $entity->label(), '%sfid' => (string) $sf_object->id()]), SalesforceEvents::NOTICE); return FALSE; } @@ -294,8 +291,8 @@ abstract class PullBase extends QueueWorkerBase implements ContainerFactoryPlugi ]) && $sf_object->field($mapping->getKeyField()) === NULL) { $params = new PushParams($mapping, $entity); $this->eventDispatcher->dispatch( - SalesforceEvents::PUSH_PARAMS, - new SalesforcePushParamsEvent($mapped_object, $params) + new SalesforcePushParamsEvent($mapped_object, $params), + SalesforceEvents::PUSH_PARAMS ); // Get just the key param and send that. $key_field = $mapping->getKeyField(); @@ -310,16 +307,16 @@ abstract class PullBase extends QueueWorkerBase implements ContainerFactoryPlugi } } - $this->eventDispatcher->dispatch(SalesforceEvents::NOTICE, new SalesforceNoticeEvent(NULL, 'Created entity %id %label associated with Salesforce Object ID: %sfid', [ + $this->eventDispatcher->dispatch(new SalesforceNoticeEvent(NULL, 'Created entity %id %label associated with Salesforce Object ID: %sfid', [ '%id' => $entity->id(), '%label' => $entity->label(), '%sfid' => (string) $sf_object->id(), - ])); + ]), SalesforceEvents::NOTICE); return MappingConstants::SALESFORCE_MAPPING_SYNC_SF_CREATE; } catch (\Exception $e) { - $this->eventDispatcher->dispatch(SalesforceEvents::WARNING, new SalesforceNoticeEvent($e, 'Pull-create failed for Salesforce Object ID: %sfobjectid', ['%sfobjectid' => (string) $sf_object->id()])); + $this->eventDispatcher->dispatch(new SalesforceNoticeEvent($e, 'Pull-create failed for Salesforce Object ID: %sfobjectid', ['%sfobjectid' => (string) $sf_object->id()]), SalesforceEvents::WARNING); // Throwing a new exception to keep current item in cron queue. throw $e; } @@ -344,7 +341,7 @@ abstract class PullBase extends QueueWorkerBase implements ContainerFactoryPlugi return TRUE; } catch (RestException $e) { - $this->eventDispatcher->dispatch(SalesforceEvents::ERROR, new SalesforceErrorEvent($e)); + $this->eventDispatcher->dispatch(new SalesforceErrorEvent($e), SalesforceEvents::ERROR); return FALSE; } } diff --git a/modules/salesforce_pull/src/QueueHandler.php b/modules/salesforce_pull/src/QueueHandler.php index 099b0c88a3e3a21edc87901fedf669ad3a3465ce..1b49d3d1c32a455b243c3cca50c50a8c978043bb 100644 --- a/modules/salesforce_pull/src/QueueHandler.php +++ b/modules/salesforce_pull/src/QueueHandler.php @@ -127,7 +127,7 @@ class QueueHandler { '%noi' => $this->queue->numberOfItems(), '%max' => $max_size, ]; - $this->eventDispatcher->dispatch(SalesforceEvents::NOTICE, new SalesforceNoticeEvent(NULL, $message, $args)); + $this->eventDispatcher->dispatch(new SalesforceNoticeEvent(NULL, $message, $args), SalesforceEvents::NOTICE); return FALSE; } @@ -229,15 +229,15 @@ class QueueHandler { try { $soql = $mapping->getPullQuery($mapped_fields, $start, $stop); $this->eventDispatcher->dispatch( - SalesforceEvents::PULL_QUERY, - new SalesforceQueryEvent($mapping, $soql) + new SalesforceQueryEvent($mapping, $soql), + SalesforceEvents::PULL_QUERY ); return $this->sfapi->query($soql); } catch (\Exception $e) { $message = '%type: @message in %function (line %line of %file).'; $args = Error::decodeException($e); - $this->eventDispatcher->dispatch(SalesforceEvents::ERROR, new SalesforceErrorEvent($e, $message, $args)); + $this->eventDispatcher->dispatch(new SalesforceErrorEvent($e, $message, $args), SalesforceEvents::ERROR); } } @@ -259,7 +259,7 @@ class QueueHandler { catch (\Exception $e) { $message = '%type: @message in %function (line %line of %file).'; $args = Error::decodeException($e); - $this->eventDispatcher->dispatch(SalesforceEvents::ERROR, new SalesforceErrorEvent($e, $message, $args)); + $this->eventDispatcher->dispatch(new SalesforceErrorEvent($e, $message, $args), SalesforceEvents::ERROR); // @TODO do we really want to eat this exception here? return; } @@ -298,7 +298,7 @@ class QueueHandler { catch (\Exception $e) { $message = '%type: @message in %function (line %line of %file).'; $args = Error::decodeException($e); - $this->eventDispatcher->dispatch(SalesforceEvents::ERROR, new SalesforceErrorEvent($e, $message, $args)); + $this->eventDispatcher->dispatch(new SalesforceErrorEvent($e, $message, $args), SalesforceEvents::ERROR); } } diff --git a/modules/salesforce_pull/tests/src/Functional/PullQueueTest.php b/modules/salesforce_pull/tests/src/Functional/PullQueueTest.php index 4e36948fd190c8223ce147fb5cc7e5b5d71f06e0..a388627a75b46b7cf634505eef68bd2a31d9cc28 100644 --- a/modules/salesforce_pull/tests/src/Functional/PullQueueTest.php +++ b/modules/salesforce_pull/tests/src/Functional/PullQueueTest.php @@ -26,7 +26,7 @@ class PullQueueTest extends BrowserTestBase { * * @var array */ - public static $modules = [ + protected static $modules = [ 'typed_data', 'dynamic_entity_reference', 'salesforce_mapping', diff --git a/modules/salesforce_pull/tests/src/Unit/DeleteHandlerTest.php b/modules/salesforce_pull/tests/src/Unit/DeleteHandlerTest.php index 7465e17ea8396fabd019e03d6e92cf38e6878f32..cf531814c259ca802d4c22f1168601030131bc55 100644 --- a/modules/salesforce_pull/tests/src/Unit/DeleteHandlerTest.php +++ b/modules/salesforce_pull/tests/src/Unit/DeleteHandlerTest.php @@ -34,7 +34,7 @@ class DeleteHandlerTest extends UnitTestCase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $result = [ 'totalSize' => 1, diff --git a/modules/salesforce_pull/tests/src/Unit/PullBaseTest.php b/modules/salesforce_pull/tests/src/Unit/PullBaseTest.php index 424aa048e12ee1a6f53eb651066a943487e2d4b3..497760d32d19e229420f2ff70d6e32ba792b69ba 100644 --- a/modules/salesforce_pull/tests/src/Unit/PullBaseTest.php +++ b/modules/salesforce_pull/tests/src/Unit/PullBaseTest.php @@ -35,12 +35,12 @@ class PullBaseTest extends UnitTestCase { * * @var array */ - public static $modules = ['salesforce_pull']; + protected static $modules = ['salesforce_pull']; /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->salesforce_id = '1234567890abcde'; diff --git a/modules/salesforce_pull/tests/src/Unit/PullQueueItemTest.php b/modules/salesforce_pull/tests/src/Unit/PullQueueItemTest.php index eb2440ec4c5543d6b3a2f46342c6bfdc94affa93..6cd4999a3250846cc1c07d728389b43579f135af 100644 --- a/modules/salesforce_pull/tests/src/Unit/PullQueueItemTest.php +++ b/modules/salesforce_pull/tests/src/Unit/PullQueueItemTest.php @@ -19,7 +19,7 @@ class PullQueueItemTest extends UnitTestCase { * * @var array */ - public static $modules = ['salesforce_pull']; + protected static $modules = ['salesforce_pull']; /** * Test object instantiation. diff --git a/modules/salesforce_pull/tests/src/Unit/QueueHandlerTest.php b/modules/salesforce_pull/tests/src/Unit/QueueHandlerTest.php index 1ca66fa275af4646ce167573fdbe67629ca9f62f..08667a88721cbce44274df216e6a8db9ff621756 100644 --- a/modules/salesforce_pull/tests/src/Unit/QueueHandlerTest.php +++ b/modules/salesforce_pull/tests/src/Unit/QueueHandlerTest.php @@ -31,12 +31,12 @@ class QueueHandlerTest extends UnitTestCase { * * @var array */ - static public $modules = ['salesforce_pull']; + static protected $modules = ['salesforce_pull']; /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $result = [ 'totalSize' => 1, diff --git a/modules/salesforce_push/salesforce_push.info.yml b/modules/salesforce_push/salesforce_push.info.yml index 8d078134ce0b01bd009dd9df461b6f7021070e4e..1f476102fb8e623b5acbf1a72b27c67acf1fd116 100644 --- a/modules/salesforce_push/salesforce_push.info.yml +++ b/modules/salesforce_push/salesforce_push.info.yml @@ -2,6 +2,6 @@ name: Salesforce Push type: module description: Push data to Salesforce when updates are made to Drupal entities. package: Salesforce -core_version_requirement: ^8.7.7 || ^9 +core_version_requirement: ^9.1 dependencies: - salesforce:salesforce_mapping diff --git a/modules/salesforce_push/salesforce_push.module b/modules/salesforce_push/salesforce_push.module index 4e1e2868826060d666de0616371e98d576a10f4a..90d9a444c1ab4ee3fe58bc4386c637402fec5bdb 100644 --- a/modules/salesforce_push/salesforce_push.module +++ b/modules/salesforce_push/salesforce_push.module @@ -85,7 +85,7 @@ function salesforce_push_entity_crud(EntityInterface $entity, $op) { } catch (\Exception $e) { // Do not allow any exception to prevent entity CRUD. - \Drupal::service('event_dispatcher')->dispatch(SalesforceEvents::ERROR, new SalesforceErrorEvent($e)); + \Drupal::service('event_dispatcher')->dispatch(new SalesforceErrorEvent($e), SalesforceEvents::ERROR); } } } @@ -138,8 +138,8 @@ function salesforce_push_entity_crud_mapping(EntityInterface $entity, $op, Sales // Event subscribers should call $event->disallowPush() to prevent push. $event = \Drupal::service('event_dispatcher')->dispatch( - SalesforceEvents::PUSH_ALLOWED, - new SalesforcePushAllowedEvent($mapped_object, $op) + new SalesforcePushAllowedEvent($mapped_object, $op), + SalesforceEvents::PUSH_ALLOWED ); if ($event->isPushAllowed() === FALSE) { return; @@ -151,7 +151,7 @@ function salesforce_push_entity_crud_mapping(EntityInterface $entity, $op, Sales salesforce_push_enqueue_async($entity, $mapping, $mapped_object, $op); } catch (\Exception $e) { - \Drupal::service('event_dispatcher')->dispatch(SalesforceEvents::ERROR, new SalesforceErrorEvent($e)); + \Drupal::service('event_dispatcher')->dispatch(new SalesforceErrorEvent($e), SalesforceEvents::ERROR); } return; } @@ -159,8 +159,8 @@ function salesforce_push_entity_crud_mapping(EntityInterface $entity, $op, Sales // Attempt real-time push. Enqueue async push on failure. try { \Drupal::service('event_dispatcher')->dispatch( - SalesforceEvents::PUSH_MAPPING_OBJECT, - new SalesforcePushOpEvent($mapped_object, $op) + new SalesforcePushOpEvent($mapped_object, $op), + SalesforceEvents::PUSH_MAPPING_OBJECT ); // If this is a delete, destroy the SF object. @@ -180,16 +180,16 @@ function salesforce_push_entity_crud_mapping(EntityInterface $entity, $op, Sales catch (\Exception $e) { \Drupal::service('event_dispatcher')->dispatch( - SalesforceEvents::PUSH_FAIL, - new SalesforcePushOpEvent($mapped_object, $op) + new SalesforcePushOpEvent($mapped_object, $op), + SalesforceEvents::PUSH_FAIL ); - \Drupal::service('event_dispatcher')->dispatch(SalesforceEvents::ERROR, new SalesforceErrorEvent($e)); + \Drupal::service('event_dispatcher')->dispatch(new SalesforceErrorEvent($e), SalesforceEvents::ERROR); try { salesforce_push_enqueue_async($entity, $mapping, $mapped_object, $op); } catch (\Exception $e) { - \Drupal::service('event_dispatcher')->dispatch(SalesforceEvents::ERROR, new SalesforceErrorEvent($e)); + \Drupal::service('event_dispatcher')->dispatch(new SalesforceErrorEvent($e), SalesforceEvents::ERROR); } if (!$mapped_object->isNew()) { @@ -250,6 +250,6 @@ function salesforce_push_cron() { $queue->processQueues($mappings); } catch (\Exception $e) { - \Drupal::service('event_dispatcher')->dispatch(SalesforceEvents::ERROR, new SalesforceErrorEvent($e)); + \Drupal::service('event_dispatcher')->dispatch(new SalesforceErrorEvent($e), SalesforceEvents::ERROR); } } diff --git a/modules/salesforce_push/src/Plugin/SalesforcePushQueueProcessor/Rest.php b/modules/salesforce_push/src/Plugin/SalesforcePushQueueProcessor/Rest.php index 9a9c564d1359d6d9f9d071b933e08a4f9eb3b90b..675eb2e22658817747e2020634224a6e9aae2f96 100644 --- a/modules/salesforce_push/src/Plugin/SalesforcePushQueueProcessor/Rest.php +++ b/modules/salesforce_push/src/Plugin/SalesforcePushQueueProcessor/Rest.php @@ -153,8 +153,8 @@ class Rest extends PluginBase implements PushQueueProcessorInterface { // @TODO: the following is nearly identical to the end of salesforce_push_entity_crud(). Can we DRY it? Do we care? try { $this->eventDispatcher->dispatch( - SalesforceEvents::PUSH_MAPPING_OBJECT, - new SalesforcePushOpEvent($mapped_object, $item->op) + new SalesforcePushOpEvent($mapped_object, $item->op), + SalesforceEvents::PUSH_MAPPING_OBJECT ); // If this is a delete, destroy the SF object and we're done. @@ -181,8 +181,8 @@ class Rest extends PluginBase implements PushQueueProcessorInterface { } catch (\Exception $e) { $this->eventDispatcher->dispatch( - SalesforceEvents::PUSH_FAIL, - new SalesforcePushOpEvent($mapped_object, $item->op) + new SalesforcePushOpEvent($mapped_object, $item->op), + SalesforceEvents::PUSH_FAIL ); // Log errors and throw exception to cause this item to be re-queued. diff --git a/modules/salesforce_push/src/PushQueue.php b/modules/salesforce_push/src/PushQueue.php index 7d8bdcf93d0a093b55e74ac5dd0df21fece106fc..7ef5382a42dd6ac36d4b619cc5f639c5d7bd01c5 100644 --- a/modules/salesforce_push/src/PushQueue.php +++ b/modules/salesforce_push/src/PushQueue.php @@ -473,7 +473,7 @@ class PushQueue extends DatabaseQueue implements PushQueueInterface { // Getting a Requeue here is weird for a group of items, but we'll // deal with it. $this->releaseItems($items); - $this->eventDispatcher->dispatch(SalesforceEvents::WARNING, new SalesforceErrorEvent($e)); + $this->eventDispatcher->dispatch(new SalesforceErrorEvent($e), SalesforceEvents::WARNING); continue; } catch (SuspendQueueException $e) { @@ -481,14 +481,14 @@ class PushQueue extends DatabaseQueue implements PushQueueInterface { // or authorization error. Release items and move on to the next // mapping in this case. $this->releaseItems($items); - $this->eventDispatcher->dispatch(SalesforceEvents::WARNING, new SalesforceErrorEvent($e)); + $this->eventDispatcher->dispatch(new SalesforceErrorEvent($e), SalesforceEvents::WARNING); return $i; } catch (\Exception $e) { // In case of any other kind of exception, log it and leave the item // in the queue to be processed again later. // @TODO: this is how Cron.php queue works, but I don't really understand why it doesn't get re-queued. - $this->eventDispatcher->dispatch(SalesforceEvents::ERROR, new SalesforceErrorEvent($e)); + $this->eventDispatcher->dispatch(new SalesforceErrorEvent($e), SalesforceEvents::ERROR); } finally { // If we've reached our limit, we're done. Otherwise, continue to next @@ -517,7 +517,7 @@ class PushQueue extends DatabaseQueue implements PushQueueInterface { '%id' => $item->entity_id, '%mapping' => $mapping->id(), ]; - $this->eventDispatcher->dispatch(SalesforceEvents::NOTICE, new SalesforceNoticeEvent(NULL, $message, $args)); + $this->eventDispatcher->dispatch(new SalesforceNoticeEvent(NULL, $message, $args), SalesforceEvents::NOTICE); $this->deleteItem($item); return; } @@ -538,7 +538,7 @@ class PushQueue extends DatabaseQueue implements PushQueueInterface { '%item' => $item->item_id, '%fail' => $item->failures, ]; - $this->eventDispatcher->dispatch(SalesforceEvents::NOTICE, new SalesforceNoticeEvent(NULL, $message, $args)); + $this->eventDispatcher->dispatch(new SalesforceNoticeEvent(NULL, $message, $args), SalesforceEvents::NOTICE); // Failed items will remain in queue, but not be released. They'll be // retried only when the current lease expires. @@ -568,7 +568,7 @@ class PushQueue extends DatabaseQueue implements PushQueueInterface { return $update->execute(); } catch (\Exception $e) { - $this->eventDispatcher->dispatch(SalesforceEvents::ERROR, new SalesforceErrorEvent($e)); + $this->eventDispatcher->dispatch(new SalesforceErrorEvent($e), SalesforceEvents::ERROR); $this->catchException($e); // If the table doesn't exist we should consider the item released. return TRUE; diff --git a/modules/salesforce_push/tests/src/Functional/PushQueueTest.php b/modules/salesforce_push/tests/src/Functional/PushQueueTest.php index 76bce7df5bbce2d3f92d629db719d6754fe726ff..bbedbd2f510ed1dffea2eb939ff95f1fe66bd30b 100644 --- a/modules/salesforce_push/tests/src/Functional/PushQueueTest.php +++ b/modules/salesforce_push/tests/src/Functional/PushQueueTest.php @@ -25,7 +25,7 @@ class PushQueueTest extends BrowserTestBase { * * @var array */ - public static $modules = [ + protected static $modules = [ 'typed_data', 'dynamic_entity_reference', 'salesforce_mapping', diff --git a/modules/salesforce_push/tests/src/Unit/PushQueueTest.php b/modules/salesforce_push/tests/src/Unit/PushQueueTest.php index 7e66ab94c57d368624847c89f940bc6b96256627..548a009b3fe272507540a9fb95c13ecad0d33362 100644 --- a/modules/salesforce_push/tests/src/Unit/PushQueueTest.php +++ b/modules/salesforce_push/tests/src/Unit/PushQueueTest.php @@ -31,12 +31,12 @@ use Prophecy\Argument; * @group salesforce_push */ class PushQueueTest extends UnitTestCase { - static public $modules = ['salesforce_push']; + static protected $modules = ['salesforce_push']; /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { $this->schema = $this->getMockBuilder(Schema::class) ->disableOriginalConstructor() ->getMock(); diff --git a/modules/salesforce_push/tests/src/Unit/SalesforcePushQueueProcessorRestTest.php b/modules/salesforce_push/tests/src/Unit/SalesforcePushQueueProcessorRestTest.php index 2a1688604a78e83bfed0132aed2f5a95bd07e4ff..ba3ae473456e823c8fe7e42592d7c24eb2395e6a 100644 --- a/modules/salesforce_push/tests/src/Unit/SalesforcePushQueueProcessorRestTest.php +++ b/modules/salesforce_push/tests/src/Unit/SalesforcePushQueueProcessorRestTest.php @@ -35,12 +35,12 @@ class SalesforcePushQueueProcessorRestTest extends UnitTestCase { * * @var array */ - static public $modules = ['salesforce_pull']; + protected static $modules = ['salesforce_pull']; /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { $this->entityType = 'default'; $this->queue = $this->getMockBuilder(PushQueueInterface::CLASS)->getMock(); diff --git a/modules/salesforce_soap/salesforce_soap.info.yml b/modules/salesforce_soap/salesforce_soap.info.yml index 363ddedfe744a72fae346c36c3782256f896e47b..bdd49facd8f597a889f49c66e2e224676de11857 100644 --- a/modules/salesforce_soap/salesforce_soap.info.yml +++ b/modules/salesforce_soap/salesforce_soap.info.yml @@ -2,6 +2,6 @@ name: Salesforce Soap type: module description: Exposes a SoapClient service for communicating with the Salesforce SOAP API. package: Salesforce -core_version_requirement: ^8.7.7 || ^9 +core_version_requirement: ^9.1 dependencies: - salesforce:salesforce diff --git a/modules/salesforce_webform/salesforce_webform.info.yml b/modules/salesforce_webform/salesforce_webform.info.yml index 666d55047df103b4bc829537accccb2eaddeae14..0c4c230ee3629816ba45d627f796ba726b571f36 100644 --- a/modules/salesforce_webform/salesforce_webform.info.yml +++ b/modules/salesforce_webform/salesforce_webform.info.yml @@ -2,7 +2,7 @@ name: Salesforce Webform type: module description: Adds support for webforms fields in Salesforce Mapping. package: Salesforce -core_version_requirement: ^8.7.7 || ^9 +core_version_requirement: ^9.1 dependencies: - salesforce:salesforce_mapping diff --git a/salesforce.info.yml b/salesforce.info.yml index b4ece72cef0a9066187dd5f11ad8fa215fcd31f0..9fb7ef22908e9e6d456230744e502f4a6e440120 100644 --- a/salesforce.info.yml +++ b/salesforce.info.yml @@ -2,5 +2,5 @@ name: Salesforce Integration type: module description: Modules to integrate Drupal and Salesforce package: Salesforce -core_version_requirement: ^8.7.7 || ^9 +core_version_requirement: ^9.1 configure: salesforce.admin_config_salesforce diff --git a/src/Event/SalesforceBaseEvent.php b/src/Event/SalesforceBaseEvent.php index b1ec8da03b4fe3947728fdf83c7fc0351ab129f8..d5b4e881f01422e97da801a27739fe90ba27ed22 100644 --- a/src/Event/SalesforceBaseEvent.php +++ b/src/Event/SalesforceBaseEvent.php @@ -2,7 +2,7 @@ namespace Drupal\salesforce\Event; -use Symfony\Component\EventDispatcher\Event; +use Drupal\Component\EventDispatcher\Event; /** * Base event class for Salesforce. diff --git a/src/Form/SalesforceAuthSettings.php b/src/Form/SalesforceAuthSettings.php index 7f7442b935021975962d4b7c5877562afc961a0a..18e8fb8b3707cc16b774d1aa9461099dfe3a51b4 100644 --- a/src/Form/SalesforceAuthSettings.php +++ b/src/Form/SalesforceAuthSettings.php @@ -107,7 +107,7 @@ class SalesforceAuthSettings extends ConfigFormBase { ->save(); $this->messenger()->addStatus($this->t('Authorization settings have been saved.')); - $this->eventDispatcher->dispatch(SalesforceEvents::NOTICE, new SalesforceNoticeEvent(NULL, "Authorization provider changed to %provider.", ['%provider' => $form_state->getValue('provider')])); + $this->eventDispatcher->dispatch(new SalesforceNoticeEvent(NULL, "Authorization provider changed to %provider.", ['%provider' => $form_state->getValue('provider')]), SalesforceEvents::NOTICE); } } diff --git a/tests/modules/salesforce_test_rest_client/salesforce_test_rest_client.info.yml b/tests/modules/salesforce_test_rest_client/salesforce_test_rest_client.info.yml index 883df79a5c66b2c5c59e5dad7712b0433022b437..aa748a14bc0ac34f67917e7bcaf148eddc1f7b08 100644 --- a/tests/modules/salesforce_test_rest_client/salesforce_test_rest_client.info.yml +++ b/tests/modules/salesforce_test_rest_client/salesforce_test_rest_client.info.yml @@ -2,6 +2,6 @@ name: 'Salesforce Test Rest Client' type: module description: 'Provides a dummy Rest Client for functional tests.' package: Testing -core_version_requirement: ^8.7.7 || ^9 +core_version_requirement: ^9.1 dependencies: - salesforce:salesforce diff --git a/tests/src/Unit/RestClientTest.php b/tests/src/Unit/RestClientTest.php index e7991ced4cfef006b2bfbb5741798b7a849292aa..9f6cfb8528fee17ea43b4308793382ac3f529be8 100644 --- a/tests/src/Unit/RestClientTest.php +++ b/tests/src/Unit/RestClientTest.php @@ -41,7 +41,7 @@ class RestClientTest extends UnitTestCase { /** * Set up for each test. */ - public function setUp() { + public function setUp(): void { parent::setUp(); $this->salesforce_id = '1234567890abcde'; $this->methods = [ diff --git a/tests/src/Unit/SFIDTest.php b/tests/src/Unit/SFIDTest.php index 4e61faf81842e451b024f642fef92c0009e2c54b..4990b8d3d61dc208b157ce8e35d178403de91442 100644 --- a/tests/src/Unit/SFIDTest.php +++ b/tests/src/Unit/SFIDTest.php @@ -17,7 +17,7 @@ class SFIDTest extends UnitTestCase { * * @var array */ - static public $modules = ['salesforce']; + static protected $modules = ['salesforce']; /** * Test object instantiation with good ID. diff --git a/tests/src/Unit/SObjectTest.php b/tests/src/Unit/SObjectTest.php index bcfada90be6f9a171f6c8cb3c73c6753177233db..0f9b142da41abb68f31e7e3909f0ef22a5d33d15 100644 --- a/tests/src/Unit/SObjectTest.php +++ b/tests/src/Unit/SObjectTest.php @@ -17,7 +17,7 @@ class SObjectTest extends UnitTestCase { * * @var array */ - static public $modules = ['salesforce']; + protected static $modules = ['salesforce']; /** * Test object instantiation. diff --git a/tests/src/Unit/SelectQueryResultTest.php b/tests/src/Unit/SelectQueryResultTest.php index c263ce6ba4ba110215b9fd08578ff84c2eac9942..c351a8c1a6518616de61753557bba381b4835606 100644 --- a/tests/src/Unit/SelectQueryResultTest.php +++ b/tests/src/Unit/SelectQueryResultTest.php @@ -18,12 +18,12 @@ class SelectQueryResultTest extends UnitTestCase { * * @var array */ - static public $modules = ['salesforce']; + protected static $modules = ['salesforce']; /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $result = [ 'totalSize' => 2,