From af598161fe614981cc1a96e70b3332433e483d82 Mon Sep 17 00:00:00 2001
From: "thebumikgmail.com" <thebumikgmail.com@3170815.no-reply.drupal.org>
Date: Tue, 3 Mar 2020 16:57:02 -0500
Subject: [PATCH] Issue #3107495 by thebumik: Fatal error when adding new web
 service call

---
 src/Form/WSCallForm.php   | 33 +++++++++++++++++++++++++++------
 src/Form/WSServerForm.php | 11 +++++++++--
 2 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/src/Form/WSCallForm.php b/src/Form/WSCallForm.php
index 0f0c247..466d598 100644
--- a/src/Form/WSCallForm.php
+++ b/src/Form/WSCallForm.php
@@ -16,6 +16,27 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
  */
 class WSCallForm extends EntityForm {
 
+  /**
+   * WSEncoder Manager.
+   *
+   * @var Drupal\wsdata\Plugin\WSEncoderManager
+   */
+  protected $encoderManager;
+
+  /**
+   * WSDecoder Manager.
+   *
+   * @var Drupal\wsdata\Plugin\WSDecoderManager
+   */
+  protected $decoderManager;
+
+  /**
+   * Module Handler.
+   *
+   * @var Drupal\Core\Extension\ModuleHandlerInterface
+   */
+  protected $moduleHandler;
+
   /**
    * {@inheritdoc}
    */
@@ -24,9 +45,9 @@ class WSCallForm extends EntityForm {
     WSDecoderManager $plugin_manager_wsdecoder,
     ModuleHandlerInterface $module_handler
   ) {
-    $this->plugin_manager_wsencoder = $plugin_manager_wsencoder;
-    $this->plugin_manager_wsdecoder = $plugin_manager_wsdecoder;
-    $this->module_handler = $module_handler;
+    $this->encoderManager = $plugin_manager_wsencoder;
+    $this->decoderManager = $plugin_manager_wsdecoder;
+    $this->moduleHandler = $module_handler;
   }
 
   /**
@@ -125,7 +146,7 @@ class WSCallForm extends EntityForm {
       }
     }
 
-    $decoder_definitions = $this->plugin_manager_wsdecoder->getDefinitions();
+    $decoder_definitions = $this->decoderManager->getDefinitions();
     $options = ['' => $this->t('None')];
     foreach ($decoder_definitions as $key => $decoder) {
       $options[$key] = $decoder['label']->render();
@@ -140,7 +161,7 @@ class WSCallForm extends EntityForm {
       '#default_value' => $wscall_entity->wsdecoder,
     ];
 
-    $encoder_definitions = $this->plugin_manager_wsencoder->getDefinitions();
+    $encoder_definitions = $this->encoderManager->getDefinitions();
     $options = ['' => $this->t('None')];
     foreach ($encoder_definitions as $key => $encoder) {
       $options[$key] = $encoder['label']->render();
@@ -155,7 +176,7 @@ class WSCallForm extends EntityForm {
       '#default_value' => $wscall_entity->wsencoder,
     ];
 
-    if (!$this->module_handler->moduleExists('wsdata_extras')) {
+    if (!$this->moduleHandler->moduleExists('wsdata_extras')) {
       $form['wsdecoder']['#description'] .= '  ' . $this->t('Looking for more decoder plugins?  Try enabling the <em>wsdata_extras</em> module.');
       $form['wsencoder']['#description'] .= '  ' . $this->t('Looking for more encoder plugins?  Try enabling the <em>wsdata_extras</em> module.');
     }
diff --git a/src/Form/WSServerForm.php b/src/Form/WSServerForm.php
index 5ad6a14..0dee201 100644
--- a/src/Form/WSServerForm.php
+++ b/src/Form/WSServerForm.php
@@ -15,11 +15,18 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
  */
 class WSServerForm extends EntityForm {
 
+  /**
+   * Connector Manager.
+   *
+   * @var Drupal\wsdata\Plugin\WSConnectorManager
+   */
+  protected $connectorManager;
+
   /**
    * {@inheritdoc}
    */
   public function __construct(WSConnectorManager $plugin_manager_wsconnector, MessengerInterface $messenger) {
-    $this->plugin_manager_wsconnector = $plugin_manager_wsconnector;
+    $this->connectorManager = $plugin_manager_wsconnector;
     $this->messenger = $messenger;
   }
 
@@ -81,7 +88,7 @@ class WSServerForm extends EntityForm {
       '#required' => TRUE,
     ];
 
-    $connector_definitions = $this->plugin_manager_wsconnector->getDefinitions();
+    $connector_definitions = $this->connectorManager->getDefinitions();
 
     $options = [];
     foreach ($connector_definitions as $key => $connector) {
-- 
GitLab