diff --git a/modules/salesforce_mapping/salesforce_mapping.services.yml b/modules/salesforce_mapping/salesforce_mapping.services.yml index 6d3f72c7df31c35d5e3e2f1f4146ff7472b88867..7f1156f4cf0f3f1687251f883a91ca234ebefcdb 100644 --- a/modules/salesforce_mapping/salesforce_mapping.services.yml +++ b/modules/salesforce_mapping/salesforce_mapping.services.yml @@ -1,4 +1,4 @@ services: plugin.manager.salesforce_mapping_field: - class: Drupal\salesforce_mapping\Plugin\SalesforceMappingFieldPluginManager - arguments: ['@container.namespaces', '@cache.data', '@module_handler'] + class: Drupal\salesforce_mapping\SalesforceMappingFieldPluginManager + arguments: ['@container.namespaces', '@cache.default', '@module_handler'] diff --git a/modules/salesforce_mapping/src/Entity/SalesforceMapping.php b/modules/salesforce_mapping/src/Entity/SalesforceMapping.php index 5e36f30ff96c78812c4bb17a2ca9482aaabd88bb..1991c968ed0a08bd82455a22f17ce1cc5a935338 100644 --- a/modules/salesforce_mapping/src/Entity/SalesforceMapping.php +++ b/modules/salesforce_mapping/src/Entity/SalesforceMapping.php @@ -8,7 +8,7 @@ namespace Drupal\salesforce_mapping\Entity; use Drupal\Core\Config\Entity\ConfigEntityBase; -use Drupal\salesforce_mapping\Plugin\SalesforceMappingFieldPluginManager; +use Drupal\salesforce_mapping\SalesforceMappingFieldPluginManager; use Drupal\Core\Entity\EntityInterface; use Drupal\salesforce_mapping\Entity\SalesforceMappingInterface; diff --git a/modules/salesforce_mapping/src/Form/SalesforceMappingFormCrudBase.php b/modules/salesforce_mapping/src/Form/SalesforceMappingFormCrudBase.php index a1c4798aca2a6ac1a0a2e73b772915773e822c8a..e6fb8dc86319f6b9eb541a10bbfd3e8f870e2259 100644 --- a/modules/salesforce_mapping/src/Form/SalesforceMappingFormCrudBase.php +++ b/modules/salesforce_mapping/src/Form/SalesforceMappingFormCrudBase.php @@ -80,10 +80,10 @@ abstract class SalesforceMappingFormCrudBase extends SalesforceMappingFormBase { $route_name = 'salesforce_mapping.fields'; $route_parameters = array('salesforce_mapping' => $this->entity->id()); } - $form_state['redirect_route'] = array( + $form_state->setValue('redirect_route', array( 'route_name' => $route_name, 'route_parameters' => $route_parameters, - ); + )); } /** @@ -115,7 +115,7 @@ abstract class SalesforceMappingFormCrudBase extends SalesforceMappingFormBase { * interfaces like FieldsDefinition (or something). Look at breaking this up * into smaller chunks. */ - public function form(array $form, array &$form_state) { + public function form(array $form, FormStateInterface $form_state) { $mapping = $this->entity; $form['label'] = array( '#type' => 'textfield', @@ -171,7 +171,7 @@ abstract class SalesforceMappingFormCrudBase extends SalesforceMappingFormBase { continue; } $form['drupal_entity']['drupal_bundle'][$entity_type] = array( - '#title' => $this->t('!entity_type Bundle', array('!entity_type' => $label)), + '#title' => $this->t('@entity_type Bundle', array('@entity_type' => $label)), '#type' => 'select', '#empty_option' => $this->t('- Select -'), '#options' => array(), @@ -204,8 +204,8 @@ abstract class SalesforceMappingFormCrudBase extends SalesforceMappingFormBase { ); $salesforce_object_type = ''; - if (!empty($form_state['values']) && !empty($form_state['values']['salesforce_object_type'])) { - $salesforce_object_type = $form_state['values']['salesforce_object_type']; + if (!empty($form_state->getValues()) && !empty($form_state->getValue('salesforce_object_type'))) { + $salesforce_object_type = $form_state->getValue('salesforce_object_type'); } elseif ($mapping->get('salesforce_object_type')) { $salesforce_object_type = $mapping->get('salesforce_object_type'); @@ -293,10 +293,8 @@ abstract class SalesforceMappingFormCrudBase extends SalesforceMappingFormBase { public function validate(array $form, array &$form_state) { parent::validate($form, $form_state); - $values = $form_state['values']; - - $entity_type = $values['drupal_entity_type']; - if (!empty($entity_type) && empty($values['drupal_bundle'][$entity_type])) { + $entity_type = $form_state->getValue('drupal_entity_type'); + if (!empty($entity_type) && empty($form_state->getValue('drupal_bundle')[$entity_type])) { $element = &$form['drupal_entity']['drupal_bundle'][$entity_type]; // @todo replace with Dependency Injection \Drupal::formBuilder()->setError($element, $this->t('!name field is required.', array('!name' => $element['#title']))); @@ -304,12 +302,12 @@ abstract class SalesforceMappingFormCrudBase extends SalesforceMappingFormBase { // In case the form was submitted without javascript, we must validate the // salesforce record type. - if (empty($values['salesforce_record_type'])) { - $record_types = $this->get_salesforce_record_type_options($values['salesforce_object_type'], $form_state); + if (empty($form_state->getValue('salesforce_record_type'))) { + $record_types = $this->get_salesforce_record_type_options($form_state->getValue('salesforce_object_type'), $form_state); if (count($record_types) > 1) { $element = &$form['salesforce_object']['salesforce_record_type']; drupal_set_message($this->t('!name field is required for this Salesforce Object type.', array('!name' => $element['#title']))); - $form_state['rebuild'] = TRUE; + $form_state->setValue('rebuild', TRUE); } } } @@ -317,18 +315,18 @@ abstract class SalesforceMappingFormCrudBase extends SalesforceMappingFormBase { /** * {@inheritdoc} */ - public function submit(array $form, array &$form_state) { + public function submit(array $form, FormStateInterface $form_state) { parent::submit($form, $form_state); // Drupal bundle is still an array, but needs to be a string. $entity_type = $this->entity->get('drupal_entity_type'); - $bundle = $form_state['values']['drupal_bundle'][$entity_type]; + $bundle = $form_state->getValue('drupal_bundle')[$entity_type]; $this->entity->set('drupal_bundle', $bundle); return $this->entity; } - public function drupal_entity_type_bundle_callback($form, $form_state) { + public function drupal_entity_type_bundle_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); // Requires updating itself and the field map. $response->addCommand(new ReplaceCommand('#edit-salesforce-object', render($form['salesforce_object'])))->addCommand(new ReplaceCommand('#edit-salesforce-field-mappings-wrapper', render($form['salesforce_field_mappings_wrapper']))); @@ -338,7 +336,7 @@ abstract class SalesforceMappingFormCrudBase extends SalesforceMappingFormBase { /** * Ajax callback for salesforce_mapping_form() salesforce record type. */ - public function salesforce_record_type_callback($form, $form_state) { + public function salesforce_record_type_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); // Requires updating itself and the field map. $response->addCommand(new ReplaceCommand('#edit-salesforce-object', render($form['salesforce_object'])))->addCommand(new ReplaceCommand('#edit-salesforce-field-mappings-wrapper', render($form['salesforce_field_mappings_wrapper']))); @@ -348,7 +346,7 @@ abstract class SalesforceMappingFormCrudBase extends SalesforceMappingFormBase { /** * Ajax callback for salesforce_mapping_form() field CRUD */ - public function field_callback($form, $form_state) { + public function field_callback($form, FormStateInterface $form_state) { $response = new AjaxResponse(); $response->addCommand(new ReplaceCommand('#edit-salesforce-field-mappings-wrapper', render($form['salesforce_field_mappings_wrapper']))); return $response; @@ -370,10 +368,10 @@ abstract class SalesforceMappingFormCrudBase extends SalesforceMappingFormBase { // arbitrary restriction, but otherwise there would be dozens of entities, // making this options list unwieldy. foreach ($entity_info as $info) { - if (!$info['fieldable']) { + if (!class_implements($info, 'FieldableEntityInterface')) { continue; } - $options[$info['id']] = $info['label']; + $options[$info->id()] = $info->getLabel(); } return $options; } diff --git a/modules/salesforce_push/salesforce_push.services.yml b/modules/salesforce_push/salesforce_push.services.yml index 17c9aa611d7cea39f4c68d01f694ad4b12ca89eb..4135018023091e35f01700696a00ad17dd095a1e 100644 --- a/modules/salesforce_push/salesforce_push.services.yml +++ b/modules/salesforce_push/salesforce_push.services.yml @@ -1,4 +1,4 @@ services: plugin.manager.salesforce_push: - class: Drupal\salesforce_push\Plugin\SalesforcePushPluginManager - arguments: ['@container.namespaces', '@cache.data', '@language_manager', '@module_handler'] + class: Drupal\salesforce_push\SalesforcePushPluginManager + arguments: ['@container.namespaces', '@cache.default', '@module_handler'] diff --git a/src/SalesforceClient.php b/src/SalesforceClient.php index 2498ee85b24023f5b9f197956aef2b24766f1424..5ae7c5080f191c84435673106cc17090ceea326d 100644 --- a/src/SalesforceClient.php +++ b/src/SalesforceClient.php @@ -489,7 +489,9 @@ class SalesforceClient { * @addtogroup salesforce_apicalls */ public function objects($conditions = array('updateable' => TRUE), $reset = FALSE) { - $cache = cache()->get('salesforce:objects'); + $cache = \Drupal::cache()->get('salesforce:objects'); + $result = $cache->data; + return $result['sobjects']; // Force the recreation of the cache when it is older than 5 minutes. if ($cache && REQUEST_TIME < ($cache->created + 300) && !$reset) { $result = $cache->data; @@ -501,7 +503,7 @@ class SalesforceClient { // CACHE_TEMPORARY has been removed. Using 'content' tag to replicate // old functionality. // @see https://drupal.org/node/1534648 - cache()->set('salesforce:objects', $result, CacheBackendInterface::CACHE_PERMANENT, array('salesforce' => TRUE, 'content' => TRUE)); + \Drupal::cache()->set('salesforce:objects', $result, CacheBackendInterface::CACHE_PERMANENT, array('salesforce' => TRUE, 'content' => TRUE)); } if (!empty($conditions)) { @@ -554,7 +556,9 @@ class SalesforceClient { if (empty($name)) { return array(); } - $cache = cache()->get('salesforce:object:' . $name); + $cache = \Drupal::cache()->get('salesforce:objects'); + + $cache = \Drupal::cache()->get('salesforce:object:' . $name); // Force the recreation of the cache when it is older than 5 minutes. if ($cache && REQUEST_TIME < ($cache->created + 300) && !$reset) { return $cache->data; @@ -564,7 +568,7 @@ class SalesforceClient { // Allow the cache to clear at any time by not setting an expire time. // CACHE_TEMPORARY has been removed. Using 'content' tag to replicate // old functionality. @see https://drupal.org/node/1534648 - cache()->set('salesforce:object:' . $name, $object, CacheBackendInterface::CACHE_PERMANENT, array('salesforce' => TRUE, 'content' => TRUE)); + \Drupal::cache()->set('salesforce:object:' . $name, $object, CacheBackendInterface::CACHE_PERMANENT, array('salesforce' => TRUE, 'content' => TRUE)); return $object; } }