diff --git a/modules/salesforce_mapping/src/Entity/MappedObjectInterface.php b/modules/salesforce_mapping/src/Entity/MappedObjectInterface.php index 44e35d35efcd32fa068878f193d9e7827726d7b8..2f0d8a34d296e67cf00b2b82b61ff735f1bce808 100644 --- a/modules/salesforce_mapping/src/Entity/MappedObjectInterface.php +++ b/modules/salesforce_mapping/src/Entity/MappedObjectInterface.php @@ -62,7 +62,7 @@ interface MappedObjectInterface extends EntityChangedInterface, RevisionLogInter /** * Wrapper for salesforce auth provider plugin manager. * - * @return \Drupal\salesforce\SalesforceAuthProviderPluginManager + * @return \Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface * The auth provider plugin manager. */ public function authMan(); diff --git a/modules/salesforce_pull/tests/src/Unit/DeleteHandlerTest.php b/modules/salesforce_pull/tests/src/Unit/DeleteHandlerTest.php index 5a33700d48bdeff1cdf308f4c726209d3655125b..71da753a50ea1665d0db924019ccd06a7b8a4419 100644 --- a/modules/salesforce_pull/tests/src/Unit/DeleteHandlerTest.php +++ b/modules/salesforce_pull/tests/src/Unit/DeleteHandlerTest.php @@ -3,7 +3,7 @@ namespace Drupal\Tests\salesforce_pull\Unit; use Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher; -use Drupal\Core\Entity\Entity; +use Drupal\Core\Entity\EntityBase; use Drupal\Core\Entity\EntityStorageBase; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\State\StateInterface; @@ -48,7 +48,7 @@ class DeleteHandlerTest extends UnitTestCase { $this->sfapi = $prophecy->reveal(); // Mock Drupal entity. - $prophecy = $this->prophesize(Entity::CLASS); + $prophecy = $this->prophesize(EntityBase::CLASS); $prophecy->delete()->willReturn(TRUE); $prophecy->id()->willReturn(1); $prophecy->label()->willReturn('foo'); diff --git a/modules/salesforce_push/src/Plugin/SalesforcePushQueueProcessor/Rest.php b/modules/salesforce_push/src/Plugin/SalesforcePushQueueProcessor/Rest.php index 91f256ae10aa7f96979c4422c0e3f4b37d5cd87d..3d12d739f1898cdca0876e53f3647a5c86fd207b 100644 --- a/modules/salesforce_push/src/Plugin/SalesforcePushQueueProcessor/Rest.php +++ b/modules/salesforce_push/src/Plugin/SalesforcePushQueueProcessor/Rest.php @@ -2,7 +2,7 @@ namespace Drupal\salesforce_push\Plugin\SalesforcePushQueueProcessor; -use Drupal\salesforce\SalesforceAuthProviderPluginManager; +use Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Plugin\PluginBase; @@ -65,7 +65,7 @@ class Rest extends PluginBase implements PushQueueProcessorInterface { /** * Auth manager. * - * @var \Drupal\salesforce\SalesforceAuthProviderPluginManager + * @var \Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface */ protected $authMan; @@ -84,13 +84,13 @@ class Rest extends PluginBase implements PushQueueProcessorInterface { * ETM service. * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher * Event dispatcher service. - * @param \Drupal\salesforce\SalesforceAuthProviderPluginManager $authMan + * @param \Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface $authMan * Auth manager. * * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException */ - public function __construct(array $configuration, $plugin_id, array $plugin_definition, PushQueueInterface $queue, EntityTypeManagerInterface $etm, EventDispatcherInterface $eventDispatcher, SalesforceAuthProviderPluginManager $authMan) { + public function __construct(array $configuration, $plugin_id, array $plugin_definition, PushQueueInterface $queue, EntityTypeManagerInterface $etm, EventDispatcherInterface $eventDispatcher, SalesforceAuthProviderPluginManagerInterface $authMan) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->queue = $queue; $this->etm = $etm; diff --git a/modules/salesforce_soap/src/Soap/SoapClient.php b/modules/salesforce_soap/src/Soap/SoapClient.php index 6389c896f341e386d511fc7524df2d60992c1155..bb06298513e227b41a8af89b10755a662c30adf0 100644 --- a/modules/salesforce_soap/src/Soap/SoapClient.php +++ b/modules/salesforce_soap/src/Soap/SoapClient.php @@ -3,7 +3,7 @@ namespace Drupal\salesforce_soap\Soap; use Drupal\salesforce\Rest\RestClientInterface; -use Drupal\salesforce\SalesforceAuthProviderPluginManager; +use Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface; use SforcePartnerClient; /** @@ -35,7 +35,7 @@ class SoapClient extends SforcePartnerClient implements SoapClientInterface { /** * Auth manager. * - * @var \Drupal\salesforce\SalesforceAuthProviderPluginManager + * @var \Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface */ protected $authMan; @@ -44,13 +44,13 @@ class SoapClient extends SforcePartnerClient implements SoapClientInterface { * * @param \Drupal\salesforce\Rest\RestClientInterface $rest_api * The Salesforce REST API client. - * @param \Drupal\salesforce\SalesforceAuthProviderPluginManager $authMan + * @param \Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface $authMan * Auth manager. * @param string $wsdl * (Optional) Path to the WSDL that should be used. Defaults to using the * partner WSDL from the developerforce/force.com-toolkit-for-php package. */ - public function __construct(RestClientInterface $rest_api, SalesforceAuthProviderPluginManager $authMan, $wsdl = NULL) { + public function __construct(RestClientInterface $rest_api, SalesforceAuthProviderPluginManagerInterface $authMan, $wsdl = NULL) { parent::__construct(); $this->restApi = $rest_api; diff --git a/salesforce.install b/salesforce.install index fbba712356e99524e53b61e6677d3f539fc20fe3..5907ac99348983bec6789786c5d5f3deaef05156 100644 --- a/salesforce.install +++ b/salesforce.install @@ -8,7 +8,6 @@ use Drupal\Component\Serialization\Json; use Drupal\Core\Url; use Drupal\salesforce\Entity\SalesforceAuthConfig; -use Drupal\salesforce\SalesforceAuthProviderPluginManager; use Drupal\salesforce\Token\SalesforceToken; use Drupal\salesforce_oauth\Consumer\SalesforceOAuthCredentials; use OAuth\Common\Storage\Exception\TokenNotFoundException; @@ -66,7 +65,7 @@ function salesforce_get_auth_provider_requirements() { 'title' => t('Salesforce Authentication Status'), 'value' => t('Provider Status'), ]; - /** @var \Drupal\salesforce\SalesforceAuthProviderPluginManager $authMan */ + /** @var \Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface $authMan */ $authMan = \Drupal::service('plugin.manager.salesforce.auth_providers'); if (!$authMan->hasProviders()) { $requirements += [ diff --git a/src/Commands/SalesforceCommandsBase.php b/src/Commands/SalesforceCommandsBase.php index f53ba63953c6fe59aa071762e69ba273bd55aafe..4734cbb726e0178624c11d859e30fed8d829749a 100644 --- a/src/Commands/SalesforceCommandsBase.php +++ b/src/Commands/SalesforceCommandsBase.php @@ -4,7 +4,7 @@ namespace Drupal\salesforce\Commands; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\salesforce\Rest\RestClient; -use Drupal\salesforce\SalesforceAuthProviderPluginManager; +use Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface; use Drupal\salesforce\Storage\SalesforceAuthTokenStorageInterface; use Drush\Commands\DrushCommands; use Drush\Drush; @@ -34,7 +34,7 @@ abstract class SalesforceCommandsBase extends DrushCommands { /** * Salesforce Auth Provider plugin manager service. * - * @var \Drupal\salesforce\SalesforceAuthProviderPluginManager + * @var \Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface */ protected $authMan; @@ -52,7 +52,7 @@ abstract class SalesforceCommandsBase extends DrushCommands { * SF client. * @param \Drupal\Core\Entity\EntityTypeManagerInterface $etm * Entity type manager. - * @param \Drupal\salesforce\SalesforceAuthProviderPluginManager $authMan + * @param \Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface $authMan * Auth plugin manager. * @param \Drupal\salesforce\Storage\SalesforceAuthTokenStorageInterface $tokenStorage * Token storage. @@ -60,7 +60,7 @@ abstract class SalesforceCommandsBase extends DrushCommands { * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException */ - public function __construct(RestClient $client, EntityTypeManagerInterface $etm, SalesforceAuthProviderPluginManager $authMan, SalesforceAuthTokenStorageInterface $tokenStorage) { + public function __construct(RestClient $client, EntityTypeManagerInterface $etm, SalesforceAuthProviderPluginManagerInterface $authMan, SalesforceAuthTokenStorageInterface $tokenStorage) { $this->client = $client; $this->etm = $etm; $this->authMan = $authMan; diff --git a/src/Entity/SalesforceAuthConfig.php b/src/Entity/SalesforceAuthConfig.php index a5dd68ae06de46e75feba58906abd77d1d898cc3..6377af02211c0f5dc3a52c0ad4d745326ed90501 100644 --- a/src/Entity/SalesforceAuthConfig.php +++ b/src/Entity/SalesforceAuthConfig.php @@ -66,7 +66,7 @@ class SalesforceAuthConfig extends ConfigEntityBase implements EntityInterface { /** * Auth manager. * - * @var \Drupal\salesforce\SalesforceAuthProviderPluginManager + * @var \Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface */ protected $manager; @@ -119,7 +119,7 @@ class SalesforceAuthConfig extends ConfigEntityBase implements EntityInterface { /** * Auth manager wrapper. * - * @return \Drupal\salesforce\SalesforceAuthProviderPluginManager|mixed + * @return \Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface|mixed * The auth provider plugin manager. */ public function authManager() { diff --git a/src/Form/SalesforceAuthSettings.php b/src/Form/SalesforceAuthSettings.php index 05c0ed34baad5805bf1435cf5c82f694e89cb529..e5858d8768cfd7efa932a99684f49ff5beec62e4 100644 --- a/src/Form/SalesforceAuthSettings.php +++ b/src/Form/SalesforceAuthSettings.php @@ -7,8 +7,7 @@ use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\salesforce\Event\SalesforceEvents; use Drupal\salesforce\Event\SalesforceNoticeEvent; -use Drupal\salesforce\SalesforceAuthManager; -use Drupal\salesforce\SalesforceAuthProviderPluginManager; +use Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -25,12 +24,12 @@ class SalesforceAuthSettings extends ConfigFormBase { * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * Config. - * @param \Drupal\salesforce\SalesforceAuthProviderPluginManager $salesforceAuth + * @param \Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface $salesforceAuth * Authman. * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher * Events. */ - public function __construct(ConfigFactoryInterface $config_factory, SalesforceAuthProviderPluginManager $salesforceAuth, EventDispatcherInterface $eventDispatcher) { + public function __construct(ConfigFactoryInterface $config_factory, SalesforceAuthProviderPluginManagerInterface $salesforceAuth, EventDispatcherInterface $eventDispatcher) { parent::__construct($config_factory); $this->salesforceAuth = $salesforceAuth; $this->eventDispatcher = $eventDispatcher; diff --git a/src/Rest/RestClient.php b/src/Rest/RestClient.php index 56d365725e1e5a85ef1877c0d581d5337ceb8826..172e34ddcb1621c48353bb7c9930c517745623e5 100644 --- a/src/Rest/RestClient.php +++ b/src/Rest/RestClient.php @@ -7,7 +7,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\State\StateInterface; -use Drupal\salesforce\SalesforceAuthProviderPluginManager; +use Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface; use Drupal\salesforce\SelectQueryInterface; use Drupal\salesforce\SFID; use Drupal\salesforce\SObject; @@ -81,7 +81,7 @@ class RestClient implements RestClientInterface { /** * Auth provider manager. * - * @var \Drupal\salesforce\SalesforceAuthProviderPluginManager + * @var \Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface */ protected $authManager; @@ -126,10 +126,10 @@ class RestClient implements RestClientInterface { * The JSON serializer service. * @param \Drupal\Component\Datetime\TimeInterface $time * The Time service. - * @param \Drupal\salesforce\SalesforceAuthProviderPluginManager $authManager + * @param \Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface $authManager * Auth manager service. */ - public function __construct(ClientInterface $http_client, ConfigFactoryInterface $config_factory, StateInterface $state, CacheBackendInterface $cache, Json $json, TimeInterface $time, SalesforceAuthProviderPluginManager $authManager) { + public function __construct(ClientInterface $http_client, ConfigFactoryInterface $config_factory, StateInterface $state, CacheBackendInterface $cache, Json $json, TimeInterface $time, SalesforceAuthProviderPluginManagerInterface $authManager) { $this->configFactory = $config_factory; $this->httpClient = $http_client; $this->immutableConfig = $this->configFactory->get('salesforce.settings'); diff --git a/src/SalesforceAuthProviderPluginManager.php b/src/SalesforceAuthProviderPluginManager.php index 904d14eb3a928060eda1439daddc30ccbff507e3..a139e47457dcf59d6d78f96e3b93ba20f870c649 100644 --- a/src/SalesforceAuthProviderPluginManager.php +++ b/src/SalesforceAuthProviderPluginManager.php @@ -13,7 +13,7 @@ use OAuth\OAuth2\Token\StdOAuth2Token; /** * Auth provider plugin manager. */ -class SalesforceAuthProviderPluginManager extends DefaultPluginManager { +class SalesforceAuthProviderPluginManager extends DefaultPluginManager implements SalesforceAuthProviderPluginManagerInterface { /** * Config from salesforce.settings. @@ -73,36 +73,21 @@ class SalesforceAuthProviderPluginManager extends DefaultPluginManager { } /** - * All Salesforce auth providers. - * - * @return \Drupal\salesforce\Entity\SalesforceAuthConfig[] - * All auth provider plugins. - * - * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException - * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException + * {@inheritdoc} */ public function getProviders() { return $this->authStorage()->loadMultiple(); } /** - * TRUE if any auth providers are defined. - * - * @return bool - * TRUE if any auth providers are defined. - * - * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException - * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException + * {@inheritdoc} */ public function hasProviders() { return $this->authStorage()->hasData(); } /** - * Get the active auth service provider, or null if it has not been assigned. - * - * @return \Drupal\salesforce\Entity\SalesforceAuthConfig|null - * The active service provider, or null if it has not been assigned. + * {@inheritdoc} */ public function getConfig() { $provider_id = $this->config()->get('salesforce_auth_provider'); @@ -113,10 +98,7 @@ class SalesforceAuthProviderPluginManager extends DefaultPluginManager { } /** - * The auth provider plugin of the active service provider, or null. - * - * @return \Drupal\salesforce\SalesforceAuthProviderInterface|null - * The auth provider plugin of the active service provider, or null. + * {@inheritdoc} */ public function getProvider() { if (!$this->getConfig()) { @@ -126,10 +108,7 @@ class SalesforceAuthProviderPluginManager extends DefaultPluginManager { } /** - * The credentials for the active auth provider plugin, or null. - * - * @return \Drupal\salesforce\Consumer\SalesforceCredentialsInterface|null - * The credentials for the active auth provider plugin, or null. + * {@inheritdoc} */ public function getCredentials() { if (!$this->getProvider()) { @@ -139,10 +118,7 @@ class SalesforceAuthProviderPluginManager extends DefaultPluginManager { } /** - * Get the active token, or null if it has not been assigned. - * - * @return \OAuth\OAuth2\Token\TokenInterface|null - * The token of the plugin of the active config, or null. + * {@inheritdoc} */ public function getToken() { if (!$config = $this->getConfig()) { @@ -160,10 +136,7 @@ class SalesforceAuthProviderPluginManager extends DefaultPluginManager { } /** - * Force a refresh of the active token and return the fresh token. - * - * @return \OAuth\Common\Token\TokenInterface - * The token. + * {@inheritdoc} */ public function refreshToken() { if (!$config = $this->getConfig()) { diff --git a/src/Storage/SalesforceAuthTokenStorage.php b/src/Storage/SalesforceAuthTokenStorage.php index 9cbe52778418ceb631e3f6b7e79ea77ef573fa1c..c725d918ff0502fbecf906cfc92473c4a63836aa 100644 --- a/src/Storage/SalesforceAuthTokenStorage.php +++ b/src/Storage/SalesforceAuthTokenStorage.php @@ -3,8 +3,6 @@ namespace Drupal\salesforce\Storage; use Drupal\Core\State\StateInterface; -use Drupal\salesforce\SalesforceAuthProviderPluginManager; -use Drupal\salesforce\Token\SalesforceToken; use OAuth\Common\Storage\Exception\TokenNotFoundException; use OAuth\Common\Token\TokenInterface;