diff --git a/composer.json b/composer.json index 2b12b780063d0a53bc88e70cd37915a3f27893e3..cf4474ec671bfaf92567f7987dc3cab0c6b46134 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "consolidation/output-formatters": "^3.2.0 || ^4.1", "lusitanian/oauth": "^0.8.11", "firebase/php-jwt": "^5.0 || ^6.0", - "drupal/address": "^1.8", + "drupal/address": "^1.8 || ^2.0", "drupal/key": "^1.14", "drupal/dynamic_entity_reference": "^1.9 || ^2.0 || ^3 || ^4", "drupal/typed_data": "^1.0-beta2", diff --git a/modules/salesforce_example/src/EventSubscriber/SalesforceExampleSubscriber.php b/modules/salesforce_example/src/EventSubscriber/SalesforceExampleSubscriber.php index 55c24340596011c52fb09e3e582442f658a2bcb6..15face96f47e3fdbb90cded3c3b7ff133a150d14 100644 --- a/modules/salesforce_example/src/EventSubscriber/SalesforceExampleSubscriber.php +++ b/modules/salesforce_example/src/EventSubscriber/SalesforceExampleSubscriber.php @@ -194,7 +194,7 @@ class SalesforceExampleSubscriber implements EventSubscriberInterface { // Attach the new file id to the user entity. /* var \Drupal\file\FileInterface */ - if ($file = file_save_data($file_data, $destination, FileSystemInterface::EXISTS_REPLACE)) { + if ($file = \Drupal::service('file.repository')->writeData($file_data, $destination, FileSystemInterface::EXISTS_REPLACE)) { $account->user_picture->target_id = $file->id(); } else { diff --git a/modules/salesforce_jwt/src/Plugin/SalesforceAuthProvider/SalesforceJWTPlugin.php b/modules/salesforce_jwt/src/Plugin/SalesforceAuthProvider/SalesforceJWTPlugin.php index 9fdf35341db1372bda7b677d4fcc227391b4e177..b0266ca93f84a92b6ef06d5a35755e591f5c406c 100644 --- a/modules/salesforce_jwt/src/Plugin/SalesforceAuthProvider/SalesforceJWTPlugin.php +++ b/modules/salesforce_jwt/src/Plugin/SalesforceAuthProvider/SalesforceJWTPlugin.php @@ -51,9 +51,9 @@ class SalesforceJWTPlugin extends SalesforceAuthProviderPluginBase { * {@inheritdoc} */ public function __construct(array $configuration, $plugin_id, $plugin_definition, ClientInterface $httpClient, SalesforceAuthTokenStorageInterface $storage, ConfigFactoryInterface $configFactory, KeyRepositoryInterface $keyRepository, TimeInterface $time) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $httpClient, $storage, $configFactory); $this->keyRepository = $keyRepository; $this->time = $time; + parent::__construct($configuration, $plugin_id, $plugin_definition, $httpClient, $storage, $configFactory); } /** diff --git a/modules/salesforce_mapping/config/schema/salesforce_mapping.schema.yml b/modules/salesforce_mapping/config/schema/salesforce_mapping.schema.yml index bab9a2febc1f4a8e61831e5e7e3d4b08500dccc4..16b49031bc61c0581cabe93ce1094f6716f412d0 100644 --- a/modules/salesforce_mapping/config/schema/salesforce_mapping.schema.yml +++ b/modules/salesforce_mapping/config/schema/salesforce_mapping.schema.yml @@ -87,30 +87,30 @@ salesforce_mapping.salesforce_mapping.*: type: sequence label: 'Field Mappings' sequence: - - type: mapping - label: 'Field Mapping' - mapping: - drupal_field_type: - type: string - label: 'Fieldmap Type' - drupal_field_value: - type: string - label: 'Fieldmap Value' - direction: - type: string - label: 'Direction' - salesforce_field: - type: string - label: 'Salesforce Field Name' - id: - type: integer - label: 'Field Id' - drupal_constant: - type: string - label: 'Drupal Constant' - description: - type: text - label: 'Description' + type: mapping + label: 'Field Mapping' + mapping: + drupal_field_type: + type: string + label: 'Fieldmap Type' + drupal_field_value: + type: string + label: 'Fieldmap Value' + direction: + type: string + label: 'Direction' + salesforce_field: + type: string + label: 'Salesforce Field Name' + id: + type: integer + label: 'Field Id' + drupal_constant: + type: string + label: 'Drupal Constant' + description: + type: text + label: 'Description' # Schema / Config API requires that we add these: status: diff --git a/modules/salesforce_mapping_ui/salesforce_mapping_ui.module b/modules/salesforce_mapping_ui/salesforce_mapping_ui.module index 09986c0c6616f2194785a588b0ea55b3969b4c3d..5935eca46b004312ec2e1413440ab026e175500c 100644 --- a/modules/salesforce_mapping_ui/salesforce_mapping_ui.module +++ b/modules/salesforce_mapping_ui/salesforce_mapping_ui.module @@ -79,9 +79,17 @@ function salesforce_mapping_ui_menu_local_actions_alter(&$local_actions) { */ function salesforce_mapping_ui_entity_operation(EntityInterface $entity) { $operations = []; - if (\Drupal::entityTypeManager() + $has_mapping_view_access = FALSE; + + foreach (\Drupal::entityTypeManager() ->getStorage('salesforce_mapping') - ->loadByEntity($entity)) { + ->loadByEntity($entity) as $mapping) { + if ($mapping->access('view')) { + $has_mapping_view_access = TRUE; + } + } + + if ($has_mapping_view_access) { $operations['salesforce'] = [ 'title' => t('Salesforce'), 'weight' => 200, diff --git a/src/Controller/SalesforceAuthListBuilder.php b/src/Controller/SalesforceAuthListBuilder.php index a4e02a44a526312b9a73e86901167b472ca8e0d1..6081c7cf50dd0d71b187436906678c60179b3646 100644 --- a/src/Controller/SalesforceAuthListBuilder.php +++ b/src/Controller/SalesforceAuthListBuilder.php @@ -17,16 +17,16 @@ class SalesforceAuthListBuilder extends ConfigEntityListBuilder { public function buildRow(EntityInterface $entity) { /** @var \Drupal\salesforce\SalesforceAuthProviderInterface $plugin */ $plugin = $entity->getPlugin(); - $row['default'] = $entity->authManager() - ->getConfig() && $entity->authManager() - ->getConfig() - ->id() == $entity->id() - ? $this->t('Default') : ''; + $row['default'] = $entity->authManager()->getConfig()?->id == $entity->id() + ? $this->t('Default') + : ''; $row['label'] = $entity->label(); - $row['url'] = $plugin->getCredentials()->getLoginUrl(); - $row['key'] = substr($plugin->getCredentials()->getConsumerKey(), 0, 16) . '...'; - $row['type'] = $plugin->label(); - $row['status'] = $plugin->hasAccessToken() ? 'Authorized' : 'Missing'; + $row['url'] = $plugin?->getCredentials()?->getLoginUrl(); + $row['key'] = $plugin?->getCredentials()?->getConsumerKey() + ? substr($plugin?->getCredentials()?->getConsumerKey(), 0, 16) . '...' + : NULL; + $row['type'] = $plugin?->label(); + $row['status'] = $plugin?->hasAccessToken() ? 'Authorized' : 'Missing'; return $row + parent::buildRow($entity); } @@ -40,8 +40,8 @@ class SalesforceAuthListBuilder extends ConfigEntityListBuilder { // Add a "revoke" action if we have a token. $operations['edit']['url'] = $entity->toUrl('edit-form'); if (!$entity instanceof SalesforceAuthConfig - || !$entity->getPlugin()->hasAccessToken() - || !$entity->hasLinkTemplate('revoke')) { + || !$entity->getPlugin()?->hasAccessToken() + || !$entity->hasLinkTemplate('revoke')) { return $operations; } // Add a "revoke" action if we have a token. diff --git a/src/Rest/RestResponseDescribe.php b/src/Rest/RestResponseDescribe.php index 2ee099561f034b3c5e1973ee4ae7a82615f72a4b..157c738eafed6525aea8b411e19e2f78e509a49e 100644 --- a/src/Rest/RestResponseDescribe.php +++ b/src/Rest/RestResponseDescribe.php @@ -122,6 +122,12 @@ class RestResponseDescribe extends RestResponse { protected array $urls; + protected bool $hasSubtypes; + + protected ?string $listviewable; + + protected ?string $lookupLayoutable; + // phpcs:enable /** diff --git a/src/SelectQuery.php b/src/SelectQuery.php index 57d666e6fc6b28def6ea351444eb0331e23cfefe..5ac3a1368c72f26ff0d92dc4e62a9a86ee3f72ae 100644 --- a/src/SelectQuery.php +++ b/src/SelectQuery.php @@ -44,6 +44,20 @@ class SelectQuery implements SelectQueryInterface { */ public $conditions = []; + /** + * Starting elements number for query result. + * + * @var int + */ + public $offset; + + /** + * The operator used to combine conditions, defaults to 'AND'. + * + * @var string + */ + public $conjunction; + /** * SelectQuery constructor. * @@ -52,11 +66,15 @@ class SelectQuery implements SelectQueryInterface { */ public function __construct($object_type = '') { $this->objectType = $object_type; + $this->conjunction = 'AND'; } /** * Add a condition to the query. * + * Conditions will be combined with the conjunction defined by + * $this->conjunction. Defaults to 'AND'. + * * @param string $field * Field name. * @param mixed $value @@ -93,6 +111,8 @@ class SelectQuery implements SelectQueryInterface { * Implements PHP's magic toString(). * * Function to convert the query to a string to pass to the SF API. + * Conditions will be combined with the conjunction defined by + * $this->conjunction. Defaults to 'AND'. * * @return string * SOQL query ready to be executed the SF API. @@ -109,7 +129,7 @@ class SelectQuery implements SelectQueryInterface { foreach ($this->conditions as $condition) { $where[] = implode('+', $condition); } - $query .= '+WHERE+' . implode('+AND+', $where); + $query .= '+WHERE+' . implode('+' . $this->conjunction . '+', $where); } if ($this->order) { @@ -125,6 +145,10 @@ class SelectQuery implements SelectQueryInterface { $query .= "+LIMIT+" . (int) $this->limit; } + if ($this->offset) { + $query .= "+OFFSET+" . (int) $this->offset; + } + return $query; } // @codingStandardsIgnoreEnd