From ced19f8fd344e096de5481d28a110f1cded49cb0 Mon Sep 17 00:00:00 2001
From: jidrone <jidrone@1769194.no-reply.drupal.org>
Date: Wed, 13 Mar 2019 14:36:36 -0400
Subject: [PATCH] Issue #3039549 by jidrone: Drush errors - Too few arguments

---
 modules/salesforce_mapping/drush.services.yml |  2 +-
 .../Commands/SalesforceMappingCommands.php    | 10 ++++++--
 .../SalesforceMappingCommandsBase.php         | 24 +++++++++++++++++--
 modules/salesforce_pull/drush.services.yml    |  2 +-
 .../src/Commands/SalesforcePullCommands.php   | 11 +++++++--
 modules/salesforce_push/drush.services.yml    |  2 +-
 .../src/Commands/SalesforcePushCommands.php   | 10 ++++++--
 7 files changed, 50 insertions(+), 11 deletions(-)

diff --git a/modules/salesforce_mapping/drush.services.yml b/modules/salesforce_mapping/drush.services.yml
index 1cf35948..a18ca39a 100644
--- a/modules/salesforce_mapping/drush.services.yml
+++ b/modules/salesforce_mapping/drush.services.yml
@@ -1,6 +1,6 @@
 services:
   salesforce_mapping.commands:
     class: \Drupal\salesforce_mapping\Commands\SalesforceMappingCommands
-    arguments: ['@salesforce.client', '@entity_type.manager', '@config.factory', '@database']
+    arguments: ['@salesforce.client', '@entity_type.manager', '@plugin.manager.salesforce.auth_providers', '@salesforce.auth_token_storage', '@config.factory', '@database']
     tags:
       - { name: drush.command }
diff --git a/modules/salesforce_mapping/src/Commands/SalesforceMappingCommands.php b/modules/salesforce_mapping/src/Commands/SalesforceMappingCommands.php
index 91c01efe..88c48f54 100644
--- a/modules/salesforce_mapping/src/Commands/SalesforceMappingCommands.php
+++ b/modules/salesforce_mapping/src/Commands/SalesforceMappingCommands.php
@@ -10,6 +10,8 @@ use Drupal\salesforce\SelectQuery;
 use Drush\Exceptions\UserAbortException;
 use Symfony\Component\Console\Input\Input;
 use Symfony\Component\Console\Output\Output;
+use Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface;
+use Drupal\salesforce\Storage\SalesforceAuthTokenStorageInterface;
 
 /**
  * A Drush commandfile.
@@ -34,6 +36,10 @@ class SalesforceMappingCommands extends SalesforceMappingCommandsBase {
    *   The salesforce.client service.
    * @param \Drupal\Core\Entity\EntityTypeManagerInterface $etm
    *   The entity_type.manager service.
+   * @param \Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface $auth_man
+   *   Auth plugin manager.
+   * @param \Drupal\salesforce\Storage\SalesforceAuthTokenStorageInterface $token_storage
+   *   Token storage.
    * @param \Drupal\Core\Config\ConfigFactory $configFactory
    *   The config.factory service.
    * @param \Drupal\Core\Database\Connection $database
@@ -42,8 +48,8 @@ class SalesforceMappingCommands extends SalesforceMappingCommandsBase {
    * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
    * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
    */
-  public function __construct(RestClient $client, EntityTypeManagerInterface $etm, ConfigFactory $configFactory, Connection $database) {
-    parent::__construct($client, $etm);
+  public function __construct(RestClient $client, EntityTypeManagerInterface $etm, SalesforceAuthProviderPluginManagerInterface $auth_man, SalesforceAuthTokenStorageInterface $token_storage, ConfigFactory $configFactory, Connection $database) {
+    parent::__construct($client, $etm, $auth_man, $token_storage);
     $this->database = $database;
     $this->salesforceConfig = $configFactory->get('salesforce.settings');
   }
diff --git a/modules/salesforce_mapping/src/Commands/SalesforceMappingCommandsBase.php b/modules/salesforce_mapping/src/Commands/SalesforceMappingCommandsBase.php
index 3c833bdc..1641baa1 100644
--- a/modules/salesforce_mapping/src/Commands/SalesforceMappingCommandsBase.php
+++ b/modules/salesforce_mapping/src/Commands/SalesforceMappingCommandsBase.php
@@ -11,6 +11,8 @@ use Symfony\Component\Console\Output\Output;
 use Drupal\salesforce\Commands\SalesforceCommandsBase;
 use Drupal\salesforce\Commands\QueryResult;
 use Drupal\salesforce\Commands\QueryResultTableFormatter;
+use Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface;
+use Drupal\salesforce\Storage\SalesforceAuthTokenStorageInterface;
 
 /**
  * Shared command base for Salesforce Drush commands.
@@ -31,6 +33,20 @@ abstract class SalesforceMappingCommandsBase extends SalesforceCommandsBase {
    */
   protected $mappedObjectStorage;
 
+  /**
+   * Salesforce Auth Provider plugin manager service.
+   *
+   * @var \Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface
+   */
+  protected $authMan;
+
+  /**
+   * Salesforce Auth Token Storage service.
+   *
+   * @var \Drupal\salesforce\Storage\SalesforceAuthTokenStorageInterface
+   */
+  protected $tokenStorage;
+
   /**
    * SalesforceMappingCommandsBase constructor.
    *
@@ -38,12 +54,16 @@ abstract class SalesforceMappingCommandsBase extends SalesforceCommandsBase {
    *   SF client.
    * @param \Drupal\Core\Entity\EntityTypeManagerInterface $etm
    *   Entity type manager.
+   * @param \Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface $auth_man
+   *   Auth plugin manager.
+   * @param \Drupal\salesforce\Storage\SalesforceAuthTokenStorageInterface $token_storage
+   *   Token storage.
    *
    * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
    * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
    */
-  public function __construct(RestClient $client, EntityTypeManagerInterface $etm) {
-    parent::__construct($client, $etm);
+  public function __construct(RestClient $client, EntityTypeManagerInterface $etm, SalesforceAuthProviderPluginManagerInterface $auth_man, SalesforceAuthTokenStorageInterface $token_storage) {
+    parent::__construct($client, $etm, $auth_man, $token_storage);
 
     $this->mappingStorage = $etm->getStorage('salesforce_mapping');
     $this->mappedObjectStorage = $etm->getStorage('salesforce_mapped_object');
diff --git a/modules/salesforce_pull/drush.services.yml b/modules/salesforce_pull/drush.services.yml
index b66c6dde..e04760fa 100644
--- a/modules/salesforce_pull/drush.services.yml
+++ b/modules/salesforce_pull/drush.services.yml
@@ -1,6 +1,6 @@
 services:
   salesforce_pull.commands:
     class: \Drupal\salesforce_pull\Commands\SalesforcePullCommands
-    arguments: ['@salesforce.client', '@entity_type.manager', '@salesforce_pull.queue_handler', '@event_dispatcher']
+    arguments: ['@salesforce.client', '@entity_type.manager', '@plugin.manager.salesforce.auth_providers', '@salesforce.auth_token_storage', '@salesforce_pull.queue_handler', '@event_dispatcher']
     tags:
       - { name: drush.command }
diff --git a/modules/salesforce_pull/src/Commands/SalesforcePullCommands.php b/modules/salesforce_pull/src/Commands/SalesforcePullCommands.php
index 78404c89..9341663e 100644
--- a/modules/salesforce_pull/src/Commands/SalesforcePullCommands.php
+++ b/modules/salesforce_pull/src/Commands/SalesforcePullCommands.php
@@ -12,6 +12,9 @@ use Drupal\salesforce_mapping\Event\SalesforceQueryEvent;
 use Drupal\salesforce_pull\QueueHandler;
 use Symfony\Component\Console\Input\Input;
 use Symfony\Component\Console\Output\Output;
+use Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface;
+use Drupal\salesforce\Storage\SalesforceAuthTokenStorageInterface;
+
 
 /**
  * A Drush commandfile.
@@ -47,6 +50,10 @@ class SalesforcePullCommands extends SalesforceMappingCommandsBase {
    *   Salesforce client.
    * @param \Drupal\Core\Entity\EntityTypeManagerInterface $etm
    *   Entity type manager.
+   * @param \Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface $auth_man
+   *   Auth plugin manager.
+   * @param \Drupal\salesforce\Storage\SalesforceAuthTokenStorageInterface $token_storage
+   *   Token storage.
    * @param \Drupal\salesforce_pull\QueueHandler $pullQueue
    *   Pull queue handler service.
    * @param \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher $eventDispatcher
@@ -55,8 +62,8 @@ class SalesforcePullCommands extends SalesforceMappingCommandsBase {
    * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
    * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
    */
-  public function __construct(RestClient $client, EntityTypeManagerInterface $etm, QueueHandler $pullQueue, ContainerAwareEventDispatcher $eventDispatcher) {
-    parent::__construct($client, $etm);
+  public function __construct(RestClient $client, EntityTypeManagerInterface $etm, SalesforceAuthProviderPluginManagerInterface $auth_man, SalesforceAuthTokenStorageInterface $token_storage, QueueHandler $pullQueue, ContainerAwareEventDispatcher $eventDispatcher) {
+    parent::__construct($client, $etm, $auth_man, $token_storage);
     $this->pullQueue = $pullQueue;
     $this->eventDispatcher = $eventDispatcher;
   }
diff --git a/modules/salesforce_push/drush.services.yml b/modules/salesforce_push/drush.services.yml
index 6dd4337e..6dfb2109 100644
--- a/modules/salesforce_push/drush.services.yml
+++ b/modules/salesforce_push/drush.services.yml
@@ -1,6 +1,6 @@
 services:
   salesforce_push.commands:
     class: \Drupal\salesforce_push\Commands\SalesforcePushCommands
-    arguments: ['@salesforce.client', '@entity_type.manager', '@queue.salesforce_push', '@database']
+    arguments: ['@salesforce.client', '@entity_type.manager', '@plugin.manager.salesforce.auth_providers', '@salesforce.auth_token_storage', '@queue.salesforce_push', '@database']
     tags:
       - { name: drush.command }
diff --git a/modules/salesforce_push/src/Commands/SalesforcePushCommands.php b/modules/salesforce_push/src/Commands/SalesforcePushCommands.php
index ddef7082..7b5fff64 100644
--- a/modules/salesforce_push/src/Commands/SalesforcePushCommands.php
+++ b/modules/salesforce_push/src/Commands/SalesforcePushCommands.php
@@ -9,6 +9,8 @@ use Drupal\salesforce\Rest\RestClient;
 use Drupal\salesforce_push\PushQueue;
 use Symfony\Component\Console\Input\Input;
 use Symfony\Component\Console\Output\Output;
+use Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface;
+use Drupal\salesforce\Storage\SalesforceAuthTokenStorageInterface;
 
 /**
  * A Drush commandfile.
@@ -44,6 +46,10 @@ class SalesforcePushCommands extends SalesforceMappingCommandsBase {
    *   Salesforce service.
    * @param \Drupal\Core\Entity\EntityTypeManagerInterface $etm
    *   ETM service.
+   * @param \Drupal\salesforce\SalesforceAuthProviderPluginManagerInterface $auth_man
+   *   Auth plugin manager.
+   * @param \Drupal\salesforce\Storage\SalesforceAuthTokenStorageInterface $token_storage
+   *   Token storage.
    * @param \Drupal\salesforce_push\PushQueue $pushQueue
    *   Push queue service.
    * @param \Drupal\Core\Database\Connection $database
@@ -52,8 +58,8 @@ class SalesforcePushCommands extends SalesforceMappingCommandsBase {
    * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
    * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
    */
-  public function __construct(RestClient $client, EntityTypeManagerInterface $etm, PushQueue $pushQueue, Connection $database) {
-    parent::__construct($client, $etm);
+  public function __construct(RestClient $client, EntityTypeManagerInterface $etm, SalesforceAuthProviderPluginManagerInterface $auth_man, SalesforceAuthTokenStorageInterface $token_storage, PushQueue $pushQueue, Connection $database) {
+    parent::__construct($client, $etm, $auth_man, $token_storage);
     $this->pushQueue = $pushQueue;
     $this->database = $database;
   }
-- 
GitLab