diff --git a/modules/webform_access/src/Plugin/Block/WebformAccessGroupEntityBlock.php b/modules/webform_access/src/Plugin/Block/WebformAccessGroupEntityBlock.php
index 2ec9c83f2..c098bcf9f 100644
--- a/modules/webform_access/src/Plugin/Block/WebformAccessGroupEntityBlock.php
+++ b/modules/webform_access/src/Plugin/Block/WebformAccessGroupEntityBlock.php
@@ -3,9 +3,7 @@
namespace Drupal\webform_access\Plugin\Block;
use Drupal\Core\Block\BlockBase;
-use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
-use Drupal\Core\Session\AccountInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -33,37 +31,14 @@ class WebformAccessGroupEntityBlock extends BlockBase implements ContainerFactor
*/
protected $webformAccessGroupStorage;
- /**
- * Creates a WebformAccessGroupEntityBlock instance.
- *
- * @param array $configuration
- * A configuration array containing information about the plugin instance.
- * @param string $plugin_id
- * The plugin_id for the plugin instance.
- * @param mixed $plugin_definition
- * The plugin implementation definition.
- * @param \Drupal\Core\Session\AccountInterface $current_user
- * The current user.
- * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
- * The entity type manager.
- */
- public function __construct(array $configuration, $plugin_id, $plugin_definition, AccountInterface $current_user, EntityTypeManagerInterface $entity_type_manager) {
- parent::__construct($configuration, $plugin_id, $plugin_definition);
- $this->currentUser = $current_user;
- $this->webformAccessGroupStorage = $entity_type_manager->getStorage('webform_access_group');
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
- return new static(
- $configuration,
- $plugin_id,
- $plugin_definition,
- $container->get('current_user'),
- $container->get('entity_type.manager')
- );
+ $instance = new static($configuration, $plugin_id, $plugin_definition);
+ $instance->currentUser = $container->get('current_user');
+ $instance->webformAccessGroupStorage = $container->get('entity_type.manager')->getStorage('webform_access_group');
+ return $instance;
}
/**
diff --git a/modules/webform_access/src/WebformAccessGroupForm.php b/modules/webform_access/src/WebformAccessGroupForm.php
index 363fd91e6..11b317fa0 100644
--- a/modules/webform_access/src/WebformAccessGroupForm.php
+++ b/modules/webform_access/src/WebformAccessGroupForm.php
@@ -2,16 +2,11 @@
namespace Drupal\webform_access;
-use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\Entity\Webform;
-use Drupal\webform\Plugin\WebformElementManagerInterface;
use Drupal\webform\Utility\WebformDialogHelper;
-use Drupal\webform\WebformAccessRulesManagerInterface;
-use Drupal\webform\WebformEntityReferenceManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
-use Drupal\Core\Entity\EntityTypeManagerInterface;
/**
* Provides a form to define a webform access group.
@@ -53,39 +48,17 @@ class WebformAccessGroupForm extends EntityForm {
*/
protected $webformAccessRulesManager;
- /**
- * Constructs a WebformAccessGroupForm.
- *
- * @param \Drupal\Core\Database\Connection $database
- * The database.
- * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
- * The entity manager.
- * @param \Drupal\webform\Plugin\WebformElementManagerInterface $element_manager
- * The webform element manager.
- * @param \Drupal\webform\WebformEntityReferenceManagerInterface $webform_entity_reference_manager
- * The webform entity reference manager.
- * @param \Drupal\webform\WebformAccessRulesManagerInterface $webform_access_rules_manager
- * The webform access rules manager.
- */
- public function __construct(Connection $database, EntityTypeManagerInterface $entity_type_manager, WebformElementManagerInterface $element_manager, WebformEntityReferenceManagerInterface $webform_entity_reference_manager, WebformAccessRulesManagerInterface $webform_access_rules_manager) {
- $this->database = $database;
- $this->entityTypeManager = $entity_type_manager;
- $this->elementManager = $element_manager;
- $this->webformEntityReferenceManager = $webform_entity_reference_manager;
- $this->webformAccessRulesManager = $webform_access_rules_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('database'),
- $container->get('entity_type.manager'),
- $container->get('plugin.manager.webform.element'),
- $container->get('webform.entity_reference_manager'),
- $container->get('webform.access_rules_manager')
- );
+ $instance = parent::create($container);
+ $instance->database = $container->get('database');
+ $instance->entityTypeManager = $container->get('entity_type.manager');
+ $instance->elementManager = $container->get('plugin.manager.webform.element');
+ $instance->webformEntityReferenceManager = $container->get('webform.entity_reference_manager');
+ $instance->webformAccessRulesManager = $container->get('webform.access_rules_manager');
+ return $instance;
}
/**
diff --git a/modules/webform_access/src/WebformAccessGroupListBuilder.php b/modules/webform_access/src/WebformAccessGroupListBuilder.php
index 3d4bd2d7c..44bcbe138 100644
--- a/modules/webform_access/src/WebformAccessGroupListBuilder.php
+++ b/modules/webform_access/src/WebformAccessGroupListBuilder.php
@@ -4,10 +4,7 @@ namespace Drupal\webform_access;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
-use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
-use Drupal\Core\Entity\EntityTypeManagerInterface;
-use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\user\Entity\User;
use Drupal\webform\Element\WebformHtmlEditor;
@@ -40,34 +37,14 @@ class WebformAccessGroupListBuilder extends ConfigEntityListBuilder {
*/
protected $entityTypeManager;
- /**
- * Constructs a new WebformListBuilder object.
- *
- * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
- * The entity type definition.
- * @param \Drupal\Core\Entity\EntityStorageInterface $storage
- * The entity storage class.
- * @param \Drupal\Core\Session\AccountInterface $current_user
- * The current user.
- * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
- * The entity type manager.
- */
- public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, AccountInterface $current_user, EntityTypeManagerInterface $entity_type_manager) {
- parent::__construct($entity_type, $storage);
- $this->currentUser = $current_user;
- $this->entityTypeManager = $entity_type_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
- return new static(
- $entity_type,
- $container->get('entity_type.manager')->getStorage($entity_type->id()),
- $container->get('current_user'),
- $container->get('entity_type.manager')
- );
+ $instance = parent::createInstance($container, $entity_type);
+ $instance->currentUser = $container->get('current_user');
+ $instance->entityTypeManager = $container->get('entity_type.manager');
+ return $instance;
}
/**
diff --git a/modules/webform_access/src/WebformAccessGroupStorage.php b/modules/webform_access/src/WebformAccessGroupStorage.php
index 91335c752..9f5e38bad 100644
--- a/modules/webform_access/src/WebformAccessGroupStorage.php
+++ b/modules/webform_access/src/WebformAccessGroupStorage.php
@@ -2,15 +2,9 @@
namespace Drupal\webform_access;
-use Drupal\Component\Uuid\UuidInterface;
-use Drupal\Core\Cache\MemoryCache\MemoryCacheInterface;
-use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\Entity\ConfigEntityStorage;
-use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
-use Drupal\Core\Entity\EntityTypeManagerInterface;
-use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\webform\WebformInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -34,45 +28,14 @@ class WebformAccessGroupStorage extends ConfigEntityStorage implements WebformAc
*/
protected $entityTypeManager;
- /**
- * Constructs a WebformAccessGroupStorage object.
- *
- * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
- * The entity type definition.
- * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
- * The config factory service.
- * @param \Drupal\Component\Uuid\UuidInterface $uuid_service
- * The UUID service.
- * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
- * The language manager.
- * @param \Drupal\Core\Database\Connection $database
- * The database connection to be used.
- * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
- * The entity type manager.
- * @param \Drupal\Core\Cache\MemoryCache\MemoryCacheInterface $memory_cache
- * The memory cache.
- *
- * @todo Webform 8.x-6.x: Move $memory_cache right after $language_manager.
- */
- public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, Connection $database, EntityTypeManagerInterface $entity_type_manager, MemoryCacheInterface $memory_cache = NULL) {
- parent::__construct($entity_type, $config_factory, $uuid_service, $language_manager, $memory_cache);
- $this->database = $database;
- $this->entityTypeManager = $entity_type_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
- return new static(
- $entity_type,
- $container->get('config.factory'),
- $container->get('uuid'),
- $container->get('language_manager'),
- $container->get('database'),
- $container->get('entity_type.manager'),
- $container->get('entity.memory_cache')
- );
+ $instance = parent::createInstance($container, $entity_type);
+ $instance->database = $container->get('database');
+ $instance->entityTypeManager = $container->get('entity_type.manager');
+ return $instance;
}
/**
diff --git a/modules/webform_access/src/WebformAccessTypeListBuilder.php b/modules/webform_access/src/WebformAccessTypeListBuilder.php
index 03d58c695..c44ef7de0 100644
--- a/modules/webform_access/src/WebformAccessTypeListBuilder.php
+++ b/modules/webform_access/src/WebformAccessTypeListBuilder.php
@@ -4,7 +4,6 @@ namespace Drupal\webform_access;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
-use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\webform\Utility\WebformDialogHelper;
use Drupal\webform_access\Entity\WebformAccessGroup;
@@ -29,23 +28,13 @@ class WebformAccessTypeListBuilder extends ConfigEntityListBuilder {
*/
protected $accessGroupStorage;
- /**
- * {@inheritdoc}
- */
- public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, WebformAccessGroupStorageInterface $access_group_storage) {
- parent::__construct($entity_type, $storage);
- $this->accessGroupStorage = $access_group_storage;
- }
-
/**
* {@inheritdoc}
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
- return new static(
- $entity_type,
- $container->get('entity.manager')->getStorage($entity_type->id()),
- $container->get('entity.manager')->getStorage('webform_access_group')
- );
+ $instance = parent::createInstance($container, $entity_type);
+ $instance->accessGroupStorage = $container->get('entity_type.manager')->getStorage('webform_access_group');
+ return $instance;
}
/**
diff --git a/modules/webform_attachment/src/Controller/WebformAttachmentController.php b/modules/webform_attachment/src/Controller/WebformAttachmentController.php
index ae128f3d6..054bd463a 100644
--- a/modules/webform_attachment/src/Controller/WebformAttachmentController.php
+++ b/modules/webform_attachment/src/Controller/WebformAttachmentController.php
@@ -4,8 +4,6 @@ namespace Drupal\webform_attachment\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
-use Drupal\Core\Render\ElementInfoManagerInterface;
-use Drupal\webform\Plugin\WebformElementManagerInterface;
use Drupal\webform\WebformInterface;
use Drupal\webform\WebformSubmissionInterface;
use Drupal\webform_attachment\Plugin\WebformElement\WebformAttachmentBase;
@@ -33,27 +31,14 @@ class WebformAttachmentController extends ControllerBase implements ContainerInj
*/
protected $elementManager;
- /**
- * Constructs a WebformAttachmentController object.
- *
- * @param \Drupal\Core\Render\ElementInfoManagerInterface $element_info
- * The element info manager.
- * @param \Drupal\webform\Plugin\WebformElementManagerInterface $element_manager
- * A webform element plugin manager.
- */
- public function __construct(ElementInfoManagerInterface $element_info, WebformElementManagerInterface $element_manager) {
- $this->elementInfo = $element_info;
- $this->elementManager = $element_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('plugin.manager.element_info'),
- $container->get('plugin.manager.webform.element')
- );
+ $instance = parent::create($container);
+ $instance->elementInfo = $container->get('plugin.manager.element_info');
+ $instance->elementManager = $container->get('plugin.manager.webform.element');
+ return $instance;
}
/**
diff --git a/modules/webform_attachment/src/Plugin/WebformElement/WebformAttachmentBase.php b/modules/webform_attachment/src/Plugin/WebformElement/WebformAttachmentBase.php
index 3fa84bb26..1ec314281 100644
--- a/modules/webform_attachment/src/Plugin/WebformElement/WebformAttachmentBase.php
+++ b/modules/webform_attachment/src/Plugin/WebformElement/WebformAttachmentBase.php
@@ -10,6 +10,7 @@ use Drupal\webform\Plugin\WebformElementBase;
use Drupal\webform\Plugin\WebformElementDisplayOnInterface;
use Drupal\webform\WebformInterface;
use Drupal\webform\WebformSubmissionInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a base class for 'webform_attachment' elements.
@@ -18,6 +19,22 @@ abstract class WebformAttachmentBase extends WebformElementBase implements Webfo
use WebformDisplayOnTrait;
+ /**
+ * The webform submission (server-side) conditions (#states) validator.
+ *
+ * @var \Drupal\webform\WebformSubmissionConditionsValidator
+ */
+ protected $conditionsValidator;
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+ $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
+ $instance->conditionsValidator = $container->get('webform_submission.conditions_validator');
+ return $instance;
+ }
+
/**
* {@inheritdoc}
*/
@@ -233,9 +250,7 @@ abstract class WebformAttachmentBase extends WebformElementBase implements Webfo
* {@inheritdoc}
*/
public function getAttachments(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
- /** @var \Drupal\webform\WebformSubmissionConditionsValidatorInterface $conditions_validator */
- $conditions_validator = \Drupal::service('webform_submission.conditions_validator');
- if (!$conditions_validator->isElementEnabled($element, $webform_submission)) {
+ if (!$this->conditionsValidator->isElementEnabled($element, $webform_submission)) {
return [];
}
diff --git a/modules/webform_devel/src/Controller/WebformDevelSchemaController.php b/modules/webform_devel/src/Controller/WebformDevelSchemaController.php
index 8a1cb20f7..2a0462883 100644
--- a/modules/webform_devel/src/Controller/WebformDevelSchemaController.php
+++ b/modules/webform_devel/src/Controller/WebformDevelSchemaController.php
@@ -2,11 +2,9 @@
namespace Drupal\webform_devel\Controller;
-use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\webform\WebformInterface;
-use Drupal\webform_devel\WebformDevelSchemaInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\StreamedResponse;
@@ -29,27 +27,14 @@ class WebformDevelSchemaController extends ControllerBase implements ContainerIn
*/
protected $schema;
- /**
- * Constructs a WebformDevelSchemaController object.
- *
- * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
- * The factory for configuration objects.
- * @param \Drupal\webform_devel\WebformDevelSchemaInterface $schema
- * The webform devel schema generator.
- */
- public function __construct(ConfigFactoryInterface $config_factory, WebformDevelSchemaInterface $schema) {
- $this->configFactory = $config_factory;
- $this->schema = $schema;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('config.factory'),
- $container->get('webform_devel.schema')
- );
+ $instance = parent::create($container);
+ $instance->configFactory = $container->get('config.factory');
+ $instance->schema = $container->get('webform_devel.schema');
+ return $instance;
}
/**
diff --git a/modules/webform_devel/src/Form/WebformDevelEntitySchemaForm.php b/modules/webform_devel/src/Form/WebformDevelEntitySchemaForm.php
index 53b6833d3..5a520c92f 100644
--- a/modules/webform_devel/src/Form/WebformDevelEntitySchemaForm.php
+++ b/modules/webform_devel/src/Form/WebformDevelEntitySchemaForm.php
@@ -7,7 +7,6 @@ use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\webform\Form\WebformEntityAjaxFormTrait;
use Drupal\webform\Utility\WebformDialogHelper;
-use Drupal\webform_devel\WebformDevelSchemaInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -24,23 +23,13 @@ class WebformDevelEntitySchemaForm extends EntityForm {
*/
protected $scheme;
- /**
- * Constructs a WebformDevelEntitySchemaForm.
- *
- * @param \Drupal\webform_devel\WebformDevelSchemaInterface $webform_devel_scheme
- * The webform devel scheme service.
- */
- public function __construct(WebformDevelSchemaInterface $webform_devel_scheme) {
- $this->scheme = $webform_devel_scheme;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('webform_devel.schema')
- );
+ $instance = parent::create($container);
+ $instance->scheme = $container->get('webform_devel.schema');
+ return $instance;
}
/**
diff --git a/modules/webform_devel/src/Form/WebformDevelSubmissionApiForm.php b/modules/webform_devel/src/Form/WebformDevelSubmissionApiForm.php
index c093541ee..34a6f81f4 100644
--- a/modules/webform_devel/src/Form/WebformDevelSubmissionApiForm.php
+++ b/modules/webform_devel/src/Form/WebformDevelSubmissionApiForm.php
@@ -3,14 +3,11 @@
namespace Drupal\webform_devel\Form;
use Drupal\Component\Utility\Variable;
-use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\Entity\Webform;
use Drupal\webform\Entity\WebformSubmission;
-use Drupal\webform\WebformRequestInterface;
use Drupal\webform\WebformSubmissionForm;
-use Drupal\webform\WebformSubmissionGenerateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -39,31 +36,15 @@ class WebformDevelSubmissionApiForm extends FormBase {
*/
protected $generate;
- /**
- * Constructs a WebformDevelSubmissionApiForm object.
- *
- * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
- * The entity type manager.
- * @param \Drupal\webform\WebformRequestInterface $request_handler
- * The webform request handler.
- * @param \Drupal\webform\WebformSubmissionGenerateInterface $submission_generate
- * The webform submission generation service.
- */
- public function __construct(EntityTypeManagerInterface $entity_type_manager, WebformRequestInterface $request_handler, WebformSubmissionGenerateInterface $submission_generate) {
- $this->submissionStorage = $entity_type_manager->getStorage('webform_submission');
- $this->requestHandler = $request_handler;
- $this->generate = $submission_generate;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('entity_type.manager'),
- $container->get('webform.request'),
- $container->get('webform_submission.generate')
- );
+ $instance = parent::create($container);
+ $instance->submissionStorage = $container->get('entity_type.manager')->getStorage('webform_submission');
+ $instance->requestHandler = $container->get('webform.request');
+ $instance->generate = $container->get('webform_submission.generate');
+ return $instance;
}
/**
diff --git a/modules/webform_editorial/src/Controller/WebformEditorialController.php b/modules/webform_editorial/src/Controller/WebformEditorialController.php
index 0f1e98070..c2f4d7861 100644
--- a/modules/webform_editorial/src/Controller/WebformEditorialController.php
+++ b/modules/webform_editorial/src/Controller/WebformEditorialController.php
@@ -4,18 +4,12 @@ namespace Drupal\webform_editorial\Controller;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Controller\ControllerBase;
-use Drupal\Core\Database\Connection;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
-use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Link;
use Drupal\Core\Render\Markup;
-use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Response;
-use Drupal\webform\Plugin\WebformElementManagerInterface;
-use Drupal\webform\WebformHelpManagerInterface;
-use Drupal\webform\WebformLibrariesManagerInterface;
/**
* Provides route responses for webform editorial.
@@ -64,43 +58,18 @@ class WebformEditorialController extends ControllerBase implements ContainerInje
*/
protected $librariesManager;
- /**
- * Constructs a WebformEditorialController object.
- *
- * @param \Drupal\Core\Database\Connection $database
- * The database connection to be used.
- * @param \Drupal\Core\Render\RendererInterface $renderer
- * The renderer.
- * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
- * The entity field manager.
- * @param \Drupal\webform\WebformHelpManagerInterface $help_manager
- * The webform help manager.
- * @param \Drupal\webform\Plugin\WebformElementManagerInterface $element_manager
- * The webform element manager.
- * @param \Drupal\webform\WebformLibrariesManagerInterface $libraries_manager
- * The webform libraries manager.
- */
- public function __construct(Connection $database, RendererInterface $renderer, EntityFieldManagerInterface $entity_field_manager, WebformHelpManagerInterface $help_manager, WebformElementManagerInterface $element_manager, WebformLibrariesManagerInterface $libraries_manager) {
- $this->database = $database;
- $this->renderer = $renderer;
- $this->entityFieldManager = $entity_field_manager;
- $this->helpManager = $help_manager;
- $this->elementManager = $element_manager;
- $this->librariesManager = $libraries_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('database'),
- $container->get('renderer'),
- $container->get('entity_field.manager'),
- $container->get('webform.help_manager'),
- $container->get('plugin.manager.webform.element'),
- $container->get('webform.libraries_manager')
- );
+ $instance = parent::create($container);
+ $instance->database = $container->get('database');
+ $instance->renderer = $container->get('renderer');
+ $instance->entityFieldManager = $container->get('entity_field.manager');
+ $instance->helpManager = $container->get('webform.help_manager');
+ $instance->elementManager = $container->get('plugin.manager.webform.element');
+ $instance->librariesManager = $container->get('webform.libraries_manager');
+ return $instance;
}
/****************************************************************************/
diff --git a/modules/webform_entity_print/src/Plugin/Derivative/WebformEntityPrintWebformDeriverBase.php b/modules/webform_entity_print/src/Plugin/Derivative/WebformEntityPrintWebformDeriverBase.php
index f2a1e9193..087fcf511 100644
--- a/modules/webform_entity_print/src/Plugin/Derivative/WebformEntityPrintWebformDeriverBase.php
+++ b/modules/webform_entity_print/src/Plugin/Derivative/WebformEntityPrintWebformDeriverBase.php
@@ -5,7 +5,6 @@ namespace Drupal\webform_entity_print\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
-use Drupal\entity_print\Plugin\ExportTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -22,23 +21,13 @@ abstract class WebformEntityPrintWebformDeriverBase extends DeriverBase implemen
*/
protected $exportTypeManager;
- /**
- * Constructs new WebformEntityPrintWebformDeriverBase.
- *
- * @param \Drupal\entity_print\Plugin\ExportTypeManagerInterface $export_type_manager
- * The entity print export type manager.
- */
- public function __construct(ExportTypeManagerInterface $export_type_manager) {
- $this->exportTypeManager = $export_type_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
- return new static(
- $container->get('plugin.manager.entity_print.export_type')
- );
+ $instance = new static();
+ $instance->exportTypeManager = $container->get('plugin.manager.entity_print.export_type');
+ return $instance;
}
/**
diff --git a/modules/webform_entity_print/src/Plugin/WebformExporter/WebformEntityPrintWebformExporter.php b/modules/webform_entity_print/src/Plugin/WebformExporter/WebformEntityPrintWebformExporter.php
index 02263340f..5b159489c 100644
--- a/modules/webform_entity_print/src/Plugin/WebformExporter/WebformEntityPrintWebformExporter.php
+++ b/modules/webform_entity_print/src/Plugin/WebformExporter/WebformEntityPrintWebformExporter.php
@@ -3,20 +3,10 @@
namespace Drupal\webform_entity_print\Plugin\WebformExporter;
use Drupal\Core\Archiver\ArchiveTar;
-use Drupal\Core\Config\ConfigFactoryInterface;
-use Drupal\Core\Entity\EntityTypeManagerInterface;
-use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Form\FormStateInterface;
-use Drupal\entity_print\Plugin\ExportTypeManagerInterface;
-use Drupal\entity_print\PrintBuilderInterface;
-use Drupal\entity_print\Plugin\EntityPrintPluginManagerInterface;
-use Drupal\webform\Plugin\WebformElementManagerInterface;
use Drupal\webform\Plugin\WebformExporter\DocumentBaseWebformExporter;
use Drupal\webform\WebformSubmissionInterface;
-use Drupal\webform\WebformTokenManagerInterface;
-use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
-use Symfony\Component\HttpFoundation\RequestStack;
/**
* Defines a Webform Entity Print PDF exporter.
@@ -65,38 +55,17 @@ class WebformEntityPrintWebformExporter extends DocumentBaseWebformExporter {
*/
protected $printBuilder;
- /**
- * Constructs a WebformEntityPrintBaseWebformExporter object.
- */
- public function __construct(array $configuration, $plugin_id, $plugin_definition, LoggerInterface $logger, ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager, WebformElementManagerInterface $element_manager, WebformTokenManagerInterface $token_manager, RequestStack $request_stack, EntityPrintPluginManagerInterface $print_engine_manager, ExportTypeManagerInterface $export_type_manager, PrintBuilderInterface $print_builder, FileSystemInterface $file_system) {
- parent::__construct($configuration, $plugin_id, $plugin_definition, $logger, $config_factory, $entity_type_manager, $element_manager, $token_manager);
- $this->request = $request_stack->getCurrentRequest();
- $this->printEngineManager = $print_engine_manager;
- $this->exportTypeManager = $export_type_manager;
- $this->printBuilder = $print_builder;
- $this->fileSystem = $file_system ?: \Drupal::service('file_system');
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
- return new static(
- $configuration,
- $plugin_id,
- $plugin_definition,
- $container->get('logger.factory')->get('webform'),
- $container->get('config.factory'),
- $container->get('entity_type.manager'),
- $container->get('plugin.manager.webform.element'),
- $container->get('webform.token_manager'),
- $container->get('request_stack'),
- $container->get('plugin.manager.entity_print.print_engine'),
- $container->get('plugin.manager.entity_print.export_type'),
- $container->get('entity_print.print_builder'),
- $container->get('file_system')
-
- );
+ $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
+ $instance->request = $container->get('request_stack')->getCurrentRequest();
+ $instance->printEngineManager = $container->get('plugin.manager.entity_print.print_engine');
+ $instance->exportTypeManager = $container->get('plugin.manager.entity_print.export_type');
+ $instance->printBuilder = $container->get('entity_print.print_builder');
+ $instance->fileSystem = $container->get('file_system');
+ return $instance;
}
/**
diff --git a/modules/webform_entity_print_attachment/src/Plugin/WebformElement/WebformEntityPrintAttachment.php b/modules/webform_entity_print_attachment/src/Plugin/WebformElement/WebformEntityPrintAttachment.php
index 1f21b8c39..121819834 100644
--- a/modules/webform_entity_print_attachment/src/Plugin/WebformElement/WebformEntityPrintAttachment.php
+++ b/modules/webform_entity_print_attachment/src/Plugin/WebformElement/WebformEntityPrintAttachment.php
@@ -7,6 +7,7 @@ use Drupal\webform\Twig\WebformTwigExtension;
use Drupal\webform\Utility\WebformElementHelper;
use Drupal\webform\WebformSubmissionInterface;
use Drupal\webform_attachment\Plugin\WebformElement\WebformAttachmentBase;
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a 'webform_entity_print_attachment' element.
@@ -21,6 +22,23 @@ use Drupal\webform_attachment\Plugin\WebformElement\WebformAttachmentBase;
*/
class WebformEntityPrintAttachment extends WebformAttachmentBase {
+ /**
+ * The export type manager.
+ *
+ * @var \Drupal\entity_print\Plugin\ExportTypeManagerInterface
+ */
+ protected $exportTypeManager;
+
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+ $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
+ $instance->exportTypeManager = $container->get('plugin.manager.entity_print.export_type');
+ return $instance;
+ }
+
/**
* {@inheritdoc}
*/
@@ -101,10 +119,8 @@ class WebformEntityPrintAttachment extends WebformAttachmentBase {
* An export type file extension.
*/
protected function getExportTypeFileExtension() {
- /** @var \Drupal\entity_print\Plugin\ExportTypeManagerInterface $export_type_manager */
- $export_type_manager = \Drupal::service('plugin.manager.entity_print.export_type');
list(, $export_type_id) = explode(':', $this->getPluginId());
- $definition = $export_type_manager->getDefinition($export_type_id);
+ $definition = $this->exportTypeManager->getDefinition($export_type_id);
return $definition['file_extension'];
}
diff --git a/modules/webform_example_handler/src/Plugin/WebformHandler/ExampleWebformHandler.php b/modules/webform_example_handler/src/Plugin/WebformHandler/ExampleWebformHandler.php
index 8adea8fde..43d4e00ec 100644
--- a/modules/webform_example_handler/src/Plugin/WebformHandler/ExampleWebformHandler.php
+++ b/modules/webform_example_handler/src/Plugin/WebformHandler/ExampleWebformHandler.php
@@ -3,16 +3,11 @@
namespace Drupal\webform_example_handler\Plugin\WebformHandler;
use Drupal\Component\Utility\Xss;
-use Drupal\Core\Config\ConfigFactoryInterface;
-use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
-use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\Render\Markup;
use Drupal\webform\Plugin\WebformHandlerBase;
use Drupal\webform\WebformInterface;
-use Drupal\webform\WebformSubmissionConditionsValidatorInterface;
use Drupal\webform\WebformSubmissionInterface;
-use Drupal\webform\WebformTokenManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -37,28 +32,13 @@ class ExampleWebformHandler extends WebformHandlerBase {
*/
protected $tokenManager;
- /**
- * {@inheritdoc}
- */
- public function __construct(array $configuration, $plugin_id, $plugin_definition, LoggerChannelFactoryInterface $logger_factory, ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager, WebformSubmissionConditionsValidatorInterface $conditions_validator, WebformTokenManagerInterface $token_manager) {
- parent::__construct($configuration, $plugin_id, $plugin_definition, $logger_factory, $config_factory, $entity_type_manager, $conditions_validator);
- $this->tokenManager = $token_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
- return new static(
- $configuration,
- $plugin_id,
- $plugin_definition,
- $container->get('logger.factory'),
- $container->get('config.factory'),
- $container->get('entity_type.manager'),
- $container->get('webform_submission.conditions_validator'),
- $container->get('webform.token_manager')
- );
+ $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
+ $instance->tokenManager = $container->get('webform.token_manager');
+ return $instance;
}
/**
diff --git a/modules/webform_group/src/WebformGroupManager.php b/modules/webform_group/src/WebformGroupManager.php
index ca7fccc67..486676ada 100644
--- a/modules/webform_group/src/WebformGroupManager.php
+++ b/modules/webform_group/src/WebformGroupManager.php
@@ -155,7 +155,7 @@ class WebformGroupManager implements WebformGroupManagerInterface {
// \Drupal\group\Entity\Storage\GroupRoleStorage::loadByUserAndGroup.
// @see \Drupal\group\Entity\Storage\GroupRoleStorageInterface::loadByUserAndGroup
/** @var \Drupal\group\Entity\Storage\GroupRoleStorageInterface $group_role_storage */
- $group_role_storage = \Drupal::entityTypeManager()->getStorage('group_role');
+ $group_role_storage = $this->entityTypeManager->getStorage('group_role');
$group_roles = $group_role_storage->loadByUserAndGroup($this->currentUser, $group, TRUE);
if (!$group_roles) {
return $this->currentGroupRoles;
diff --git a/modules/webform_image_select/src/Plugin/WebformElement/WebformImageSelect.php b/modules/webform_image_select/src/Plugin/WebformElement/WebformImageSelect.php
index 2ecb37730..ba6b84a36 100644
--- a/modules/webform_image_select/src/Plugin/WebformElement/WebformImageSelect.php
+++ b/modules/webform_image_select/src/Plugin/WebformElement/WebformImageSelect.php
@@ -8,6 +8,7 @@ use Drupal\webform\Plugin\WebformElement\Select;
use Drupal\webform_image_select\Element\WebformImageSelect as WebformImageSelectElement;
use Drupal\webform\WebformSubmissionInterface;
use Drupal\webform_image_select\Entity\WebformImageSelectImages;
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a 'image_select' element.
@@ -21,6 +22,30 @@ use Drupal\webform_image_select\Entity\WebformImageSelectImages;
*/
class WebformImageSelect extends Select {
+ /**
+ * The current request.
+ *
+ * @var null|\Symfony\Component\HttpFoundation\Request
+ */
+ protected $request;
+
+ /**
+ * The route match object.
+ *
+ * @var \Drupal\Core\Routing\RouteMatchInterface
+ */
+ protected $routeMatch;
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+ $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
+ $instance->request = $container->get('request_stack')->getCurrentRequest();
+ $instance->routeMatch = $container->get('current_route_match');
+ return $instance;
+ }
+
/**
* {@inheritdoc}
*/
@@ -93,7 +118,7 @@ class WebformImageSelect extends Select {
// Always use absolute URLs for the src so that it will load via e-mail.
if (strpos($src, '/') === 0) {
- $src = \Drupal::request()->getSchemeAndHttpHost() . $src;
+ $src = $this->request->getSchemeAndHttpHost() . $src;
}
$image = [
@@ -119,7 +144,7 @@ class WebformImageSelect extends Select {
}
// For the Results table always just return the image with tooltip.
- if (strpos(\Drupal::routeMatch()->getRouteName(), 'webform.results_submissions') !== FALSE) {
+ if (strpos($this->routeMatch->getRouteName(), 'webform.results_submissions') !== FALSE) {
$image['#attached']['library'][] = 'webform/webform.tooltip';
$image['#attributes']['class'] = ['js-webform-tooltip-link'];
return $image;
diff --git a/modules/webform_image_select/src/WebformImageSelectImagesListBuilder.php b/modules/webform_image_select/src/WebformImageSelectImagesListBuilder.php
index a43dc187f..213625549 100644
--- a/modules/webform_image_select/src/WebformImageSelectImagesListBuilder.php
+++ b/modules/webform_image_select/src/WebformImageSelectImagesListBuilder.php
@@ -4,14 +4,12 @@ namespace Drupal\webform_image_select;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
-use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Url;
use Drupal\webform\Utility\WebformDialogHelper;
use Drupal\webform_image_select\Entity\WebformImageSelectImages;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
-use Symfony\Component\HttpFoundation\RequestStack;
/**
* Defines a class to build a listing of webform image select images entities.
@@ -20,6 +18,13 @@ use Symfony\Component\HttpFoundation\RequestStack;
*/
class WebformImageSelectImagesListBuilder extends ConfigEntityListBuilder {
+ /**
+ * The current request.
+ *
+ * @var \Symfony\Component\HttpFoundation\Request
+ */
+ protected $request;
+
/**
* Search keys.
*
@@ -35,32 +40,24 @@ class WebformImageSelectImagesListBuilder extends ConfigEntityListBuilder {
protected $category;
/**
- * Constructs a new WebformImageSelectImagesListBuilder object.
- *
- * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
- * The entity type definition.
- * @param \Drupal\Core\Entity\EntityStorageInterface $storage
- * The entity storage class.
- * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
- * The request stack.
+ * {@inheritdoc}
*/
- public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, RequestStack $request_stack) {
- parent::__construct($entity_type, $storage);
- $this->request = $request_stack->getCurrentRequest();
+ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
+ /** @var \Drupal\webform_image_select\WebformImageSelectImagesListBuilder $instance */
+ $instance = parent::createInstance($container, $entity_type);
- $this->keys = $this->request->query->get('search');
- $this->category = $this->request->query->get('category');
+ $instance->request = $container->get('request_stack')->getCurrentRequest();
+
+ $instance->initialize();
+ return $instance;
}
/**
- * {@inheritdoc}
+ * Initialize WebformImageSelectImagesListBuilder object.
*/
- public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
- return new static(
- $entity_type,
- $container->get('entity.manager')->getStorage($entity_type->id()),
- $container->get('request_stack')
- );
+ protected function initialize() {
+ $this->keys = $this->request->query->get('search');
+ $this->category = $this->request->query->get('category');
}
/**
diff --git a/modules/webform_location_geocomplete/src/Plugin/WebformElement/WebformLocationGeocomplete.php b/modules/webform_location_geocomplete/src/Plugin/WebformElement/WebformLocationGeocomplete.php
index 54869ea38..ecea3a320 100644
--- a/modules/webform_location_geocomplete/src/Plugin/WebformElement/WebformLocationGeocomplete.php
+++ b/modules/webform_location_geocomplete/src/Plugin/WebformElement/WebformLocationGeocomplete.php
@@ -126,13 +126,13 @@ class WebformLocationGeocomplete extends WebformLocationBase {
'#title' => $this->t('Google Maps API key'),
'#description' => $this->t('Google requires users to use a valid API key. Using the Google API Manager, you can enable the Google Maps JavaScript API. That will create (or reuse) a Browser key which you can paste here.'),
];
- $default_api_key = \Drupal::config('webform.settings')->get('element.default_google_maps_api_key');
+ $default_api_key = $this->configFactory->get('webform.settings')->get('element.default_google_maps_api_key');
if ($default_api_key) {
$form['composite']['api_key']['#description'] .= '
' . $this->t('Defaults to: %value', ['%value' => $default_api_key]);
}
else {
$form['composite']['api_key']['#required'] = TRUE;
- if (\Drupal::currentUser()->hasPermission('administer webform')) {
+ if ($this->currentUser->hasPermission('administer webform')) {
$t_args = [':href' => UrlGenerator::fromRoute('webform.config.elements')->toString()];
$form['composite']['api_key']['#description'] .= '
' . $this->t('You can either enter an element specific API key here or set the default site-wide API key.', $t_args);
}
diff --git a/modules/webform_node/src/Controller/WebformNodeEntityReferenceController.php b/modules/webform_node/src/Controller/WebformNodeEntityReferenceController.php
index 0be1abdfe..d54b91dc7 100644
--- a/modules/webform_node/src/Controller/WebformNodeEntityReferenceController.php
+++ b/modules/webform_node/src/Controller/WebformNodeEntityReferenceController.php
@@ -5,7 +5,6 @@ namespace Drupal\webform_node\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\node\NodeInterface;
-use Drupal\webform\WebformEntityReferenceManagerInterface;
use Drupal\webform\WebformInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -23,23 +22,13 @@ class WebformNodeEntityReferenceController extends ControllerBase implements Con
*/
protected $webformEntityReferenceManager;
- /**
- * Constructs a WebformNodeEntityReferenceController object.
- *
- * @param \Drupal\webform\WebformEntityReferenceManagerInterface $webform_entity_reference_manager
- * The webform entity reference manager.
- */
- public function __construct(WebformEntityReferenceManagerInterface $webform_entity_reference_manager) {
- $this->webformEntityReferenceManager = $webform_entity_reference_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('webform.entity_reference_manager')
- );
+ $instance = parent::create($container);
+ $instance->webformEntityReferenceManager = $container->get('webform.entity_reference_manager');
+ return $instance;
}
/**
diff --git a/modules/webform_node/src/Controller/WebformNodeReferencesListController.php b/modules/webform_node/src/Controller/WebformNodeReferencesListController.php
index 490dc2523..cdc11f3e5 100644
--- a/modules/webform_node/src/Controller/WebformNodeReferencesListController.php
+++ b/modules/webform_node/src/Controller/WebformNodeReferencesListController.php
@@ -3,19 +3,13 @@
namespace Drupal\webform_node\Controller;
use Drupal\Core\Serialization\Yaml;
-use Drupal\Core\Datetime\DateFormatterInterface;
-use Drupal\Core\Config\Entity\ConfigEntityStorageInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
-use Drupal\Core\Entity\EntityStorageInterface;
-use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Url;
use Drupal\webform\Utility\WebformDialogHelper;
use Drupal\webform\Utility\WebformElementHelper;
-use Drupal\webform\WebformEntityReferenceManagerInterface;
use Drupal\webform\WebformInterface;
-use Drupal\webform\WebformSubmissionStorageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -104,32 +98,27 @@ class WebformNodeReferencesListController extends EntityListBuilder implements C
}
/**
- * Constructs a new WebformNodeReferencesListController object.
- *
- * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
- * The entity type definition.
- * @param \Drupal\Core\Entity\EntityStorageInterface $storage
- * The entity storage class.
- * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
- * The date formatter service.
- * @param \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $node_type_storage
- * The node type storage class.
- * @param \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $field_config_storage
- * The field config storage class.
- * @param \Drupal\webform\WebformSubmissionStorageInterface $webform_submission_storage
- * The webform submission storage class.
- * @param \Drupal\webform\WebformEntityReferenceManagerInterface $webform_entity_reference_manager
- * The webform entity reference manager.
+ * {@inheritdoc}
*/
- public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, DateFormatterInterface $date_formatter, ConfigEntityStorageInterface $node_type_storage, ConfigEntityStorageInterface $field_config_storage, WebformSubmissionStorageInterface $webform_submission_storage, WebformEntityReferenceManagerInterface $webform_entity_reference_manager) {
- parent::__construct($entity_type, $storage);
-
- $this->dateFormatter = $date_formatter;
- $this->nodeTypeStorage = $node_type_storage;
- $this->fieldConfigStorage = $field_config_storage;
- $this->submissionStorage = $webform_submission_storage;
- $this->webformEntityReferenceManager = $webform_entity_reference_manager;
+ public static function create(ContainerInterface $container) {
+ /** @var web/core/lib/Drupal/Core/Entity/EntityTypeManagerInterface.php:12 $entity_type_manager */
+ $entity_type_manager = $container->get('entity_type.manager');
+ $instance = static::createInstance($container, $entity_type_manager->getDefinition('node'));
+
+ $instance->dateFormatter = $container->get('date.formatter');
+ $instance->nodeTypeStorage = $entity_type_manager->getStorage('node_type');
+ $instance->fieldConfigStorage = $entity_type_manager->getStorage('field_config');
+ $instance->submissionStorage = $entity_type_manager->getStorage('webform_submission');
+ $instance->webformEntityReferenceManager = $container->get('webform.entity_reference_manager');
+
+ $instance->initialize();
+ return $instance;
+ }
+ /**
+ * Initialize WebformNodeReferencesListController object.
+ */
+ protected function initialize() {
$this->nodeTypes = [];
$this->fieldNames = [];
@@ -148,21 +137,6 @@ class WebformNodeReferencesListController extends EntityListBuilder implements C
}
}
- /**
- * {@inheritdoc}
- */
- public static function create(ContainerInterface $container) {
- return new static(
- $container->get('entity_type.manager')->getDefinition('node'),
- $container->get('entity_type.manager')->getStorage('node'),
- $container->get('date.formatter'),
- $container->get('entity_type.manager')->getStorage('node_type'),
- $container->get('entity_type.manager')->getStorage('field_config'),
- $container->get('entity_type.manager')->getStorage('webform_submission'),
- $container->get('webform.entity_reference_manager')
- );
- }
-
/**
* {@inheritdoc}
*/
diff --git a/modules/webform_options_custom/src/WebformOptionsCustomListBuilder.php b/modules/webform_options_custom/src/WebformOptionsCustomListBuilder.php
index c7400ed84..028f4e2ff 100644
--- a/modules/webform_options_custom/src/WebformOptionsCustomListBuilder.php
+++ b/modules/webform_options_custom/src/WebformOptionsCustomListBuilder.php
@@ -4,13 +4,11 @@ namespace Drupal\webform_options_custom;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
-use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Url;
use Drupal\webform\Utility\WebformDialogHelper;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
-use Symfony\Component\HttpFoundation\RequestStack;
/**
* Defines a class to build a listing of webform options custom entities.
@@ -19,6 +17,20 @@ use Symfony\Component\HttpFoundation\RequestStack;
*/
class WebformOptionsCustomListBuilder extends ConfigEntityListBuilder {
+ /**
+ * The current request.
+ *
+ * @var \Symfony\Component\HttpFoundation\Request
+ */
+ protected $request;
+
+ /**
+ * The form builder.
+ *
+ * @var \Drupal\Core\Form\FormBuilderInterface
+ */
+ protected $formBuilder;
+
/**
* Search keys.
*
@@ -33,33 +45,25 @@ class WebformOptionsCustomListBuilder extends ConfigEntityListBuilder {
*/
protected $category;
+
/**
- * Constructs a new WebformOptionsCustomListBuilder object.
- *
- * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
- * The entity type definition.
- * @param \Drupal\Core\Entity\EntityStorageInterface $storage
- * The entity storage class.
- * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
- * The request stack.
+ * {@inheritdoc}
*/
- public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, RequestStack $request_stack) {
- parent::__construct($entity_type, $storage);
- $this->request = $request_stack->getCurrentRequest();
-
- $this->keys = $this->request->query->get('search');
- $this->category = $this->request->query->get('category');
+ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
+ /** @var \Drupal\webform_options_custom\WebformOptionsCustomListBuilder $instance */
+ $instance = parent::createInstance($container, $entity_type);
+ $instance->request = $container->get('request_stack')->getCurrentRequest();
+ $instance->formBuilder = $container->get('form_builder');
+ $instance->initialize();
+ return $instance;
}
/**
- * {@inheritdoc}
+ * Initialize WebformOptionsCustomListBuilder object.
*/
- public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
- return new static(
- $entity_type,
- $container->get('entity.manager')->getStorage($entity_type->id()),
- $container->get('request_stack')
- );
+ protected function initialize() {
+ $this->keys = $this->request->query->get('search');
+ $this->category = $this->request->query->get('category');
}
/**
@@ -100,7 +104,7 @@ class WebformOptionsCustomListBuilder extends ConfigEntityListBuilder {
*/
protected function buildFilterForm() {
$categories = $this->getStorage()->getCategories();
- return \Drupal::formBuilder()->getForm('\Drupal\webform_options_custom\Form\WebformOptionsCustomFilterForm', $this->keys, $this->category, $categories);
+ return $this->formBuilder->getForm('\Drupal\webform_options_custom\Form\WebformOptionsCustomFilterForm', $this->keys, $this->category, $categories);
}
/**
diff --git a/modules/webform_options_limit/src/Controller/WebformOptionsLimitController.php b/modules/webform_options_limit/src/Controller/WebformOptionsLimitController.php
index 420087dc1..c0a3b7d90 100644
--- a/modules/webform_options_limit/src/Controller/WebformOptionsLimitController.php
+++ b/modules/webform_options_limit/src/Controller/WebformOptionsLimitController.php
@@ -9,7 +9,6 @@ use Drupal\Core\Session\AccountInterface;
use Drupal\node\NodeInterface;
use Drupal\webform\Access\WebformEntityAccess;
use Drupal\webform\WebformInterface;
-use Drupal\webform\WebformRequestInterface;
use Drupal\webform_options_limit\Plugin\WebformOptionsLimitHandlerInterface;
use Drupal\webform_node\Access\WebformNodeAccess;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -26,23 +25,13 @@ class WebformOptionsLimitController extends ControllerBase implements ContainerI
*/
protected $requestHandler;
- /**
- * Constructs a WebformSubmissionExportImportController object.
- *
- * @param \Drupal\webform\WebformRequestInterface $request_handler
- * The webform request handler.
- */
- public function __construct(WebformRequestInterface $request_handler) {
- $this->requestHandler = $request_handler;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('webform.request')
- );
+ $instance = parent::create($container);
+ $instance->requestHandler = $container->get('webform.request');
+ return $instance;
}
/**
diff --git a/modules/webform_options_limit/src/Plugin/WebformHandler/OptionsLimitWebformHandler.php b/modules/webform_options_limit/src/Plugin/WebformHandler/OptionsLimitWebformHandler.php
index a7823f659..c189a7879 100644
--- a/modules/webform_options_limit/src/Plugin/WebformHandler/OptionsLimitWebformHandler.php
+++ b/modules/webform_options_limit/src/Plugin/WebformHandler/OptionsLimitWebformHandler.php
@@ -3,25 +3,17 @@
namespace Drupal\webform_options_limit\Plugin\WebformHandler;
use Drupal\Component\Render\FormattableMarkup;
-use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Cache\Cache;
-use Drupal\Core\Database\Connection;
-use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityInterface;
-use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\OptGroup;
-use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\webform\Element\WebformAjaxElementTrait;
use Drupal\webform\Element\WebformEntityTrait;
use Drupal\webform\Element\WebformMessage;
use Drupal\webform\Plugin\WebformElementEntityOptionsInterface;
-use Drupal\webform\Plugin\WebformElementManagerInterface;
use Drupal\webform\Plugin\WebformHandlerBase;
use Drupal\webform\Utility\WebformOptionsHelper;
-use Drupal\webform\WebformSubmissionConditionsValidatorInterface;
use Drupal\webform\WebformSubmissionInterface;
-use Drupal\webform\WebformTokenManagerInterface;
use Drupal\webform_options_limit\Plugin\WebformOptionsLimitHandlerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -116,6 +108,13 @@ class OptionsLimitWebformHandler extends WebformHandlerBase implements WebformOp
*/
protected $database;
+ /**
+ * The current user.
+ *
+ * @var \Drupal\Core\Session\AccountInterface
+ */
+ protected $currentUser;
+
/**
* The webform token manager.
*
@@ -137,32 +136,16 @@ class OptionsLimitWebformHandler extends WebformHandlerBase implements WebformOp
*/
protected $sourceEntity = NULL;
- /**
- * {@inheritdoc}
- */
- public function __construct(array $configuration, $plugin_id, $plugin_definition, LoggerChannelFactoryInterface $logger_factory, ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager, WebformSubmissionConditionsValidatorInterface $conditions_validator, Connection $database, WebformTokenManagerInterface $token_manager, WebformElementManagerInterface $element_manager) {
- parent::__construct($configuration, $plugin_id, $plugin_definition, $logger_factory, $config_factory, $entity_type_manager, $conditions_validator);
- $this->database = $database;
- $this->tokenManager = $token_manager;
- $this->elementManager = $element_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
- return new static(
- $configuration,
- $plugin_id,
- $plugin_definition,
- $container->get('logger.factory'),
- $container->get('config.factory'),
- $container->get('entity_type.manager'),
- $container->get('webform_submission.conditions_validator'),
- $container->get('database'),
- $container->get('webform.token_manager'),
- $container->get('plugin.manager.webform.element')
- );
+ $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
+ $instance->database = $container->get('database');
+ $instance->currentUser = $container->get('current_user');
+ $instance->tokenManager = $container->get('webform.token_manager');
+ $instance->elementManager = $container->get('plugin.manager.webform.element');
+ return $instance;
}
/**
@@ -1054,12 +1037,11 @@ class OptionsLimitWebformHandler extends WebformHandlerBase implements WebformOp
// Limit by authenticated or anonymous user.
if ($this->configuration['limit_user']) {
- $account = \Drupal::currentUser();
- if ($account->isAuthenticated()) {
- $query->condition('s.uid', $account->id());
+ if ($this->currentUser->isAuthenticated()) {
+ $query->condition('s.uid', $this->currentUser->id());
}
else {
- $sids = $this->submissionStorage->getAnonymousSubmissionIds($account);
+ $sids = $this->submissionStorage->getAnonymousSubmissionIds($this->currentUser);
if ($sids) {
$query->condition('s.sid', $sids, 'IN');
$query->condition('s.uid', 0);
diff --git a/modules/webform_scheduled_email/src/Controller/WebformScheduledEmailController.php b/modules/webform_scheduled_email/src/Controller/WebformScheduledEmailController.php
index 80b5c0d8d..3a661e0f8 100644
--- a/modules/webform_scheduled_email/src/Controller/WebformScheduledEmailController.php
+++ b/modules/webform_scheduled_email/src/Controller/WebformScheduledEmailController.php
@@ -5,7 +5,6 @@ namespace Drupal\webform_scheduled_email\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\webform\WebformInterface;
-use Drupal\webform_scheduled_email\WebformScheduledEmailManagerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -21,23 +20,13 @@ class WebformScheduledEmailController extends ControllerBase implements Containe
*/
protected $manager;
- /**
- * Constructs a WebformScheduledEmailController object.
- *
- * @param \Drupal\webform_scheduled_email\WebformScheduledEmailManagerInterface $manager
- * The webform scheduled email manager.
- */
- public function __construct(WebformScheduledEmailManagerInterface $manager) {
- $this->manager = $manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('webform_scheduled_email.manager')
- );
+ $instance = parent::create($container);
+ $instance->manager = $container->get('webform_scheduled_email.manager');
+ return $instance;
}
/**
diff --git a/modules/webform_scheduled_email/src/Plugin/WebformHandler/ScheduleEmailWebformHandler.php b/modules/webform_scheduled_email/src/Plugin/WebformHandler/ScheduleEmailWebformHandler.php
index f37a65559..ef197aa83 100644
--- a/modules/webform_scheduled_email/src/Plugin/WebformHandler/ScheduleEmailWebformHandler.php
+++ b/modules/webform_scheduled_email/src/Plugin/WebformHandler/ScheduleEmailWebformHandler.php
@@ -11,6 +11,7 @@ use Drupal\webform\Plugin\WebformHandler\EmailWebformHandler;
use Drupal\webform\Utility\WebformDateHelper;
use Drupal\webform\WebformSubmissionInterface;
use Drupal\webform_scheduled_email\WebformScheduledEmailManagerInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Schedules a webform submission's email.
@@ -27,6 +28,30 @@ use Drupal\webform_scheduled_email\WebformScheduledEmailManagerInterface;
*/
class ScheduleEmailWebformHandler extends EmailWebformHandler {
+ /**
+ * The current request.
+ *
+ * @var null|\Symfony\Component\HttpFoundation\Request
+ */
+ protected $request;
+
+ /**
+ * The webform scheculed email manager.
+ *
+ * @var \Drupal\webform_scheduled_email\WebformScheduledEmailManagerInterface $webform_scheduled_email_manager
+ */
+ protected $scheduledEmailManager;
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+ $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
+ $instance->request = $container->get('request_stack')->getCurrentRequest();
+ $instance->scheduledEmailManager = $container->get('webform_scheduled_email.manager');
+ return $instance;
+ }
+
/**
* {@inheritdoc}
*/
@@ -44,9 +69,6 @@ class ScheduleEmailWebformHandler extends EmailWebformHandler {
* {@inheritdoc}
*/
public function getSummary() {
- /** @var \Drupal\webform_scheduled_email\WebformScheduledEmailManagerInterface $webform_scheduled_email_manager */
- $webform_scheduled_email_manager = \Drupal::service('webform_scheduled_email.manager');
-
$status_messages = [
WebformScheduledEmailManagerInterface::SUBMISSION_WAITING => [
'message' => $this->t('waiting to be scheduled.'),
@@ -64,7 +86,7 @@ class ScheduleEmailWebformHandler extends EmailWebformHandler {
$cron_link = FALSE;
$build = [];
- $stats = $webform_scheduled_email_manager->stats($this->webform, $this->getHandlerId());
+ $stats = $this->scheduledEmailManager->stats($this->webform, $this->getHandlerId());
foreach ($stats as $type => $total) {
if (empty($total) || !isset($status_messages[$type])) {
continue;
@@ -113,9 +135,6 @@ class ScheduleEmailWebformHandler extends EmailWebformHandler {
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
- /** @var \Drupal\webform_scheduled_email\WebformScheduledEmailManagerInterface $webform_scheduled_email_manager */
- $webform_scheduled_email_manager = \Drupal::service('webform_scheduled_email.manager');
-
$webform = $this->getWebform();
// Get options, mail, and text elements as options (text/value).
@@ -149,7 +168,7 @@ class ScheduleEmailWebformHandler extends EmailWebformHandler {
// Send date/time.
$send_options = [
'[date:html_date]' => $this->t('Current date'),
- WebformOtherBase::OTHER_OPTION => $this->t('Custom @label…', ['@label' => $webform_scheduled_email_manager->getDateTypeLabel()]),
+ WebformOtherBase::OTHER_OPTION => $this->t('Custom @label…', ['@label' => $this->scheduledEmailManager->getDateTypeLabel()]),
(string) $this->t('Webform') => [
'[webform:open:html_date]' => $this->t('Open date'),
'[webform:close:html_date]' => $this->t('Close date'),
@@ -165,14 +184,14 @@ class ScheduleEmailWebformHandler extends EmailWebformHandler {
}
$t_args = [
- '@format' => $webform_scheduled_email_manager->getDateFormatLabel(),
- '@type' => $webform_scheduled_email_manager->getDateTypeLabel(),
+ '@format' => $this->scheduledEmailManager->getDateFormatLabel(),
+ '@type' => $this->scheduledEmailManager->getDateTypeLabel(),
];
$form['scheduled']['send'] = [
'#type' => 'webform_select_other',
'#title' => $this->t('Send email on'),
'#options' => $send_options,
- '#other__placeholder' => $webform_scheduled_email_manager->getDateFormatLabel(),
+ '#other__placeholder' => $this->scheduledEmailManager->getDateFormatLabel(),
'#other__description' => $this->t('Enter a valid ISO @type (@format) or token which returns a valid ISO @type.', $t_args),
'#default_value' => $this->configuration['send'],
];
@@ -280,9 +299,6 @@ class ScheduleEmailWebformHandler extends EmailWebformHandler {
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::validateConfigurationForm($form, $form_state);
- /** @var \Drupal\webform_scheduled_email\WebformScheduledEmailManagerInterface $webform_scheduled_email_manager */
- $webform_scheduled_email_manager = \Drupal::service('webform_scheduled_email.manager');
-
$values = $form_state->getValues();
// Cast days string to int.
@@ -290,13 +306,13 @@ class ScheduleEmailWebformHandler extends EmailWebformHandler {
// If token skip validation.
if (!preg_match('/^\[[^]]+\]$/', $values['send'])) {
- $date_format = $webform_scheduled_email_manager->getDateFormat();
+ $date_format = $this->scheduledEmailManager->getDateFormat();
// Validate custom 'send on' date.
if (WebformDateHelper::createFromFormat($date_format, $values['send']) === FALSE) {
$t_args = [
'%field' => $this->t('Send on'),
- '%format' => $webform_scheduled_email_manager->getDateFormatLabel(),
- '@type' => $webform_scheduled_email_manager->getDateTypeLabel(),
+ '%format' => $this->scheduledEmailManager->getDateFormatLabel(),
+ '@type' => $this->scheduledEmailManager->getDateTypeLabel(),
];
$form_state->setError($form['settings']['scheduled']['send'], $this->t('The %field date is required. Please enter a @type in the format %format.', $t_args));
}
@@ -311,9 +327,7 @@ class ScheduleEmailWebformHandler extends EmailWebformHandler {
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::submitConfigurationForm($form, $form_state);
if ($form_state->getValue('queue')) {
- /** @var \Drupal\webform_scheduled_email\WebformScheduledEmailManagerInterface $webform_scheduled_email_manager */
- $webform_scheduled_email_manager = \Drupal::service('webform_scheduled_email.manager');
- $webform_scheduled_email_manager->schedule($this->getWebform(), $this->getHandlerId());
+ $this->scheduledEmailManager->schedule($this->getWebform(), $this->getHandlerId());
}
}
@@ -322,7 +336,7 @@ class ScheduleEmailWebformHandler extends EmailWebformHandler {
*/
public function alterForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {
// Display warning when test email will be sent immediately.
- if (\Drupal::request()->isMethod('GET')
+ if ($this->request->isMethod('GET')
&& $this->getWebform()->isTest()
&& !empty($this->configuration['test_send'])) {
$t_args = ['%label' => $this->getLabel()];
@@ -360,18 +374,14 @@ class ScheduleEmailWebformHandler extends EmailWebformHandler {
* {@inheritdoc}
*/
public function updateHandler() {
- /** @var \Drupal\webform_scheduled_email\WebformScheduledEmailManagerInterface $webform_scheduled_email_manager */
- $webform_scheduled_email_manager = \Drupal::service('webform_scheduled_email.manager');
- $webform_scheduled_email_manager->reschedule($this->webform, $this->getHandlerId());
+ $this->scheduledEmailManager->reschedule($this->webform, $this->getHandlerId());
}
/**
* {@inheritdoc}
*/
public function deleteHandler() {
- /** @var \Drupal\webform_scheduled_email\WebformScheduledEmailManagerInterface $webform_scheduled_email_manager */
- $webform_scheduled_email_manager = \Drupal::service('webform_scheduled_email.manager');
- $webform_scheduled_email_manager->unschedule($this->webform, $this->getHandlerId());
+ $this->scheduledEmailManager->unschedule($this->webform, $this->getHandlerId());
}
/**
@@ -384,9 +394,6 @@ class ScheduleEmailWebformHandler extends EmailWebformHandler {
* The status of scheduled email. FALSE is email was not scheduled.
*/
protected function scheduleMessage(WebformSubmissionInterface $webform_submission) {
- /** @var \Drupal\webform_scheduled_email\WebformScheduledEmailManagerInterface $webform_scheduled_email_manager */
- $webform_scheduled_email_manager = \Drupal::service('webform_scheduled_email.manager');
-
$t_args = [
'%submission' => $webform_submission->label(),
'%handler' => $this->label(),
@@ -411,7 +418,7 @@ class ScheduleEmailWebformHandler extends EmailWebformHandler {
}
// Get send date.
- $send_iso_date = $webform_scheduled_email_manager->getSendDate($webform_submission, $this->handler_id);
+ $send_iso_date = $this->scheduledEmailManager->getSendDate($webform_submission, $this->handler_id);
$t_args['%date'] = $send_iso_date;
// Log and exit when we are unable to schedule an email due to an invalid
@@ -429,7 +436,7 @@ class ScheduleEmailWebformHandler extends EmailWebformHandler {
// Finally, schedule the email, which also writes to the submission log
// and watchdog.
- $status = $webform_scheduled_email_manager->schedule($webform_submission, $this->getHandlerId());
+ $status = $this->scheduledEmailManager->schedule($webform_submission, $this->getHandlerId());
// Debug by displaying schedule message onscreen.
if ($this->configuration['debug']) {
@@ -459,7 +466,7 @@ class ScheduleEmailWebformHandler extends EmailWebformHandler {
'#wrapper_attributes' => ['class' => ['container-inline'], 'style' => 'margin: 0'],
'#weight' => -10,
];
- $this->messenger()->addWarning(\Drupal::service('renderer')->renderPlain($debug_message), TRUE);
+ $this->messenger()->addWarning($this->renderer->renderPlain($debug_message), TRUE);
}
return $status;
@@ -472,10 +479,8 @@ class ScheduleEmailWebformHandler extends EmailWebformHandler {
* A webform submission.
*/
protected function unscheduleMessage(WebformSubmissionInterface $webform_submission) {
- /** @var \Drupal\webform_scheduled_email\WebformScheduledEmailManagerInterface $webform_scheduled_email_manager */
- $webform_scheduled_email_manager = \Drupal::service('webform_scheduled_email.manager');
- if ($webform_scheduled_email_manager->hasScheduledEmail($webform_submission, $this->getHandlerId())) {
- $webform_scheduled_email_manager->unschedule($webform_submission, $this->getHandlerId());
+ if ($this->scheduledEmailManager->hasScheduledEmail($webform_submission, $this->getHandlerId())) {
+ $this->scheduledEmailManager->unschedule($webform_submission, $this->getHandlerId());
if ($this->configuration['debug']) {
$t_args = [
'%submission' => $webform_submission->label(),
diff --git a/modules/webform_submission_export_import/src/Controller/WebformSubmissionExportImportController.php b/modules/webform_submission_export_import/src/Controller/WebformSubmissionExportImportController.php
index 39a35ad21..60705981a 100644
--- a/modules/webform_submission_export_import/src/Controller/WebformSubmissionExportImportController.php
+++ b/modules/webform_submission_export_import/src/Controller/WebformSubmissionExportImportController.php
@@ -4,11 +4,7 @@ namespace Drupal\webform_submission_export_import\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
-use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Serialization\Yaml;
-use Drupal\webform\WebformRequestInterface;
-use Drupal\webform\WebformSubmissionGenerateInterface;
-use Drupal\webform_submission_export_import\WebformSubmissionExportImportImporterInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\StreamedResponse;
@@ -53,41 +49,28 @@ class WebformSubmissionExportImportController extends ControllerBase implements
protected $importer;
/**
- * Constructs a WebformSubmissionExportImportController object.
- *
- * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
- * The entity type manager.
- * @param \Drupal\webform\WebformRequestInterface $request_handler
- * The webform request handler.
- * @param \Drupal\webform\WebformSubmissionGenerateInterface $submission_generate
- * The webform submission generation service.
- * @param \Drupal\webform_submission_export_import\WebformSubmissionExportImportImporterInterface $importer
- * The webform submission importer.
+ * {@inheritdoc}
*/
- public function __construct(EntityTypeManagerInterface $entity_type_manager, WebformRequestInterface $request_handler, WebformSubmissionGenerateInterface $submission_generate, WebformSubmissionExportImportImporterInterface $importer) {
- $this->entityTypeManager = $entity_type_manager;
- $this->webformSubmissionStorage = $entity_type_manager->getStorage('webform_submission');
- $this->requestHandler = $request_handler;
- $this->generate = $submission_generate;
- $this->importer = $importer;
-
- // Initialize the importer.
- $webform = $this->requestHandler->getCurrentWebform();
- $source_entity = $this->requestHandler->getCurrentSourceEntity();
- $this->importer->setWebform($webform);
- $this->importer->setSourceEntity($source_entity);
+ public static function create(ContainerInterface $container) {
+ /** @var \Drupal\webform_submission_export_import\Controller\WebformSubmissionExportImportController $instance */
+ $instance = parent::create($container);
+ $instance->entityTypeManager = $container->get('entity_type.manager');
+ $instance->webformSubmissionStorage = $instance->entityTypeManager->getStorage('webform_submission');
+ $instance->requestHandler = $container->get('webform.request');
+ $instance->generate = $container->get('webform_submission.generate');
+ $instance->importer = $container->get('webform_submission_export_import.importer');
+ $instance->initialize();
+ return $instance;
}
/**
- * {@inheritdoc}
+ * Initialize WebformSubmissionExportImportController object.
*/
- public static function create(ContainerInterface $container) {
- return new static(
- $container->get('entity_type.manager'),
- $container->get('webform.request'),
- $container->get('webform_submission.generate'),
- $container->get('webform_submission_export_import.importer')
- );
+ protected function initialize() {
+ $webform = $this->requestHandler->getCurrentWebform();
+ $source_entity = $this->requestHandler->getCurrentSourceEntity();
+ $this->importer->setWebform($webform);
+ $this->importer->setSourceEntity($source_entity);
}
/**
diff --git a/modules/webform_submission_export_import/src/Form/WebformSubmissionExportImportUploadForm.php b/modules/webform_submission_export_import/src/Form/WebformSubmissionExportImportUploadForm.php
index da4a1af8e..c2beef8de 100644
--- a/modules/webform_submission_export_import/src/Form/WebformSubmissionExportImportUploadForm.php
+++ b/modules/webform_submission_export_import/src/Form/WebformSubmissionExportImportUploadForm.php
@@ -2,7 +2,6 @@
namespace Drupal\webform_submission_export_import\Form;
-use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\ConfirmFormHelper;
@@ -13,8 +12,6 @@ use Drupal\file\Entity\File;
use Drupal\webform\Element\WebformMessage;
use Drupal\webform\Utility\WebformOptionsHelper;
use Drupal\webform\WebformInterface;
-use Drupal\webform\WebformRequestInterface;
-use Drupal\webform_submission_export_import\WebformSubmissionExportImportImporterInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\File\UploadedFile;
@@ -45,20 +42,22 @@ class WebformSubmissionExportImportUploadForm extends ConfirmFormBase {
protected $importer;
/**
- * Constructs a WebformResultsExportController object.
- *
- * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
- * The date formatter service.
- * @param \Drupal\webform\WebformRequestInterface $request_handler
- * The webform request handler.
- * @param \Drupal\webform_submission_export_import\WebformSubmissionExportImportImporterInterface $importer
- * The webform submission importer.
+ * {@inheritdoc}
*/
- public function __construct(DateFormatterInterface $date_formatter, WebformRequestInterface $request_handler, WebformSubmissionExportImportImporterInterface $importer) {
- $this->dateFormatter = $date_formatter;
- $this->requestHandler = $request_handler;
- $this->importer = $importer;
+ public static function create(ContainerInterface $container) {
+ /** @var \Drupal\webform_submission_export_import\Form\WebformSubmissionExportImportUploadForm $instance */
+ $instance = parent::create($container);
+ $instance->dateFormatter = $container->get('date.formatter');
+ $instance->requestHandler = $container->get('webform.request');
+ $instance->importer = $container->get('webform_submission_export_import.importer');
+ $instance->initialize();
+ return $instance;
+ }
+ /**
+ * Initialize WebformImageSelectImagesListBuilder object.
+ */
+ protected function initialize() {
// Initialize the importer.
$webform = $this->requestHandler->getCurrentWebform();
$source_entity = $this->requestHandler->getCurrentSourceEntity();
@@ -66,17 +65,6 @@ class WebformSubmissionExportImportUploadForm extends ConfirmFormBase {
$this->importer->setSourceEntity($source_entity);
}
- /**
- * {@inheritdoc}
- */
- public static function create(ContainerInterface $container) {
- return new static(
- $container->get('date.formatter'),
- $container->get('webform.request'),
- $container->get('webform_submission_export_import.importer')
- );
- }
-
/**
* {@inheritdoc}
*/
diff --git a/modules/webform_submission_export_import/src/Plugin/WebformExporter/WebformSubmissionExportImportWebformExporter.php b/modules/webform_submission_export_import/src/Plugin/WebformExporter/WebformSubmissionExportImportWebformExporter.php
index 256cb0222..bf5de14ca 100644
--- a/modules/webform_submission_export_import/src/Plugin/WebformExporter/WebformSubmissionExportImportWebformExporter.php
+++ b/modules/webform_submission_export_import/src/Plugin/WebformExporter/WebformSubmissionExportImportWebformExporter.php
@@ -6,6 +6,7 @@ use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\Plugin\WebformExporter\FileHandleTraitWebformExporter;
use Drupal\webform\Plugin\WebformExporterBase;
use Drupal\webform\WebformSubmissionInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Defines a machine readable CSV export that can be imported back into the current webform.
@@ -23,6 +24,22 @@ class WebformSubmissionExportImportWebformExporter extends WebformExporterBase {
use FileHandleTraitWebformExporter;
+ /**
+ * Webform submission export importer service.
+ *
+ * @var \Drupal\webform_submission_export_import\WebformSubmissionExportImportImporterInterface $importer
+ */
+ protected $importer;
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+ $instance = new static($configuration, $plugin_id, $plugin_definition);
+ $instance->importer = $container->get('webform_submission_export_import.importer');
+ return $instance;
+ }
+
/**
* {@inheritdoc}
*/
@@ -82,10 +99,8 @@ class WebformSubmissionExportImportWebformExporter extends WebformExporterBase {
* The submission importer.
*/
protected function getImporter() {
- /** @var \Drupal\webform_submission_export_import\WebformSubmissionExportImportImporterInterface $importer */
- $importer = \Drupal::service('webform_submission_export_import.importer');
- $importer->setWebform($this->getWebform());
- return $importer;
+ $this->importer->setWebform($this->getWebform());
+ return $this->importer;
}
}
diff --git a/modules/webform_submission_export_import/src/WebformSubmissionExportImportImporter.php b/modules/webform_submission_export_import/src/WebformSubmissionExportImportImporter.php
index e1edc1925..7da392c19 100644
--- a/modules/webform_submission_export_import/src/WebformSubmissionExportImportImporter.php
+++ b/modules/webform_submission_export_import/src/WebformSubmissionExportImportImporter.php
@@ -23,7 +23,7 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Yaml\Dumper;
/**
- * Webform submission export import manager.
+ * Webform submission export importer.
*/
class WebformSubmissionExportImportImporter implements WebformSubmissionExportImportImporterInterface {
diff --git a/modules/webform_submission_log/src/Controller/WebformSubmissionLogController.php b/modules/webform_submission_log/src/Controller/WebformSubmissionLogController.php
index dcf251c75..b26dcd721 100644
--- a/modules/webform_submission_log/src/Controller/WebformSubmissionLogController.php
+++ b/modules/webform_submission_log/src/Controller/WebformSubmissionLogController.php
@@ -3,14 +3,10 @@
namespace Drupal\webform_submission_log\Controller;
use Drupal\Core\Controller\ControllerBase;
-use Drupal\Core\Database\Connection;
-use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\webform\WebformInterface;
-use Drupal\webform\WebformRequestInterface;
use Drupal\webform\WebformSubmissionInterface;
-use Drupal\webform_submission_log\WebformSubmissionLogManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -69,38 +65,22 @@ class WebformSubmissionLogController extends ControllerBase {
*/
protected $logManager;
- /**
- * Constructs a WebformSubmissionLogController object.
- *
- * @param \Drupal\Core\Database\Connection $database
- * A database connection.
- * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
- * The date formatter service.
- * @param \Drupal\webform\WebformRequestInterface $request_handler
- * The webform request handler.
- * @param \Drupal\webform_submission_log\WebformSubmissionLogManagerInterface $log_manager
- * The webform submission log manager.
- */
- public function __construct(Connection $database, DateFormatterInterface $date_formatter, WebformRequestInterface $request_handler, WebformSubmissionLogManagerInterface $log_manager) {
- $this->database = $database;
- $this->dateFormatter = $date_formatter;
- $this->webformStorage = $this->entityTypeManager()->getStorage('webform');
- $this->webformSubmissionStorage = $this->entityTypeManager()->getStorage('webform_submission');
- $this->userStorage = $this->entityTypeManager()->getStorage('user');
- $this->requestHandler = $request_handler;
- $this->logManager = $log_manager;
- }
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('database'),
- $container->get('date.formatter'),
- $container->get('webform.request'),
- $container->get('webform_submission_log.manager')
- );
+ /** @var \Drupal\webform_submission_log\Controller\WebformSubmissionLogController $instance */
+ $instance = parent::create($container);
+ $instance->database = $container->get('database');
+ $instance->dateFormatter = $container->get('date.formatter');
+ $instance->requestHandler = $container->get('webform.request');
+ $instance->logManager = $container->get('webform_submission_log.manager');
+ $instance->entityTypeManager = $container->get('entity_type.manager');
+ $instance->webformStorage = $instance->entityTypeManager->getStorage('webform');
+ $instance->webformSubmissionStorage = $instance->entityTypeManager->getStorage('webform_submission');
+ $instance->userStorage = $instance->entityTypeManager->getStorage('user');
+ return $instance;
}
/**
diff --git a/modules/webform_templates/src/Controller/WebformTemplatesController.php b/modules/webform_templates/src/Controller/WebformTemplatesController.php
index 700ee7d54..55f8c6a5a 100644
--- a/modules/webform_templates/src/Controller/WebformTemplatesController.php
+++ b/modules/webform_templates/src/Controller/WebformTemplatesController.php
@@ -4,9 +4,6 @@ namespace Drupal\webform_templates\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
-use Drupal\Core\Entity\EntityTypeManagerInterface;
-use Drupal\Core\Form\FormBuilderInterface;
-use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\webform\Utility\WebformDialogHelper;
use Drupal\webform\WebformInterface;
@@ -28,7 +25,7 @@ class WebformTemplatesController extends ControllerBase implements ContainerInje
protected $currentUser;
/**
- * The webform builder.
+ * The form builder.
*
* @var \Drupal\Core\Form\FormBuilderInterface
*/
@@ -41,31 +38,15 @@ class WebformTemplatesController extends ControllerBase implements ContainerInje
*/
protected $webformStorage;
- /**
- * Constructs a WebformTemplatesController object.
- *
- * @param \Drupal\Core\Session\AccountInterface $current_user
- * The current user.
- * @param \Drupal\Core\Form\FormBuilderInterface $form_builder
- * The webform builder.
- * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
- * The entity type manager.
- */
- public function __construct(AccountInterface $current_user, FormBuilderInterface $form_builder, EntityTypeManagerInterface $entity_type_manager) {
- $this->currentUser = $current_user;
- $this->formBuilder = $form_builder;
- $this->webformStorage = $entity_type_manager->getStorage('webform');
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('current_user'),
- $container->get('form_builder'),
- $container->get('entity_type.manager')
- );
+ $instance = parent::create($container);
+ $instance->currentUser = $container->get('current_user');
+ $instance->formBuilder = $container->get('form_builder');
+ $instance->webformStorage = $container->get('entity_type.manager')->getStorage('webform');
+ return $instance;
}
/**
diff --git a/modules/webform_templates/src/Form/WebformTemplatesFilterForm.php b/modules/webform_templates/src/Form/WebformTemplatesFilterForm.php
index 3ee593682..d149e4b4a 100644
--- a/modules/webform_templates/src/Form/WebformTemplatesFilterForm.php
+++ b/modules/webform_templates/src/Form/WebformTemplatesFilterForm.php
@@ -2,7 +2,6 @@
namespace Drupal\webform_templates\Form;
-use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -26,23 +25,13 @@ class WebformTemplatesFilterForm extends FormBase {
*/
protected $webformStorage;
- /**
- * Constructs a WebformResultsCustomForm object.
- *
- * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
- * The entity type manager.
- */
- public function __construct(EntityTypeManagerInterface $entity_type_manager) {
- $this->webformStorage = $entity_type_manager->getStorage('webform');
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('entity_type.manager')
- );
+ $instance = parent::create($container);
+ $instance->webformStorage = $container->get('entity_type.manager')->getStorage('webform');
+ return $instance;
}
/**
diff --git a/modules/webform_ui/src/Form/WebformUiElementDeleteForm.php b/modules/webform_ui/src/Form/WebformUiElementDeleteForm.php
index 20b482751..04e948970 100644
--- a/modules/webform_ui/src/Form/WebformUiElementDeleteForm.php
+++ b/modules/webform_ui/src/Form/WebformUiElementDeleteForm.php
@@ -4,11 +4,8 @@ namespace Drupal\webform_ui\Form;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Form\FormStateInterface;
-use Drupal\Core\Render\RendererInterface;
use Drupal\webform\Form\WebformDeleteFormBase;
-use Drupal\webform\Plugin\WebformElementManagerInterface;
use Drupal\webform\Plugin\WebformElementVariantInterface;
-use Drupal\webform\WebformEntityElementsValidatorInterface;
use Drupal\webform\WebformInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -67,31 +64,15 @@ class WebformUiElementDeleteForm extends WebformDeleteFormBase {
*/
protected $element;
- /**
- * Constructs a WebformUiElementDeleteForm.
- *
- * @param \Drupal\Core\Render\RendererInterface $renderer
- * The renderer.
- * @param \Drupal\webform\Plugin\WebformElementManagerInterface $element_manager
- * The webform element manager.
- * @param \Drupal\webform\WebformEntityElementsValidatorInterface $elements_validator
- * Webform element validator.
- */
- public function __construct(RendererInterface $renderer, WebformElementManagerInterface $element_manager, WebformEntityElementsValidatorInterface $elements_validator) {
- $this->renderer = $renderer;
- $this->elementManager = $element_manager;
- $this->elementsValidator = $elements_validator;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('renderer'),
- $container->get('plugin.manager.webform.element'),
- $container->get('webform.elements_validator')
- );
+ $instance = parent::create($container);
+ $instance->renderer = $container->get('renderer');
+ $instance->elementManager = $container->get('plugin.manager.webform.element');
+ $instance->elementsValidator = $container->get('webform.elements_validator');
+ return $instance;
}
/****************************************************************************/
diff --git a/modules/webform_ui/src/Form/WebformUiElementFormBase.php b/modules/webform_ui/src/Form/WebformUiElementFormBase.php
index 4aabaad1a..211a96923 100644
--- a/modules/webform_ui/src/Form/WebformUiElementFormBase.php
+++ b/modules/webform_ui/src/Form/WebformUiElementFormBase.php
@@ -4,20 +4,15 @@ namespace Drupal\webform_ui\Form;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\NestedArray;
-use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\SubformState;
-use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Url;
use Drupal\webform\Plugin\WebformElementVariantInterface;
use Drupal\webform\Utility\WebformDialogHelper;
use Drupal\webform\Form\WebformDialogFormTrait;
-use Drupal\webform\Plugin\WebformElementManagerInterface;
use Drupal\webform\Utility\WebformYaml;
-use Drupal\webform\WebformEntityElementsValidatorInterface;
use Drupal\webform\WebformInterface;
-use Drupal\webform\WebformTokenManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -131,39 +126,17 @@ abstract class WebformUiElementFormBase extends FormBase implements WebformUiEle
return 'webform_ui_element_form';
}
- /**
- * Constructs a WebformUiElementFormBase.
- *
- * @param \Drupal\Core\Render\RendererInterface $renderer
- * The renderer.
- * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
- * The entity field manager.
- * @param \Drupal\webform\Plugin\WebformElementManagerInterface $element_manager
- * The webform element manager.
- * @param \Drupal\webform\WebformEntityElementsValidatorInterface $elements_validator
- * Webform element validator.
- * @param \Drupal\webform\WebformTokenManagerInterface $token_manager
- * The webform token manager.
- */
- public function __construct(RendererInterface $renderer, EntityFieldManagerInterface $entity_field_manager, WebformElementManagerInterface $element_manager, WebformEntityElementsValidatorInterface $elements_validator, WebformTokenManagerInterface $token_manager) {
- $this->renderer = $renderer;
- $this->entityFieldManager = $entity_field_manager;
- $this->elementManager = $element_manager;
- $this->elementsValidator = $elements_validator;
- $this->tokenManager = $token_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('renderer'),
- $container->get('entity_field.manager'),
- $container->get('plugin.manager.webform.element'),
- $container->get('webform.elements_validator'),
- $container->get('webform.token_manager')
- );
+ $instance = parent::create($container);
+ $instance->renderer = $container->get('renderer');
+ $instance->entityFieldManager = $container->get('entity_field.manager');
+ $instance->elementManager = $container->get('plugin.manager.webform.element');
+ $instance->elementsValidator = $container->get('webform.elements_validator');
+ $instance->tokenManager = $container->get('webform.token_manager');
+ return $instance;
}
/**
diff --git a/modules/webform_ui/src/Form/WebformUiElementTypeFormBase.php b/modules/webform_ui/src/Form/WebformUiElementTypeFormBase.php
index 7dc9a6385..436bee0dd 100644
--- a/modules/webform_ui/src/Form/WebformUiElementTypeFormBase.php
+++ b/modules/webform_ui/src/Form/WebformUiElementTypeFormBase.php
@@ -6,15 +6,12 @@ use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\HtmlCommand;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
-use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
-use Drupal\user\UserDataInterface;
use Drupal\webform\Entity\Webform;
use Drupal\webform\Entity\WebformSubmission;
use Drupal\webform\Form\WebformDialogFormTrait;
use Drupal\webform\Plugin\WebformElement\WebformManagedFileBase;
use Drupal\webform\Plugin\WebformElementInterface;
-use Drupal\webform\Plugin\WebformElementManagerInterface;
use Drupal\webform\Utility\WebformDialogHelper;
use Drupal\webform\WebformInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -61,34 +58,17 @@ abstract class WebformUiElementTypeFormBase extends FormBase {
*/
protected $webformSubmission;
- /**
- * Constructs a WebformUiElementTypeFormBase object.
- *
- * @param \Drupal\webform\Plugin\WebformElementManagerInterface $element_manager
- * The webform element manager.
- * @param \Drupal\Core\Session\AccountInterface $current_user
- * The current user.
- * @param \Drupal\user\UserDataInterface $user_data
- * The user data service.
- */
- public function __construct(WebformElementManagerInterface $element_manager, AccountInterface $current_user, UserDataInterface $user_data) {
- $this->elementManager = $element_manager;
- $this->currentUser = $current_user;
- $this->userData = $user_data;
-
- $this->webform = Webform::create(['id' => '_webform_ui_temp_form']);
- $this->webformSubmission = WebformSubmission::create(['webform' => $this->webform]);
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('plugin.manager.webform.element'),
- $container->get('current_user'),
- $container->get('user.data')
- );
+ $instance = parent::create($container);
+ $instance->elementManager = $container->get('plugin.manager.webform.element');
+ $instance->currentUser = $container->get('current_user');
+ $instance->userData = $container->get('user.data');
+ $instance->webform = Webform::create(['id' => '_webform_ui_temp_form']);
+ $instance->webformSubmission = WebformSubmission::create(['webform' => $instance->webform]);
+ return $instance;
}
/**
diff --git a/modules/webform_ui/src/WebformUiEntityElementsForm.php b/modules/webform_ui/src/WebformUiEntityElementsForm.php
index ecf761bc9..b04c628a4 100644
--- a/modules/webform_ui/src/WebformUiEntityElementsForm.php
+++ b/modules/webform_ui/src/WebformUiEntityElementsForm.php
@@ -9,15 +9,11 @@ use Drupal\Core\Serialization\Yaml;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
-use Drupal\Core\Render\ElementInfoManagerInterface;
-use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Url;
use Drupal\webform\Element\WebformElementStates;
use Drupal\webform\Form\WebformEntityAjaxFormTrait;
use Drupal\webform\Plugin\WebformElement\WebformElement;
use Drupal\webform\Utility\WebformDialogHelper;
-use Drupal\webform\Plugin\WebformElementManagerInterface;
-use Drupal\webform\WebformEntityElementsValidatorInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -74,35 +70,16 @@ class WebformUiEntityElementsForm extends BundleEntityFormBase {
*/
protected $tokenManager;
- /**
- * Constructs a WebformUiEntityElementsForm.
- *
- * @param \Drupal\Core\Render\RendererInterface $renderer
- * The renderer.
- * @param \Drupal\Core\Render\ElementInfoManagerInterface $element_info
- * The element manager.
- * @param \Drupal\webform\Plugin\WebformElementManagerInterface $element_manager
- * The webform element manager.
- * @param \Drupal\webform\WebformEntityElementsValidatorInterface $elements_validator
- * Webform element validator.
- */
- public function __construct(RendererInterface $renderer, ElementInfoManagerInterface $element_info, WebformElementManagerInterface $element_manager, WebformEntityElementsValidatorInterface $elements_validator) {
- $this->renderer = $renderer;
- $this->elementInfo = $element_info;
- $this->elementManager = $element_manager;
- $this->elementsValidator = $elements_validator;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('renderer'),
- $container->get('plugin.manager.element_info'),
- $container->get('plugin.manager.webform.element'),
- $container->get('webform.elements_validator')
- );
+ $instance = parent::create($container);
+ $instance->renderer = $container->get('renderer');
+ $instance->elementInfo = $container->get('plugin.manager.element_info');
+ $instance->elementManager = $container->get('plugin.manager.webform.element');
+ $instance->elementsValidator = $container->get('webform.elements_validator');
+ return $instance;
}
/**
diff --git a/src/Controller/WebformAddonsController.php b/src/Controller/WebformAddonsController.php
index 3ad77429d..695bf806d 100644
--- a/src/Controller/WebformAddonsController.php
+++ b/src/Controller/WebformAddonsController.php
@@ -6,10 +6,7 @@ use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Render\Markup;
use Drupal\webform\Element\WebformMessage;
-use Drupal\webform\WebformAddonsManagerInterface;
-use Drupal\webform\WebformThemeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
-use Symfony\Component\HttpFoundation\RequestStack;
/**
* Provides route responses for Webform add-ons.
@@ -37,31 +34,15 @@ class WebformAddonsController extends ControllerBase implements ContainerInjecti
*/
protected $addons;
- /**
- * Constructs a WebformAddonsController object.
- *
- * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
- * The request stack.
- * @param \Drupal\webform\WebformThemeManagerInterface $theme_manager
- * The webform theme manager.
- * @param \Drupal\webform\WebformAddonsManagerInterface $addons
- * The webform add-ons manager.
- */
- public function __construct(RequestStack $request_stack, WebformThemeManagerInterface $theme_manager, WebformAddonsManagerInterface $addons) {
- $this->request = $request_stack->getCurrentRequest();
- $this->themeManager = $theme_manager;
- $this->addons = $addons;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('request_stack'),
- $container->get('webform.theme_manager'),
- $container->get('webform.addons_manager')
- );
+ $instance = parent::create($container);
+ $instance->request = $container->get('request_stack')->getCurrentRequest();
+ $instance->themeManager = $container->get('webform.theme_manager');
+ $instance->addons = $container->get('webform.addons_manager');
+ return $instance;
}
/**
diff --git a/src/Controller/WebformEntityController.php b/src/Controller/WebformEntityController.php
index 55343e879..2da8c1188 100644
--- a/src/Controller/WebformEntityController.php
+++ b/src/Controller/WebformEntityController.php
@@ -6,14 +6,10 @@ use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Entity\EntityInterface;
-use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Serialization\Yaml;
use Drupal\webform\Element\Webform as WebformElement;
-use Drupal\webform\WebformEntityReferenceManagerInterface;
use Drupal\webform\WebformInterface;
-use Drupal\webform\WebformRequestInterface;
use Drupal\webform\WebformSubmissionInterface;
-use Drupal\webform\WebformTokenManagerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -52,31 +48,14 @@ class WebformEntityController extends ControllerBase implements ContainerInjecti
*/
protected $webformEntityReferenceManager;
- /**
- * Constructs a WebformEntityController object.
- *
- * @param \Drupal\Core\Render\RendererInterface $renderer
- * The renderer service.
- * @param \Drupal\webform\WebformRequestInterface $request_handler
- * The webform request handler.
- * @param \Drupal\webform\WebformTokenManagerInterface $token_manager
- * The webform token manager.
- */
- public function __construct(RendererInterface $renderer, WebformRequestInterface $request_handler, WebformTokenManagerInterface $token_manager) {
- $this->renderer = $renderer;
- $this->requestHandler = $request_handler;
- $this->tokenManager = $token_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- $instance = new static(
- $container->get('renderer'),
- $container->get('webform.request'),
- $container->get('webform.token_manager')
- );
+ $instance = parent::create($container);
+ $instance->renderer = $container->get('renderer');
+ $instance->requestHandler = $container->get('webform.request');
+ $instance->tokenManager = $container->get('webform.token_manager');
$instance->webformEntityReferenceManager = $container->get('webform.entity_reference_manager');
return $instance;
}
diff --git a/src/Controller/WebformHelpController.php b/src/Controller/WebformHelpController.php
index 280fd8861..72fd0d95a 100644
--- a/src/Controller/WebformHelpController.php
+++ b/src/Controller/WebformHelpController.php
@@ -4,7 +4,6 @@ namespace Drupal\webform\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
-use Drupal\webform\WebformHelpManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -19,23 +18,13 @@ class WebformHelpController extends ControllerBase implements ContainerInjection
*/
protected $help;
- /**
- * Constructs a WebformHelpController object.
- *
- * @param \Drupal\webform\WebformHelpManagerInterface $help
- * The webform help manager.
- */
- public function __construct(WebformHelpManagerInterface $help) {
- $this->help = $help;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('webform.help_manager')
- );
+ $instance = parent::create($container);
+ $instance->help = $container->get('webform.help_manager');
+ return $instance;
}
/**
diff --git a/src/Controller/WebformPluginElementController.php b/src/Controller/WebformPluginElementController.php
index 63cd55970..328eada47 100644
--- a/src/Controller/WebformPluginElementController.php
+++ b/src/Controller/WebformPluginElementController.php
@@ -4,14 +4,9 @@ namespace Drupal\webform\Controller;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
-use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Controller\ControllerBase;
-use Drupal\Core\Render\ElementInfoManagerInterface;
-use Drupal\Core\Serialization\Yaml;
use Drupal\Core\Url;
-use Drupal\webform\Utility\WebformElementHelper;
use Drupal\webform\Utility\WebformReflectionHelper;
-use Drupal\webform\Plugin\WebformElementManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -40,31 +35,15 @@ class WebformPluginElementController extends ControllerBase implements Container
*/
protected $elementManager;
- /**
- * Constructs a WebformPluginElementController object.
- *
- * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
- * The module handler.
- * @param \Drupal\Core\Render\ElementInfoManagerInterface $element_info
- * A element info plugin manager.
- * @param \Drupal\webform\Plugin\WebformElementManagerInterface $element_manager
- * A webform element plugin manager.
- */
- public function __construct(ModuleHandlerInterface $module_handler, ElementInfoManagerInterface $element_info, WebformElementManagerInterface $element_manager) {
- $this->moduleHandler = $module_handler;
- $this->elementInfo = $element_info;
- $this->elementManager = $element_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('module_handler'),
- $container->get('plugin.manager.element_info'),
- $container->get('plugin.manager.webform.element')
- );
+ $instance = parent::create($container);
+ $instance->moduleHandler = $container->get('module_handler');
+ $instance->elementInfo = $container->get('plugin.manager.element_info');
+ $instance->elementManager = $container->get('plugin.manager.webform.element');
+ return $instance;
}
/**
diff --git a/src/Controller/WebformPluginExporterController.php b/src/Controller/WebformPluginExporterController.php
index f6920a112..9bfa9d7ca 100644
--- a/src/Controller/WebformPluginExporterController.php
+++ b/src/Controller/WebformPluginExporterController.php
@@ -3,7 +3,6 @@
namespace Drupal\webform\Controller;
use Drupal\Core\Controller\ControllerBase;
-use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -20,23 +19,13 @@ class WebformPluginExporterController extends ControllerBase implements Containe
*/
protected $pluginManager;
- /**
- * Constructs a WebformPluginExporterController object.
- *
- * @param \Drupal\Component\Plugin\PluginManagerInterface $plugin_manager
- * A results exporter plugin manager.
- */
- public function __construct(PluginManagerInterface $plugin_manager) {
- $this->pluginManager = $plugin_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('plugin.manager.webform.exporter')
- );
+ $instance = parent::create($container);
+ $instance->pluginManager = $container->get('plugin.manager.webform.exporter');
+ return $instance;
}
/**
diff --git a/src/Controller/WebformPluginHandlerController.php b/src/Controller/WebformPluginHandlerController.php
index 7079d9bae..21d1d934b 100644
--- a/src/Controller/WebformPluginHandlerController.php
+++ b/src/Controller/WebformPluginHandlerController.php
@@ -2,7 +2,6 @@
namespace Drupal\webform\Controller;
-use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Url;
@@ -24,23 +23,13 @@ class WebformPluginHandlerController extends ControllerBase implements Container
*/
protected $pluginManager;
- /**
- * Constructs a WebformPluginHandlerController object.
- *
- * @param \Drupal\Component\Plugin\PluginManagerInterface $plugin_manager
- * A webform handler plugin manager.
- */
- public function __construct(PluginManagerInterface $plugin_manager) {
- $this->pluginManager = $plugin_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('plugin.manager.webform.handler')
- );
+ $instance = parent::create($container);
+ $instance->pluginManager = $container->get('plugin.manager.webform.handler');
+ return $instance;
}
/**
diff --git a/src/Controller/WebformResultsExportController.php b/src/Controller/WebformResultsExportController.php
index add60abd8..0e933aa02 100644
--- a/src/Controller/WebformResultsExportController.php
+++ b/src/Controller/WebformResultsExportController.php
@@ -9,11 +9,8 @@ use Drupal\Core\Url;
use Drupal\webform\Entity\Webform;
use Drupal\webform\Entity\WebformSubmission;
use Drupal\webform\WebformInterface;
-use Drupal\webform\WebformRequestInterface;
-use Drupal\webform\WebformSubmissionExporterInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
-use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
@@ -43,31 +40,15 @@ class WebformResultsExportController extends ControllerBase implements Container
*/
protected $requestHandler;
- /**
- * Constructs a WebformResultsExportController object.
- *
- * @param \Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface $mime_type_guesser
- * The MIME type guesser instance to use.
- * @param \Drupal\webform\WebformSubmissionExporterInterface $webform_submission_exporter
- * The webform submission exported.
- * @param \Drupal\webform\WebformRequestInterface $request_handler
- * The webform request handler.
- */
- public function __construct(MimeTypeGuesserInterface $mime_type_guesser, WebformSubmissionExporterInterface $webform_submission_exporter, WebformRequestInterface $request_handler) {
- $this->mimeTypeGuesser = $mime_type_guesser;
- $this->submissionExporter = $webform_submission_exporter;
- $this->requestHandler = $request_handler;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('file.mime_type.guesser'),
- $container->get('webform_submission.exporter'),
- $container->get('webform.request')
- );
+ $instance = parent::create($container);
+ $instance->mimeTypeGuesser = $container->get('file.mime_type.guesser');
+ $instance->submissionExporter = $container->get('webform_submission.exporter');
+ $instance->requestHandler = $container->get('webform.request');
+ return $instance;
}
/**
diff --git a/src/Controller/WebformSubmissionController.php b/src/Controller/WebformSubmissionController.php
index 0c28a70aa..c66a72c49 100644
--- a/src/Controller/WebformSubmissionController.php
+++ b/src/Controller/WebformSubmissionController.php
@@ -7,12 +7,9 @@ use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\AnnounceCommand;
use Drupal\Core\Ajax\HtmlCommand;
use Drupal\Core\Controller\ControllerBase;
-use Drupal\Core\Render\RendererInterface;
use Drupal\webform\Element\WebformHtmlEditor;
use Drupal\webform\WebformInterface;
use Drupal\webform\WebformSubmissionInterface;
-use Drupal\webform\WebformRequestInterface;
-use Drupal\webform\WebformTokenManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -41,31 +38,15 @@ class WebformSubmissionController extends ControllerBase {
*/
protected $tokenManager;
- /**
- * Constructs a WebformSubmissionController object.
- *
- * @param \Drupal\Core\Render\RendererInterface $renderer
- * The renderer service.
- * @param \Drupal\webform\WebformRequestInterface $request_handler
- * The webform request handler.
- * @param \Drupal\webform\WebformTokenManagerInterface $token_manager
- * The webform token manager.
- */
- public function __construct(RendererInterface $renderer, WebformRequestInterface $request_handler, WebformTokenManagerInterface $token_manager) {
- $this->renderer = $renderer;
- $this->requestHandler = $request_handler;
- $this->tokenManager = $token_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('renderer'),
- $container->get('webform.request'),
- $container->get('webform.token_manager')
- );
+ $instance = parent::create($container);
+ $instance->renderer = $container->get('renderer');
+ $instance->requestHandler = $container->get('webform.request');
+ $instance->tokenManager = $container->get('webform.token_manager');
+ return $instance;
}
/**
diff --git a/src/Controller/WebformSubmissionViewController.php b/src/Controller/WebformSubmissionViewController.php
index baeaf69e9..f667a7f50 100644
--- a/src/Controller/WebformSubmissionViewController.php
+++ b/src/Controller/WebformSubmissionViewController.php
@@ -4,11 +4,7 @@ namespace Drupal\webform\Controller;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Controller\EntityViewController;
-use Drupal\Core\Entity\EntityManagerInterface;
-use Drupal\Core\Render\RendererInterface;
-use Drupal\Core\Session\AccountInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
-use Drupal\webform\WebformRequestInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -32,34 +28,14 @@ class WebformSubmissionViewController extends EntityViewController {
*/
protected $requestHandler;
- /**
- * Creates an WebformSubmissionViewController object.
- *
- * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
- * The entity manager.
- * @param \Drupal\Core\Render\RendererInterface $renderer
- * The renderer service.
- * @param \Drupal\Core\Session\AccountInterface $current_user
- * The current user.
- * @param \Drupal\webform\WebformRequestInterface $webform_request
- * The webform request handler.
- */
- public function __construct(EntityManagerInterface $entity_manager, RendererInterface $renderer, AccountInterface $current_user, WebformRequestInterface $webform_request) {
- parent::__construct($entity_manager, $renderer);
- $this->currentUser = $current_user;
- $this->requestHandler = $webform_request;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('entity.manager'),
- $container->get('renderer'),
- $container->get('current_user'),
- $container->get('webform.request')
- );
+ $instance = parent::create($container);
+ $instance->currentUser = $container->get('current_user');
+ $instance->requestHandler = $container->get('webform.request');
+ return $instance;
}
/**
diff --git a/src/Controller/WebformSubmissionsController.php b/src/Controller/WebformSubmissionsController.php
index 0bef80d2d..e154efbf2 100644
--- a/src/Controller/WebformSubmissionsController.php
+++ b/src/Controller/WebformSubmissionsController.php
@@ -22,23 +22,13 @@ class WebformSubmissionsController extends ControllerBase {
*/
protected $entityRepository;
- /**
- * Constructs a WebformSubmissionsController object.
- *
- * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
- * The entity repository.
- */
- public function __construct(EntityRepositoryInterface $entity_repository) {
- $this->entityRepository = $entity_repository;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('entity.repository')
- );
+ $instance = parent::create($container);
+ $instance->entityRepository = $container->get('entity.repository');
+ return $instance ;
}
/**
diff --git a/src/Controller/WebformTestController.php b/src/Controller/WebformTestController.php
index 78b6624d0..2d865ab1b 100644
--- a/src/Controller/WebformTestController.php
+++ b/src/Controller/WebformTestController.php
@@ -4,11 +4,8 @@ namespace Drupal\webform\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
-use Drupal\Core\Messenger\MessengerInterface;
use Drupal\webform\Plugin\WebformHandler\EmailWebformHandler;
use Drupal\webform\WebformInterface;
-use Drupal\webform\WebformRequestInterface;
-use Drupal\webform\WebformSubmissionGenerateInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
@@ -39,31 +36,15 @@ class WebformTestController extends ControllerBase implements ContainerInjection
*/
protected $generate;
- /**
- * Constructs a WebformTestController object.
- *
- * @param \Drupal\Core\Messenger\MessengerInterface $messenger
- * The messenger.
- * @param \Drupal\webform\WebformRequestInterface $request_handler
- * The webform request handler.
- * @param \Drupal\webform\WebformSubmissionGenerateInterface $submission_generate
- * The webform submission generation service.
- */
- public function __construct(MessengerInterface $messenger, WebformRequestInterface $request_handler, WebformSubmissionGenerateInterface $submission_generate) {
- $this->messenger = $messenger;
- $this->requestHandler = $request_handler;
- $this->generate = $submission_generate;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('messenger'),
- $container->get('webform.request'),
- $container->get('webform_submission.generate')
- );
+ $instance = parent::create($container);
+ $instance->messenger = $container->get('messenger');
+ $instance->requestHandler = $container->get('webform.request');
+ $instance->generate = $container->get('webform_submission.generate');
+ return $instance;
}
/**
diff --git a/src/EntitySettings/WebformEntitySettingsAccessForm.php b/src/EntitySettings/WebformEntitySettingsAccessForm.php
index 43481afb5..449ca20b6 100644
--- a/src/EntitySettings/WebformEntitySettingsAccessForm.php
+++ b/src/EntitySettings/WebformEntitySettingsAccessForm.php
@@ -3,7 +3,6 @@
namespace Drupal\webform\EntitySettings;
use Drupal\Core\Form\FormStateInterface;
-use Drupal\webform\WebformAccessRulesManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -18,23 +17,13 @@ class WebformEntitySettingsAccessForm extends WebformEntitySettingsBaseForm {
*/
protected $accessRulesManager;
- /**
- * WebformEntitySettingsAccessForm constructor.
- *
- * @param \Drupal\webform\WebformAccessRulesManagerInterface $access_rules_manager
- * Webform access rules manager.
- */
- public function __construct(WebformAccessRulesManagerInterface $access_rules_manager) {
- $this->accessRulesManager = $access_rules_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('webform.access_rules_manager')
- );
+ $instance = parent::create($container);
+ $instance->accessRulesManager = $container->get('webform.access_rules_manager');
+ return $instance;
}
/**
diff --git a/src/EntitySettings/WebformEntitySettingsConfirmationForm.php b/src/EntitySettings/WebformEntitySettingsConfirmationForm.php
index 6325ca4c9..4edfb2c16 100644
--- a/src/EntitySettings/WebformEntitySettingsConfirmationForm.php
+++ b/src/EntitySettings/WebformEntitySettingsConfirmationForm.php
@@ -5,7 +5,6 @@ namespace Drupal\webform\EntitySettings;
use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\Element\WebformMessage;
use Drupal\webform\WebformInterface;
-use Drupal\webform\WebformTokenManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -19,24 +18,13 @@ class WebformEntitySettingsConfirmationForm extends WebformEntitySettingsBaseFor
* @var \Drupal\webform\WebformTokenManagerInterface
*/
protected $tokenManager;
-
- /**
- * Constructs a WebformEntitySettingsConfirmationForm.
- *
- * @param \Drupal\webform\WebformTokenManagerInterface $token_manager
- * The webform token manager.
- */
- public function __construct(WebformTokenManagerInterface $token_manager) {
- $this->tokenManager = $token_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('webform.token_manager')
- );
+ $instance = parent::create($container);
+ $instance->tokenManager = $container->get('webform.token_manager');
+ return $instance;
}
/**
diff --git a/src/EntitySettings/WebformEntitySettingsFormForm.php b/src/EntitySettings/WebformEntitySettingsFormForm.php
index b9a270631..a4b531372 100644
--- a/src/EntitySettings/WebformEntitySettingsFormForm.php
+++ b/src/EntitySettings/WebformEntitySettingsFormForm.php
@@ -10,7 +10,6 @@ use Drupal\webform\Utility\WebformArrayHelper;
use Drupal\webform\Utility\WebformDateHelper;
use Drupal\webform\Utility\WebformElementHelper;
use Drupal\webform\WebformInterface;
-use Drupal\webform\WebformTokenManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -25,23 +24,13 @@ class WebformEntitySettingsFormForm extends WebformEntitySettingsBaseForm {
*/
protected $tokenManager;
- /**
- * Constructs a WebformEntitySettingsFormForm.
- *
- * @param \Drupal\webform\WebformTokenManagerInterface $token_manager
- * The webform token manager.
- */
- public function __construct(WebformTokenManagerInterface $token_manager) {
- $this->tokenManager = $token_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('webform.token_manager')
- );
+ $instance = parent::create($container);
+ $instance->tokenManager = $container->get('webform.token_manager');
+ return $instance;
}
/**
diff --git a/src/EntitySettings/WebformEntitySettingsGeneralForm.php b/src/EntitySettings/WebformEntitySettingsGeneralForm.php
index b8058dca5..1c9ff27b4 100644
--- a/src/EntitySettings/WebformEntitySettingsGeneralForm.php
+++ b/src/EntitySettings/WebformEntitySettingsGeneralForm.php
@@ -8,7 +8,6 @@ use Drupal\Core\Render\Element;
use Drupal\Core\Url;
use Drupal\webform\Plugin\WebformHandlerInterface;
use Drupal\webform\WebformMessageManagerInterface;
-use Drupal\webform\WebformThirdPartySettingsManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -30,27 +29,14 @@ class WebformEntitySettingsGeneralForm extends WebformEntitySettingsBaseForm {
*/
protected $thirdPartySettingsManager;
- /**
- * Constructs a WebformEntitySettingsGeneralForm.
- *
- * @param \Drupal\webform\WebformMessageManagerInterface $message_manager
- * The webform message manager.
- * @param \Drupal\webform\WebformThirdPartySettingsManagerInterface $third_party_settings_manager
- * The webform third party settings manager.
- */
- public function __construct(WebformMessageManagerInterface $message_manager, WebformThirdPartySettingsManagerInterface $third_party_settings_manager) {
- $this->messageManager = $message_manager;
- $this->thirdPartySettingsManager = $third_party_settings_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('webform.message_manager'),
- $container->get('webform.third_party_settings_manager')
- );
+ $instance = parent::create($container);
+ $instance->messageManager = $container->get('webform.message_manager');
+ $instance->thirdPartySettingsManager = $container->get('webform.third_party_settings_manager');
+ return $instance;
}
/**
diff --git a/src/EntitySettings/WebformEntitySettingsSubmissionsForm.php b/src/EntitySettings/WebformEntitySettingsSubmissionsForm.php
index 35b8cf6de..ed9d51a21 100644
--- a/src/EntitySettings/WebformEntitySettingsSubmissionsForm.php
+++ b/src/EntitySettings/WebformEntitySettingsSubmissionsForm.php
@@ -9,7 +9,6 @@ use Drupal\webform\Element\WebformMessage;
use Drupal\webform\Utility\WebformDateHelper;
use Drupal\webform\WebformInterface;
use Drupal\webform\WebformSubmissionStorageInterface;
-use Drupal\webform\WebformTokenManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -24,23 +23,13 @@ class WebformEntitySettingsSubmissionsForm extends WebformEntitySettingsBaseForm
*/
protected $tokenManager;
- /**
- * Constructs a WebformEntitySettingsForm.
- *
- * @param \Drupal\webform\WebformTokenManagerInterface $token_manager
- * The webform token manager.
- */
- public function __construct(WebformTokenManagerInterface $token_manager) {
- $this->tokenManager = $token_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('webform.token_manager')
- );
+ $instance = parent::create($container);
+ $instance->tokenManager = $container->get('webform.token_manager');
+ return $instance;
}
/**
diff --git a/src/Form/AdminConfig/WebformAdminConfigAdvancedForm.php b/src/Form/AdminConfig/WebformAdminConfigAdvancedForm.php
index 6aebc2851..a3a05cf96 100644
--- a/src/Form/AdminConfig/WebformAdminConfigAdvancedForm.php
+++ b/src/Form/AdminConfig/WebformAdminConfigAdvancedForm.php
@@ -2,13 +2,8 @@
namespace Drupal\webform\Form\AdminConfig;
-use Drupal\Core\Cache\CacheBackendInterface;
-use Drupal\Core\Config\ConfigFactoryInterface;
-use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormStateInterface;
-use Drupal\Core\Routing\RouteBuilderInterface;
use Drupal\Core\Url;
-use Drupal\webform\Commands\WebformCliService;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -51,39 +46,16 @@ class WebformAdminConfigAdvancedForm extends WebformAdminConfigBaseForm {
return 'webform_admin_config_advanced_form';
}
- /**
- * Constructs a WebformAdminConfigAdvancedForm object.
- *
- * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
- * The factory for configuration objects.
- * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
- * The module handler.
- * @param \Drupal\Core\Cache\CacheBackendInterface $render_cache
- * The render cache service.
- * @param \Drupal\Core\Routing\RouteBuilderInterface $router_builder
- * The router builder service.
- * @param \Drupal\webform\Commands\WebformCliService $cli_service
- * The (drush) command-line service.
- */
- public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, CacheBackendInterface $render_cache, RouteBuilderInterface $router_builder, WebformCliService $cli_service) {
- parent::__construct($config_factory);
- $this->renderCache = $render_cache;
- $this->moduleHandler = $module_handler;
- $this->routerBuilder = $router_builder;
- $this->cliService = $cli_service;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('config.factory'),
- $container->get('module_handler'),
- $container->get('cache.render'),
- $container->get('router.builder'),
- $container->get('webform.cli_service')
- );
+ $instance = parent::create($container);
+ $instance->renderCache = $container->get('cache.render');
+ $instance->moduleHandler = $container->get('module_handler');
+ $instance->routerBuilder = $container->get('router.builder');
+ $instance->cliService = $container->get('webform.cli_service');
+ return $instance;
}
/**
diff --git a/src/Form/AdminConfig/WebformAdminConfigElementsForm.php b/src/Form/AdminConfig/WebformAdminConfigElementsForm.php
index 62762eb0a..20224eeaa 100644
--- a/src/Form/AdminConfig/WebformAdminConfigElementsForm.php
+++ b/src/Form/AdminConfig/WebformAdminConfigElementsForm.php
@@ -5,16 +5,11 @@ namespace Drupal\webform\Form\AdminConfig;
use Drupal\Component\Utility\Bytes;
use Drupal\Component\Utility\Environment;
use Drupal\Component\Utility\Xss;
-use Drupal\Core\Config\ConfigFactoryInterface;
-use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\file\Plugin\Field\FieldType\FileItem;
use Drupal\webform\Element\WebformMessage;
use Drupal\webform\Utility\WebformArrayHelper;
use Drupal\webform\Utility\WebformOptionsHelper;
-use Drupal\webform\Plugin\WebformElementManagerInterface;
-use Drupal\webform\WebformLibrariesManagerInterface;
-use Drupal\webform\WebformTokenManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -57,39 +52,16 @@ class WebformAdminConfigElementsForm extends WebformAdminConfigBaseForm {
return 'webform_admin_config_elements_form';
}
- /**
- * Constructs a WebformAdminConfigElementsForm object.
- *
- * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
- * The factory for configuration objects.
- * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
- * The module handler.
- * @param \Drupal\webform\WebformTokenManagerInterface $token_manager
- * The webform token manager.
- * @param \Drupal\webform\Plugin\WebformElementManagerInterface $element_manager
- * The webform element manager.
- * @param \Drupal\webform\WebformLibrariesManagerInterface $libraries_manager
- * The webform libraries manager.
- */
- public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, WebformTokenManagerInterface $token_manager, WebformElementManagerInterface $element_manager, WebformLibrariesManagerInterface $libraries_manager) {
- parent::__construct($config_factory);
- $this->moduleHandler = $module_handler;
- $this->tokenManager = $token_manager;
- $this->elementManager = $element_manager;
- $this->librariesManager = $libraries_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('config.factory'),
- $container->get('module_handler'),
- $container->get('webform.token_manager'),
- $container->get('plugin.manager.webform.element'),
- $container->get('webform.libraries_manager')
- );
+ $instance = parent::create($container);
+ $instance->moduleHandler = $container->get('module_handler');
+ $instance->tokenManager = $container->get('webform.token_manager');
+ $instance->elementManager = $container->get('plugin.manager.webform.element');
+ $instance->librariesManager = $container->get('webform.libraries_manager');
+ return $instance;
}
/**
diff --git a/src/Form/AdminConfig/WebformAdminConfigExportersForm.php b/src/Form/AdminConfig/WebformAdminConfigExportersForm.php
index ac8c62679..78149cd1f 100644
--- a/src/Form/AdminConfig/WebformAdminConfigExportersForm.php
+++ b/src/Form/AdminConfig/WebformAdminConfigExportersForm.php
@@ -2,12 +2,8 @@
namespace Drupal\webform\Form\AdminConfig;
-use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\FormState;
-use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Form\FormStateInterface;
-use Drupal\webform\Plugin\WebformExporterManagerInterface;
-use Drupal\webform\WebformSubmissionExporterInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -43,35 +39,15 @@ class WebformAdminConfigExportersForm extends WebformAdminConfigBaseForm {
return 'webform_admin_config_exporters_form';
}
- /**
- * Constructs a WebformAdminConfigExportersForm object.
- *
- * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
- * The factory for configuration objects.
- * @param \Drupal\Core\File\FileSystemInterface $file_system
- * The file system service.
- * @param \Drupal\webform\Plugin\WebformExporterManagerInterface $exporter_manager
- * The webform exporter manager.
- * @param \Drupal\webform\WebformSubmissionExporterInterface $submission_exporter
- * The webform submission exporter.
- */
- public function __construct(ConfigFactoryInterface $config_factory, FileSystemInterface $file_system, WebformExporterManagerInterface $exporter_manager, WebformSubmissionExporterInterface $submission_exporter) {
- parent::__construct($config_factory);
- $this->fileSystem = $file_system;
- $this->exporterManager = $exporter_manager;
- $this->submissionExporter = $submission_exporter;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('config.factory'),
- $container->get('file_system'),
- $container->get('plugin.manager.webform.exporter'),
- $container->get('webform_submission.exporter')
- );
+ $instance = parent::create($container);
+ $instance->fileSystem = $container->get('file_system');
+ $instance->exporterManager = $container->get('plugin.manager.webform.exporter');
+ $instance->submissionExporter = $container->get('webform_submission.exporter');
+ return $instance;
}
/**
diff --git a/src/Form/AdminConfig/WebformAdminConfigFormsForm.php b/src/Form/AdminConfig/WebformAdminConfigFormsForm.php
index 7dcd7c960..fa9d2f809 100644
--- a/src/Form/AdminConfig/WebformAdminConfigFormsForm.php
+++ b/src/Form/AdminConfig/WebformAdminConfigFormsForm.php
@@ -2,9 +2,6 @@
namespace Drupal\webform\Form\AdminConfig;
-use Drupal\Core\Config\ConfigFactoryInterface;
-use Drupal\Core\Entity\EntityTypeManagerInterface;
-use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Url;
@@ -12,10 +9,7 @@ use Drupal\filter\Entity\FilterFormat;
use Drupal\webform\Element\WebformMessage;
use Drupal\webform\Entity\Webform;
use Drupal\webform\Utility\WebformArrayHelper;
-use Drupal\webform\WebformAddonsManagerInterface;
use Drupal\webform\WebformInterface;
-use Drupal\webform\WebformTokenManagerInterface;
-use Drupal\webform\WebformThirdPartySettingsManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -65,43 +59,17 @@ class WebformAdminConfigFormsForm extends WebformAdminConfigBaseForm {
return 'webform_admin_config_forms_form';
}
- /**
- * Constructs a WebformAdminConfigFormsForm object.
- *
- * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
- * The factory for configuration objects.
- * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
- * The module handler.
- * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
- * The entity type manager.
- * @param \Drupal\webform\WebformTokenManagerInterface $token_manager
- * The webform token manager.
- * @param \Drupal\webform\WebformThirdPartySettingsManagerInterface $third_party_settings_manager
- * The webform third party settings manager.
- * @param \Drupal\webform\WebformAddonsManagerInterface $addons_manager
- * The webform add-ons manager.
- */
- public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, EntityTypeManagerInterface $entity_type_manager, WebformTokenManagerInterface $token_manager, WebformThirdPartySettingsManagerInterface $third_party_settings_manager, WebformAddonsManagerInterface $addons_manager) {
- parent::__construct($config_factory);
- $this->webformStorage = $entity_type_manager->getStorage('webform');
- $this->moduleHandler = $module_handler;
- $this->tokenManager = $token_manager;
- $this->thirdPartySettingsManager = $third_party_settings_manager;
- $this->addonsManager = $addons_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('config.factory'),
- $container->get('module_handler'),
- $container->get('entity_type.manager'),
- $container->get('webform.token_manager'),
- $container->get('webform.third_party_settings_manager'),
- $container->get('webform.addons_manager')
- );
+ $instance = parent::create($container);
+ $instance->webformStorage = $container->get('entity_type.manager')->getStorage('webform');
+ $instance->moduleHandler = $container->get('module_handler');
+ $instance->tokenManager = $container->get('webform.token_manager');
+ $instance->thirdPartySettingsManager = $container->get('webform.third_party_settings_manager');
+ $instance->addonsManager = $container->get('webform.addons_manager');
+ return $instance;
}
/**
diff --git a/src/Form/AdminConfig/WebformAdminConfigHandlersForm.php b/src/Form/AdminConfig/WebformAdminConfigHandlersForm.php
index 2315a94d2..47db42fbf 100644
--- a/src/Form/AdminConfig/WebformAdminConfigHandlersForm.php
+++ b/src/Form/AdminConfig/WebformAdminConfigHandlersForm.php
@@ -2,11 +2,7 @@
namespace Drupal\webform\Form\AdminConfig;
-use Drupal\Core\Config\ConfigFactoryInterface;
-use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormStateInterface;
-use Drupal\webform\Plugin\WebformHandlerManagerInterface;
-use Drupal\webform\WebformTokenManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -42,35 +38,15 @@ class WebformAdminConfigHandlersForm extends WebformAdminConfigBaseForm {
return 'webform_admin_config_handlers_form';
}
- /**
- * Constructs a WebformAdminConfigHandlersForm object.
- *
- * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
- * The factory for configuration objects.
- * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
- * The module handler.
- * @param \Drupal\webform\WebformTokenManagerInterface $token_manager
- * The webform token manager.
- * @param \Drupal\webform\Plugin\WebformHandlerManagerInterface $handler_manager
- * The webform handler manager.
- */
- public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, WebformTokenManagerInterface $token_manager, WebformHandlerManagerInterface $handler_manager) {
- parent::__construct($config_factory);
- $this->moduleHandler = $module_handler;
- $this->tokenManager = $token_manager;
- $this->handlerManager = $handler_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('config.factory'),
- $container->get('module_handler'),
- $container->get('webform.token_manager'),
- $container->get('plugin.manager.webform.handler')
- );
+ $instance = parent::create($container);
+ $instance->moduleHandler = $container->get('module_handler');
+ $instance->tokenManager = $container->get('webform.token_manager');
+ $instance->handlerManager = $container->get('plugin.manager.webform.handler');
+ return $instance;
}
/**
diff --git a/src/Form/AdminConfig/WebformAdminConfigLibrariesForm.php b/src/Form/AdminConfig/WebformAdminConfigLibrariesForm.php
index e2b6a6b62..bb1076f76 100644
--- a/src/Form/AdminConfig/WebformAdminConfigLibrariesForm.php
+++ b/src/Form/AdminConfig/WebformAdminConfigLibrariesForm.php
@@ -2,12 +2,10 @@
namespace Drupal\webform\Form\AdminConfig;
-use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\webform\Element\WebformMessage;
use Drupal\webform\Plugin\WebformElement\TableSelect;
-use Drupal\webform\WebformLibrariesManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -36,27 +34,13 @@ class WebformAdminConfigLibrariesForm extends WebformAdminConfigBaseForm {
return 'webform_admin_config_libraries_form';
}
- /**
- * Constructs a WebformAdminConfigLibrariesForm object.
- *
- * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
- * The factory for configuration objects.
- * @param \Drupal\webform\WebformLibrariesManagerInterface $libraries_manager
- * The webform libraries manager.
- */
- public function __construct(ConfigFactoryInterface $config_factory, WebformLibrariesManagerInterface $libraries_manager) {
- parent::__construct($config_factory);
- $this->librariesManager = $libraries_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('config.factory'),
- $container->get('webform.libraries_manager')
- );
+ $instance = parent::create($container);
+ $instance->librariesManager = $container->get('webform.libraries_manager');
+ return $instance;
}
/**
diff --git a/src/Form/AdminConfig/WebformAdminConfigSubmissionsForm.php b/src/Form/AdminConfig/WebformAdminConfigSubmissionsForm.php
index 45d15aa9f..b8414766a 100644
--- a/src/Form/AdminConfig/WebformAdminConfigSubmissionsForm.php
+++ b/src/Form/AdminConfig/WebformAdminConfigSubmissionsForm.php
@@ -2,11 +2,8 @@
namespace Drupal\webform\Form\AdminConfig;
-use Drupal\Core\Config\ConfigFactoryInterface;
-use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\Element\WebformMessage;
-use Drupal\webform\WebformTokenManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -35,31 +32,14 @@ class WebformAdminConfigSubmissionsForm extends WebformAdminConfigBaseForm {
return 'webform_admin_config_submissions_form';
}
- /**
- * Constructs a WebformAdminConfigSubmissionsForm object.
- *
- * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
- * The factory for configuration objects.
- * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
- * The module handler.
- * @param \Drupal\webform\WebformTokenManagerInterface $token_manager
- * The webform token manager.
- */
- public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, WebformTokenManagerInterface $token_manager) {
- parent::__construct($config_factory);
- $this->moduleHandler = $module_handler;
- $this->tokenManager = $token_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('config.factory'),
- $container->get('module_handler'),
- $container->get('webform.token_manager')
- );
+ $instance = parent::create($container);
+ $instance->moduleHandler = $container->get('module_handler');
+ $instance->tokenManager = $container->get('webform.token_manager');
+ return $instance;
}
/**
diff --git a/src/Form/WebformEntityFilterForm.php b/src/Form/WebformEntityFilterForm.php
index e05c9a596..48eff533b 100644
--- a/src/Form/WebformEntityFilterForm.php
+++ b/src/Form/WebformEntityFilterForm.php
@@ -2,7 +2,6 @@
namespace Drupal\webform\Form;
-use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\WebformInterface;
@@ -27,23 +26,13 @@ class WebformEntityFilterForm extends FormBase {
*/
protected $webformStorage;
- /**
- * Constructs a WebformResultsCustomForm object.
- *
- * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
- * The entity type manager.
- */
- public function __construct(EntityTypeManagerInterface $entity_type_manager) {
- $this->webformStorage = $entity_type_manager->getStorage('webform');
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('entity_type.manager')
- );
+ $instance = parent::create($container);
+ $instance->webformStorage = $container->get('entity_type.manager')->getStorage('webform');
+ return $instance;
}
/**
diff --git a/src/Form/WebformHandlerAddForm.php b/src/Form/WebformHandlerAddForm.php
index a59c8093f..fcc20f47a 100644
--- a/src/Form/WebformHandlerAddForm.php
+++ b/src/Form/WebformHandlerAddForm.php
@@ -2,12 +2,8 @@
namespace Drupal\webform\Form;
-use Drupal\Component\Transliteration\TransliterationInterface;
use Drupal\Core\Form\FormStateInterface;
-use Drupal\Core\Language\LanguageManagerInterface;
-use Drupal\webform\Plugin\WebformHandlerManagerInterface;
use Drupal\webform\WebformInterface;
-use Drupal\webform\WebformTokenManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
@@ -23,33 +19,13 @@ class WebformHandlerAddForm extends WebformHandlerFormBase {
*/
protected $webformHandlerManager;
- /**
- * Constructs a WebformHandlerAddForm.
- *
- * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
- * The language manager.
- * @param \Drupal\Component\Transliteration\TransliterationInterface $transliteration
- * The transliteration helper.
- * @param \Drupal\webform\WebformTokenManagerInterface $token_manager
- * The webform token manager.
- * @param \Drupal\webform\Plugin\WebformHandlerManagerInterface $webform_handler
- * The webform handler manager.
- */
- public function __construct(LanguageManagerInterface $language_manager, TransliterationInterface $transliteration, WebformTokenManagerInterface $token_manager, WebformHandlerManagerInterface $webform_handler) {
- parent::__construct($language_manager, $transliteration, $token_manager);
- $this->webformHandlerManager = $webform_handler;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('language_manager'),
- $container->get('transliteration'),
- $container->get('webform.token_manager'),
- $container->get('plugin.manager.webform.handler')
- );
+ $instance = parent::create($container);
+ $instance->webformHandlerManager = $container->get('plugin.manager.webform.handler');
+ return $instance;
}
/**
diff --git a/src/Form/WebformHandlerFormBase.php b/src/Form/WebformHandlerFormBase.php
index 8641d013d..dd2aa29bc 100644
--- a/src/Form/WebformHandlerFormBase.php
+++ b/src/Form/WebformHandlerFormBase.php
@@ -3,15 +3,12 @@
namespace Drupal\webform\Form;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
-use Drupal\Component\Transliteration\TransliterationInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\SubformState;
-use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\webform\Plugin\WebformHandlerInterface;
use Drupal\webform\Utility\WebformFormHelper;
use Drupal\webform\WebformInterface;
-use Drupal\webform\WebformTokenManagerInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -69,31 +66,15 @@ abstract class WebformHandlerFormBase extends FormBase {
return 'webform_handler_form';
}
- /**
- * Constructs a WebformHandlerFormBase.
- *
- * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
- * The language manager.
- * @param \Drupal\Component\Transliteration\TransliterationInterface $transliteration
- * The transliteration helper.
- * @param \Drupal\webform\WebformTokenManagerInterface $token_manager
- * The webform token manager.
- */
- public function __construct(LanguageManagerInterface $language_manager, TransliterationInterface $transliteration, WebformTokenManagerInterface $token_manager) {
- $this->languageManager = $language_manager;
- $this->transliteration = $transliteration;
- $this->tokenManager = $token_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('language_manager'),
- $container->get('transliteration'),
- $container->get('webform.token_manager')
- );
+ $instance = parent::create($container);
+ $instance->languageManager = $container->get('language_manager');
+ $instance->transliteration = $container->get('transliteration');
+ $instance->tokenManager = $container->get('webform.token_manager');
+ return $instance;
}
/**
diff --git a/src/Form/WebformHelpVideoForm.php b/src/Form/WebformHelpVideoForm.php
index 2e1ce1f8a..e4fe14bbf 100644
--- a/src/Form/WebformHelpVideoForm.php
+++ b/src/Form/WebformHelpVideoForm.php
@@ -5,7 +5,6 @@ namespace Drupal\webform\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
-use Drupal\webform\WebformHelpManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -37,23 +36,13 @@ class WebformHelpVideoForm extends FormBase {
return 'webform_help_video_form';
}
- /**
- * Constructs a WebformHelpVideoForm object.
- *
- * @param \Drupal\webform\WebformHelpManagerInterface $help_manager
- * The webform help manager.
- */
- public function __construct(WebformHelpManagerInterface $help_manager) {
- $this->helpManager = $help_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('webform.help_manager')
- );
+ $instance = parent::create($container);
+ $instance->helpManager = $container->get('webform.help_manager');
+ return $instance;
}
/**
diff --git a/src/Form/WebformResultsCustomForm.php b/src/Form/WebformResultsCustomForm.php
index d79a51f41..5aa5001d9 100644
--- a/src/Form/WebformResultsCustomForm.php
+++ b/src/Form/WebformResultsCustomForm.php
@@ -2,10 +2,8 @@
namespace Drupal\webform\Form;
-use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
-use Drupal\webform\WebformRequestInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -48,28 +46,15 @@ class WebformResultsCustomForm extends FormBase {
*/
protected $requestHandler;
- /**
- * Constructs a WebformResultsCustomForm object.
- *
- * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
- * The entity type manager.
- * @param \Drupal\webform\WebformRequestInterface $request_handler
- * The webform request handler.
- */
- public function __construct(EntityTypeManagerInterface $entity_type_manager, WebformRequestInterface $request_handler) {
- $this->submissionStorage = $entity_type_manager->getStorage('webform_submission');
- $this->requestHandler = $request_handler;
- list($this->webform, $this->sourceEntity) = $this->requestHandler->getWebformEntities();
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('entity_type.manager'),
- $container->get('webform.request')
- );
+ $instance = parent::create($container);
+ $instance->submissionStorage = $container->get('entity_type.manager')->getStorage('webform_submission');
+ $instance->requestHandler = $container->get('webform.request');
+ list($instance->webform, $instance->sourceEntity) = $instance->requestHandler->getWebformEntities();
+ return $instance;
}
/**
diff --git a/src/Form/WebformResultsExportForm.php b/src/Form/WebformResultsExportForm.php
index 2964f1c5c..6266b9599 100644
--- a/src/Form/WebformResultsExportForm.php
+++ b/src/Form/WebformResultsExportForm.php
@@ -4,7 +4,6 @@ namespace Drupal\webform\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
-use Drupal\webform\WebformSubmissionExporterInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -26,23 +25,13 @@ class WebformResultsExportForm extends FormBase {
*/
protected $submissionExporter;
- /**
- * Constructs a WebformResultsExportForm object.
- *
- * @param \Drupal\webform\WebformSubmissionExporterInterface $webform_submission_exporter
- * The webform submission exported.
- */
- public function __construct(WebformSubmissionExporterInterface $webform_submission_exporter) {
- $this->submissionExporter = $webform_submission_exporter;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('webform_submission.exporter')
- );
+ $instance = parent::create($container);
+ $instance->submissionExporter = $container->get('webform_submission.exporter');
+ return $instance;
}
/**
diff --git a/src/Form/WebformSubmissionDeleteForm.php b/src/Form/WebformSubmissionDeleteForm.php
index 86d120829..5074b9d1a 100644
--- a/src/Form/WebformSubmissionDeleteForm.php
+++ b/src/Form/WebformSubmissionDeleteForm.php
@@ -3,9 +3,7 @@
namespace Drupal\webform\Form;
use Drupal\Core\Entity\ContentEntityDeleteForm;
-use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Form\FormStateInterface;
-use Drupal\webform\WebformRequestInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -43,27 +41,13 @@ class WebformSubmissionDeleteForm extends ContentEntityDeleteForm implements Web
*/
protected $requestHandler;
- /**
- * Constructs a WebformSubmissionDeleteForm object.
- *
- * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
- * The entity repository.
- * @param \Drupal\webform\WebformRequestInterface $request_handler
- * The webform request handler.
- */
- public function __construct(EntityRepositoryInterface $entity_repository, WebformRequestInterface $request_handler) {
- parent::__construct($entity_repository);
- $this->requestHandler = $request_handler;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('entity.repository'),
- $container->get('webform.request')
- );
+ $instance = parent::create($container);
+ $instance->requestHandler = $container->get('webform.request');
+ return $instance;
}
/**
diff --git a/src/Form/WebformSubmissionDeleteMultiple.php b/src/Form/WebformSubmissionDeleteMultiple.php
index 2f6618873..7539fddaa 100644
--- a/src/Form/WebformSubmissionDeleteMultiple.php
+++ b/src/Form/WebformSubmissionDeleteMultiple.php
@@ -2,11 +2,9 @@
namespace Drupal\webform\Form;
-use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
-use Drupal\Core\TempStore\PrivateTempStoreFactory;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -36,27 +34,14 @@ class WebformSubmissionDeleteMultiple extends ConfirmFormBase {
*/
protected $storage;
- /**
- * Constructs a WebformSubmissionDeleteMultiple object.
- *
- * @param \Drupal\Core\TempStore\PrivateTempStoreFactory $temp_store_factory
- * The tempstore factory.
- * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
- * The entity type manager.
- */
- public function __construct(PrivateTempStoreFactory $temp_store_factory, EntityTypeManagerInterface $entity_type_manager) {
- $this->tempStoreFactory = $temp_store_factory;
- $this->storage = $entity_type_manager->getStorage('webform_submission');
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('tempstore.private'),
- $container->get('entity_type.manager')
- );
+ $instance = parent::create($container);
+ $instance->tempStoreFactory = $container->get('tempstore.private');
+ $instance->storage = $container->get('entity_type.manager')->getStorage('webform_submission');
+ return $instance;
}
/**
diff --git a/src/Form/WebformSubmissionResendForm.php b/src/Form/WebformSubmissionResendForm.php
index 45007f6f8..e6fde1073 100644
--- a/src/Form/WebformSubmissionResendForm.php
+++ b/src/Form/WebformSubmissionResendForm.php
@@ -7,7 +7,6 @@ use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\Element\WebformAjaxElementTrait;
use Drupal\webform\Plugin\WebformHandlerMessageInterface;
-use Drupal\webform\WebformRequestInterface;
use Drupal\webform\WebformSubmissionInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -32,13 +31,6 @@ class WebformSubmissionResendForm extends FormBase {
*/
protected $entity;
- /**
- * {@inheritdoc}
- */
- public function getFormId() {
- return 'webform_submission_resend';
- }
-
/**
* Webform request handler.
*
@@ -47,22 +39,19 @@ class WebformSubmissionResendForm extends FormBase {
protected $requestHandler;
/**
- * Constructs a WebformResultsResendForm object.
- *
- * @param \Drupal\webform\WebformRequestInterface $request_handler
- * The webform request handler.
+ * {@inheritdoc}
*/
- public function __construct(WebformRequestInterface $request_handler) {
- $this->requestHandler = $request_handler;
+ public function getFormId() {
+ return 'webform_submission_resend';
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('webform.request')
- );
+ $instance = parent::create($container);
+ $instance->requestHandler = $container->get('webform.request');
+ return $instance;
}
/**
diff --git a/src/Form/WebformSubmissionsDeleteFormBase.php b/src/Form/WebformSubmissionsDeleteFormBase.php
index f27dd448f..36640e307 100644
--- a/src/Form/WebformSubmissionsDeleteFormBase.php
+++ b/src/Form/WebformSubmissionsDeleteFormBase.php
@@ -3,10 +3,8 @@
namespace Drupal\webform\Form;
use Drupal\Core\Entity\EntityInterface;
-use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\WebformInterface;
-use Drupal\webform\WebformRequestInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -63,30 +61,17 @@ abstract class WebformSubmissionsDeleteFormBase extends WebformDeleteFormBase {
*/
protected $requestHandler;
- /**
- * Constructs a WebformResultsDeleteFormBase object.
- *
- * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
- * The entity type manager.
- * @param \Drupal\webform\WebformRequestInterface $request_handler
- * The webform request handler.
- */
- public function __construct(EntityTypeManagerInterface $entity_type_manager, WebformRequestInterface $request_handler) {
- $this->entityTypeManager = $entity_type_manager;
- $this->submissionStorage = $entity_type_manager->getStorage('webform_submission');
- $this->requestHandler = $request_handler;
-
- list($this->webform, $this->sourceEntity) = $this->requestHandler->getWebformEntities();
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
- return new static(
- $container->get('entity_type.manager'),
- $container->get('webform.request')
- );
+ $instance = parent::create($container);
+ $instance->entityTypeManager = $container->get('entity_type.manager');
+ $instance->submissionStorage = $instance->entityTypeManager->getStorage('webform_submission');
+ $instance->requestHandler = $container->get('webform.request');
+ list($instance->webform, $instance->sourceEntity) = $instance->requestHandler->getWebformEntities();
+ return $instance;
+
}
/**
diff --git a/src/Plugin/Action/DeleteWebformSubmission.php b/src/Plugin/Action/DeleteWebformSubmission.php
index 682839ad6..0ed730d13 100644
--- a/src/Plugin/Action/DeleteWebformSubmission.php
+++ b/src/Plugin/Action/DeleteWebformSubmission.php
@@ -5,7 +5,6 @@ namespace Drupal\webform\Plugin\Action;
use Drupal\Core\Action\ActionBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Session\AccountInterface;
-use Drupal\Core\TempStore\PrivateTempStoreFactory;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -34,38 +33,14 @@ class DeleteWebformSubmission extends ActionBase implements ContainerFactoryPlug
*/
protected $currentUser;
- /**
- * Constructs a DeleteWebformSubmission object.
- *
- * @param array $configuration
- * A configuration array containing information about the plugin instance.
- * @param string $plugin_id
- * The plugin ID for the plugin instance.
- * @param mixed $plugin_definition
- * The plugin implementation definition.
- * @param \Drupal\Core\TempStore\PrivateTempStoreFactory $temp_store_factory
- * The tempstore factory.
- * @param \Drupal\Core\Session\AccountInterface $current_user
- * The current user.
- */
- public function __construct(array $configuration, $plugin_id, $plugin_definition, PrivateTempStoreFactory $temp_store_factory, AccountInterface $current_user) {
- $this->currentUser = $current_user;
- $this->tempStoreFactory = $temp_store_factory;
-
- parent::__construct($configuration, $plugin_id, $plugin_definition);
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
- return new static(
- $configuration,
- $plugin_id,
- $plugin_definition,
- $container->get('tempstore.private'),
- $container->get('current_user')
- );
+ $instance = new static($configuration, $plugin_id, $plugin_definition);
+ $instance->currentUser = $container->get('current_user');
+ $instance->tempStoreFactory = $container->get('tempstore.private');
+ return $instance;
}
/**
diff --git a/src/Plugin/Block/WebformBlock.php b/src/Plugin/Block/WebformBlock.php
index d81b3ddd5..a57a20b1e 100644
--- a/src/Plugin/Block/WebformBlock.php
+++ b/src/Plugin/Block/WebformBlock.php
@@ -4,15 +4,12 @@ namespace Drupal\webform\Plugin\Block;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Block\BlockBase;
-use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\webform\WebformInterface;
-use Drupal\webform\WebformTokenManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
-use Symfony\Component\HttpFoundation\RequestStack;
/**
* Provides a 'Webform' block.
@@ -46,41 +43,15 @@ class WebformBlock extends BlockBase implements ContainerFactoryPluginInterface
*/
protected $tokenManager;
- /**
- * Creates a WebformBlock instance.
- *
- * @param array $configuration
- * A configuration array containing information about the plugin instance.
- * @param string $plugin_id
- * The plugin_id for the plugin instance.
- * @param mixed $plugin_definition
- * The plugin implementation definition.
- * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
- * The request stack.
- * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
- * The entity type manager.
- * @param \Drupal\webform\WebformTokenManagerInterface $token_manager
- * The webform token manager.
- */
- public function __construct(array $configuration, $plugin_id, $plugin_definition, RequestStack $request_stack, EntityTypeManagerInterface $entity_type_manager, WebformTokenManagerInterface $token_manager) {
- parent::__construct($configuration, $plugin_id, $plugin_definition);
- $this->requestStack = $request_stack;
- $this->entityTypeManager = $entity_type_manager;
- $this->tokenManager = $token_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
- return new static(
- $configuration,
- $plugin_id,
- $plugin_definition,
- $container->get('request_stack'),
- $container->get('entity_type.manager'),
- $container->get('webform.token_manager')
- );
+ $instance = new static($configuration, $plugin_id, $plugin_definition);
+ $instance->requestStack = $container->get('request_stack');
+ $instance->entityTypeManager = $container->get('entity_type.manager');
+ $instance->tokenManager = $container->get('webform.token_manager');
+ return $instance;
}
/**
diff --git a/src/Plugin/Block/WebformSubmissionLimitBlock.php b/src/Plugin/Block/WebformSubmissionLimitBlock.php
index 14cd55183..48384ea74 100644
--- a/src/Plugin/Block/WebformSubmissionLimitBlock.php
+++ b/src/Plugin/Block/WebformSubmissionLimitBlock.php
@@ -4,15 +4,12 @@ namespace Drupal\webform\Plugin\Block;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Block\BlockBase;
-use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\webform\Element\WebformHtmlEditor;
use Drupal\webform\Entity\Webform;
use Drupal\webform\Utility\WebformDateHelper;
-use Drupal\webform\WebformRequestInterface;
-use Drupal\webform\WebformTokenManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -68,45 +65,16 @@ class WebformSubmissionLimitBlock extends BlockBase implements ContainerFactoryP
*/
protected $tokenManager;
- /**
- * Creates a WebformSubmissionLimitBlock instance.
- *
- * @param array $configuration
- * A configuration array containing information about the plugin instance.
- * @param string $plugin_id
- * The plugin_id for the plugin instance.
- * @param mixed $plugin_definition
- * The plugin implementation definition.
- * @param \Drupal\Core\Session\AccountInterface $account
- * The current user.
- * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
- * The entity type manager.
- * @param \Drupal\webform\WebformRequestInterface $request_handler
- * The webform request handler.
- * @param \Drupal\webform\WebformTokenManagerInterface $token_manager
- * The webform token manager.
- */
- public function __construct(array $configuration, $plugin_id, $plugin_definition, AccountInterface $account, EntityTypeManagerInterface $entity_type_manager, WebformRequestInterface $request_handler, WebformTokenManagerInterface $token_manager) {
- parent::__construct($configuration, $plugin_id, $plugin_definition);
- $this->currentUser = $account;
- $this->entityTypeManager = $entity_type_manager;
- $this->requestHandler = $request_handler;
- $this->tokenManager = $token_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
- return new static(
- $configuration,
- $plugin_id,
- $plugin_definition,
- $container->get('current_user'),
- $container->get('entity_type.manager'),
- $container->get('webform.request'),
- $container->get('webform.token_manager')
- );
+ $instance = new static($configuration, $plugin_id, $plugin_definition);
+ $instance->currentUser = $container->get('current_user');
+ $instance->entityTypeManager = $container->get('entity_type.manager');
+ $instance->requestHandler = $container->get('webform.request');
+ $instance->tokenManager = $container->get('webform.token_manager');
+ return $instance;
}
/**
diff --git a/src/Plugin/Condition/Webform.php b/src/Plugin/Condition/Webform.php
index 62b1514b0..42e0ff5e1 100644
--- a/src/Plugin/Condition/Webform.php
+++ b/src/Plugin/Condition/Webform.php
@@ -3,11 +3,9 @@
namespace Drupal\webform\Plugin\Condition;
use Drupal\Core\Condition\ConditionPluginBase;
-use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\webform\Utility\WebformElementHelper;
-use Drupal\webform\WebformEntityReferenceManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -39,40 +37,14 @@ class Webform extends ConditionPluginBase implements ContainerFactoryPluginInter
*/
protected $webformEntityReferenceManager;
- /**
- * Creates a new Webform instance.
- *
- * @param array $configuration
- * The plugin configuration, i.e. an array with configuration values keyed
- * by configuration option name. The special key 'context' may be used to
- * initialize the defined contexts by setting it to an array of context
- * values keyed by context names.
- * @param string $plugin_id
- * The plugin_id for the plugin instance.
- * @param mixed $plugin_definition
- * The plugin implementation definition.
- * @param \Drupal\Core\Entity\EntityStorageInterface $entity_storage
- * The entity storage.
- * @param \Drupal\webform\WebformEntityReferenceManagerInterface $webform_entity_reference_manager
- * The webform entity reference manager.
- */
- public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityStorageInterface $entity_storage, WebformEntityReferenceManagerInterface $webform_entity_reference_manager) {
- parent::__construct($configuration, $plugin_id, $plugin_definition);
- $this->entityStorage = $entity_storage;
- $this->webformEntityReferenceManager = $webform_entity_reference_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
- return new static(
- $configuration,
- $plugin_id,
- $plugin_definition,
- $container->get('entity_type.manager')->getStorage('webform'),
- $container->get('webform.entity_reference_manager')
- );
+ $instance = new static($configuration, $plugin_id, $plugin_definition);
+ $instance->entityStorage = $container->get('entity_type.manager')->getStorage('webform');
+ $instance->webformEntityReferenceManager = $container->get('webform.entity_reference_manager');
+ return $instance;
}
/**
diff --git a/src/Plugin/DevelGenerate/WebformSubmissionDevelGenerate.php b/src/Plugin/DevelGenerate/WebformSubmissionDevelGenerate.php
index 1e8fabeb4..b443e537c 100644
--- a/src/Plugin/DevelGenerate/WebformSubmissionDevelGenerate.php
+++ b/src/Plugin/DevelGenerate/WebformSubmissionDevelGenerate.php
@@ -2,18 +2,12 @@
namespace Drupal\webform\Plugin\DevelGenerate;
-use Drupal\Core\Database\Connection;
-use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
-use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Serialization\Yaml;
use Drupal\devel_generate\DevelGenerateBase;
use Drupal\webform\Utility\WebformArrayHelper;
-use Drupal\webform\WebformEntityReferenceManagerInterface;
-use Drupal\webform\WebformSubmissionGenerateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
-use Symfony\Component\HttpFoundation\RequestStack;
/**
* Provides a WebformSubmissionDevelGenerate plugin.
@@ -97,56 +91,20 @@ class WebformSubmissionDevelGenerate extends DevelGenerateBase implements Contai
*/
protected $messenger;
- /**
- * Constructs a WebformSubmissionDevelGenerate object.
- *
- * @param array $configuration
- * A configuration array containing information about the plugin instance.
- * @param string $plugin_id
- * The plugin_id for the plugin instance.
- * @param mixed $plugin_definition
- * The plugin implementation definition.
- * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
- * The request stack.
- * @param \Drupal\Core\Database\Connection $database
- * The database.
- * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
- * The entity type manager.
- * @param \Drupal\Core\Messenger\MessengerInterface $messenger
- * The messenger.
- * @param \Drupal\webform\WebformSubmissionGenerateInterface $webform_submission_generate
- * The webform submission generator.
- * @param \Drupal\webform\WebformEntityReferenceManagerInterface $webform_entity_reference_manager
- * The webform entity reference manager.
- */
- public function __construct(array $configuration, $plugin_id, $plugin_definition, RequestStack $request_stack, Connection $database, EntityTypeManagerInterface $entity_type_manager, MessengerInterface $messenger, WebformSubmissionGenerateInterface $webform_submission_generate, WebformEntityReferenceManagerInterface $webform_entity_reference_manager) {
- parent::__construct($configuration, $plugin_id, $plugin_definition);
-
- $this->request = $request_stack->getCurrentRequest();
- $this->database = $database;
- $this->entityTypeManager = $entity_type_manager;
- $this->messenger = $messenger;
- $this->webformSubmissionGenerate = $webform_submission_generate;
- $this->webformEntityReferenceManager = $webform_entity_reference_manager;
- $this->webformStorage = $entity_type_manager->getStorage('webform');
- $this->webformSubmissionStorage = $entity_type_manager->getStorage('webform_submission');
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
- return new static(
- $configuration,
- $plugin_id,
- $plugin_definition,
- $container->get('request_stack'),
- $container->get('database'),
- $container->get('entity_type.manager'),
- $container->get('messenger'),
- $container->get('webform_submission.generate'),
- $container->get('webform.entity_reference_manager')
- );
+ $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
+ $instance->request = $container->get('request_stack')->getCurrentRequest();
+ $instance->database = $container->get('database');
+ $instance->entityTypeManager = $container->get('entity_type.manager');
+ $instance->messenger = $container->get('messenger');
+ $instance->webformSubmissionGenerate = $container->get('webform_submission.generate');
+ $instance->webformEntityReferenceManager = $container->get('webform.entity_reference_manager');
+ $instance->webformStorage = $container->get('entity_type.manager')->getStorage('webform');
+ $instance->webformSubmissionStorage = $container->get('entity_type.manager')->getStorage('webform_submission');
+ return $instance;
}
/**
diff --git a/src/Plugin/Field/FieldFormatter/WebformEntityReferenceEntityFormatter.php b/src/Plugin/Field/FieldFormatter/WebformEntityReferenceEntityFormatter.php
index c13056eb3..6b11d7a81 100644
--- a/src/Plugin/Field/FieldFormatter/WebformEntityReferenceEntityFormatter.php
+++ b/src/Plugin/Field/FieldFormatter/WebformEntityReferenceEntityFormatter.php
@@ -3,16 +3,10 @@
namespace Drupal\webform\Plugin\Field\FieldFormatter;
use Drupal\Core\Access\AccessResult;
-use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Serialization\Yaml;
-use Drupal\Core\Entity\EntityTypeManagerInterface;
-use Drupal\Core\Field\FieldDefinitionInterface;
-use Drupal\Core\Render\RendererInterface;
-use Drupal\Core\Routing\RouteMatchInterface;
-use Drupal\webform\WebformMessageManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -50,60 +44,15 @@ class WebformEntityReferenceEntityFormatter extends WebformEntityReferenceFormat
*/
protected $messageManager;
- /**
- * WebformEntityReferenceEntityFormatter constructor.
- *
- * @param string $plugin_id
- * The plugin_id for the formatter.
- * @param mixed $plugin_definition
- * The plugin implementation definition.
- * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
- * The definition of the field to which the formatter is associated.
- * @param array $settings
- * The formatter settings.
- * @param string $label
- * The formatter label display setting.
- * @param string $view_mode
- * The view mode.
- * @param array $third_party_settings
- * Third party settings.
- * @param \Drupal\Core\Render\RendererInterface $renderer
- * The renderer.
- * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
- * The factory for configuration objects.
- * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
- * The route match.
- * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
- * The entity type manager.
- * @param \Drupal\webform\WebformMessageManagerInterface $message_manager
- * The webform message manager.
- */
- public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, RendererInterface $renderer, ConfigFactoryInterface $config_factory, RouteMatchInterface $route_match, EntityTypeManagerInterface $entity_type_manager, WebformMessageManagerInterface $message_manager) {
- parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings, $renderer, $config_factory);
-
- $this->routeMatch = $route_match;
- $this->entityTypeManager = $entity_type_manager;
- $this->messageManager = $message_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
- return new static(
- $plugin_id,
- $plugin_definition,
- $configuration['field_definition'],
- $configuration['settings'],
- $configuration['label'],
- $configuration['view_mode'],
- $configuration['third_party_settings'],
- $container->get('renderer'),
- $container->get('config.factory'),
- $container->get('current_route_match'),
- $container->get('entity_type.manager'),
- $container->get('webform.message_manager')
- );
+ $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
+ $instance->routeMatch = $container->get('current_route_match');
+ $instance->entityTypeManager = $container->get('entity_type.manager');
+ $instance->messageManager = $container->get('webform.message_manager');
+ return $instance;
}
/**
diff --git a/src/Plugin/Field/FieldFormatter/WebformEntityReferenceFormatterBase.php b/src/Plugin/Field/FieldFormatter/WebformEntityReferenceFormatterBase.php
index fbf6bd860..c518b2095 100644
--- a/src/Plugin/Field/FieldFormatter/WebformEntityReferenceFormatterBase.php
+++ b/src/Plugin/Field/FieldFormatter/WebformEntityReferenceFormatterBase.php
@@ -2,12 +2,9 @@
namespace Drupal\webform\Plugin\Field\FieldFormatter;
-use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Field\EntityReferenceFieldItemListInterface;
-use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
-use Drupal\Core\Render\RendererInterface;
use Drupal\webform\Plugin\Field\FieldType\WebformEntityReferenceItem;
use Drupal\webform\WebformInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -31,50 +28,22 @@ abstract class WebformEntityReferenceFormatterBase extends EntityReferenceFormat
*/
protected $configFactory;
- /**
- * WebformEntityReferenceLinkFormatter constructor.
- *
- * @param string $plugin_id
- * The plugin_id for the formatter.
- * @param mixed $plugin_definition
- * The plugin implementation definition.
- * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
- * The definition of the field to which the formatter is associated.
- * @param array $settings
- * The formatter settings.
- * @param string $label
- * The formatter label display setting.
- * @param string $view_mode
- * The view mode.
- * @param array $third_party_settings
- * Third party settings.
- * @param \Drupal\Core\Render\RendererInterface $renderer
- * The renderer.
- * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
- * The factory for configuration objects.
- */
- public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, RendererInterface $renderer, ConfigFactoryInterface $config_factory) {
- parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
-
- $this->configFactory = $config_factory;
- $this->renderer = $renderer;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
- return new static(
+ $instance = new static(
$plugin_id,
$plugin_definition,
$configuration['field_definition'],
$configuration['settings'],
$configuration['label'],
$configuration['view_mode'],
- $configuration['third_party_settings'],
- $container->get('renderer'),
- $container->get('config.factory')
+ $configuration['third_party_settings']
);
+ $instance->configFactory = $container->get('config.factory');
+ $instance->renderer = $container->get('renderer');
+ return $instance;
}
/**
diff --git a/src/Plugin/Field/FieldFormatter/WebformEntityReferenceLinkFormatter.php b/src/Plugin/Field/FieldFormatter/WebformEntityReferenceLinkFormatter.php
index ff9e73b73..dc895e442 100644
--- a/src/Plugin/Field/FieldFormatter/WebformEntityReferenceLinkFormatter.php
+++ b/src/Plugin/Field/FieldFormatter/WebformEntityReferenceLinkFormatter.php
@@ -2,15 +2,11 @@
namespace Drupal\webform\Plugin\Field\FieldFormatter;
-use Drupal\Core\Config\ConfigFactoryInterface;
-use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
-use Drupal\Core\Render\RendererInterface;
use Drupal\webform\Element\WebformMessage;
use Drupal\webform\Entity\WebformSubmission;
use Drupal\webform\WebformMessageManagerInterface;
-use Drupal\webform\WebformTokenManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -48,56 +44,14 @@ class WebformEntityReferenceLinkFormatter extends WebformEntityReferenceFormatte
*/
protected $tokenManager;
- /**
- * WebformEntityReferenceLinkFormatter constructor.
- *
- * @param string $plugin_id
- * The plugin_id for the formatter.
- * @param mixed $plugin_definition
- * The plugin implementation definition.
- * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
- * The definition of the field to which the formatter is associated.
- * @param array $settings
- * The formatter settings.
- * @param string $label
- * The formatter label display setting.
- * @param string $view_mode
- * The view mode.
- * @param array $third_party_settings
- * Third party settings.
- * @param \Drupal\Core\Render\RendererInterface $renderer
- * The renderer.
- * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
- * The factory for configuration objects.
- * @param \Drupal\webform\WebformMessageManagerInterface $message_manager
- * The webform message manager.
- * @param \Drupal\webform\WebformTokenManagerInterface $token_manager
- * The webform token manager.
- */
- public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, RendererInterface $renderer, ConfigFactoryInterface $config_factory, WebformMessageManagerInterface $message_manager, WebformTokenManagerInterface $token_manager) {
- parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings, $renderer, $config_factory);
-
- $this->messageManager = $message_manager;
- $this->tokenManager = $token_manager;
- }
-
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
- return new static(
- $plugin_id,
- $plugin_definition,
- $configuration['field_definition'],
- $configuration['settings'],
- $configuration['label'],
- $configuration['view_mode'],
- $configuration['third_party_settings'],
- $container->get('renderer'),
- $container->get('config.factory'),
- $container->get('webform.message_manager'),
- $container->get('webform.token_manager')
- );
+ $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
+ $instance->messageManager = $container->get('webform.message_manager');
+ $instance->tokenManager = $container->get('webform.token_manager');
+ return $instance;
}
/**
diff --git a/src/Plugin/WebformElement/Address.php b/src/Plugin/WebformElement/Address.php
index 043c3be60..529fd5cda 100644
--- a/src/Plugin/WebformElement/Address.php
+++ b/src/Plugin/WebformElement/Address.php
@@ -12,6 +12,7 @@ use Drupal\Core\Mail\MailFormatHelper;
use Drupal\webform\Utility\WebformElementHelper;
use Drupal\webform\WebformInterface;
use Drupal\webform\WebformSubmissionInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a 'address' element.
@@ -33,6 +34,46 @@ use Drupal\webform\WebformSubmissionInterface;
*/
class Address extends WebformCompositeBase {
+ /**
+ * The language manager service.
+ *
+ * @var \Drupal\Core\Language\LanguageManagerInterface
+ */
+ protected $languageManager;
+
+ /**
+ * The renderer.
+ *
+ * @var \Drupal\Core\Render\RendererInterface
+ */
+ protected $renderer;
+
+ /**
+ * The address format repository service.
+ *
+ * @var \CommerceGuys\Addressing\AddressFormat\AddressFormatRepositoryInterface $address_format_repository
+ */
+ protected $addressFormatRepository;
+
+ /**
+ * The address county repository service.
+ *
+ * @var \CommerceGuys\Addressing\Country\CountryRepositoryInterface $country_repository
+ */
+ protected $addressCountryRepository;
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+ $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
+ $instance->languageManager = $container->get('language_manager');
+ $instance->renderer = $container->get('renderer');
+ $instance->addressFormatRepository = $container->get('address.address_format_repository');
+ $instance->addressCountryRepository = $container->get('address.country_repository');
+ return $instance;
+ }
+
/**
* {@inheritdoc}
*/
@@ -208,7 +249,7 @@ class Address extends WebformCompositeBase {
$format = $this->getItemFormat($element);
if ($format === 'value') {
$build = $this->buildAddress($element, $webform_submission, $options);
- $html = \Drupal::service('renderer')->renderPlain($build);
+ $html = $this->renderer->renderPlain($build);
return trim(MailFormatHelper::htmlToText($html));
}
else {
@@ -236,11 +277,6 @@ class Address extends WebformCompositeBase {
* @see \Drupal\address\Plugin\Field\FieldFormatter\AddressDefaultFormatter::viewElement
*/
protected function buildAddress(array $element, WebformSubmissionInterface $webform_submission, array $options) {
- /** @var \CommerceGuys\Addressing\AddressFormat\AddressFormatRepositoryInterface $address_format_repository */
- $address_format_repository = \Drupal::service('address.address_format_repository');
- /** @var \CommerceGuys\Addressing\Country\CountryRepositoryInterface $country_repository */
- $country_repository = \Drupal::service('address.country_repository');
-
$value = $this->getValue($element, $webform_submission, $options);
// Skip if value or country code is empty.
if (empty($value) || empty($value['country_code'])) {
@@ -263,8 +299,8 @@ class Address extends WebformCompositeBase {
// @see \Drupal\address\Plugin\Field\FieldFormatter\AddressDefaultFormatter::viewElement
$country_code = $value['country_code'];
- $countries = $country_repository->getList();
- $address_format = $address_format_repository->get($country_code);
+ $countries = $this->addressCountryRepository->getList();
+ $address_format = $this->addressFormatRepository->get($country_code);
$build += [
'#address_format' => $address_format,
@@ -313,7 +349,7 @@ class Address extends WebformCompositeBase {
// Copied from: \Drupal\address\Plugin\Field\FieldType\AddressItem::fieldSettingsForm
/**************************************************************************/
- $languages = \Drupal::languageManager()->getLanguages(LanguageInterface::STATE_ALL);
+ $languages = $this->languageManager->getLanguages(LanguageInterface::STATE_ALL);
$language_options = [];
foreach ($languages as $langcode => $language) {
if (!$language->isLocked()) {
@@ -325,7 +361,7 @@ class Address extends WebformCompositeBase {
'#type' => 'select',
'#title' => $this->t('Available countries'),
'#description' => $this->t('If no countries are selected, all countries will be available.'),
- '#options' => \Drupal::service('address.country_repository')->getList(),
+ '#options' => $this->addressCountryRepository->getList(),
'#multiple' => TRUE,
'#size' => 10,
'#select2' => TRUE,
@@ -337,7 +373,7 @@ class Address extends WebformCompositeBase {
'#description' => $this->t('Ensures entered addresses are always formatted in the same language.'),
'#options' => $language_options,
'#empty_option' => $this->t('- No override -'),
- '#access' => \Drupal::languageManager()->isMultilingual(),
+ '#access' => $this->languageManager->isMultilingual(),
];
$form['address']['field_overrides_title'] = [
'#type' => 'item',
diff --git a/src/Plugin/WebformElement/Captcha.php b/src/Plugin/WebformElement/Captcha.php
index fc5749ed4..50b0bdf1d 100644
--- a/src/Plugin/WebformElement/Captcha.php
+++ b/src/Plugin/WebformElement/Captcha.php
@@ -9,6 +9,7 @@ use Drupal\webform\WebformSubmissionForm;
use Drupal\webform\WebformSubmissionInterface;
use Drupal\Core\Link;
use Drupal\Core\Url as CoreUrl;
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a 'captcha' element.
@@ -28,6 +29,22 @@ use Drupal\Core\Url as CoreUrl;
*/
class Captcha extends WebformElementBase {
+ /**
+ * The current route match.
+ *
+ * @var \Drupal\Core\Routing\RouteMatchInterface
+ */
+ protected $routeMatch;
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+ $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
+ $instance->routeMatch = $container->get('current_route_match');
+ return $instance;
+ }
+
/**
* {@inheritdoc}
*/
@@ -80,14 +97,14 @@ class Captcha extends WebformElementBase {
public function prepare(array &$element, WebformSubmissionInterface $webform_submission = NULL) {
// Hide and solve the element if the user is assigned 'skip CAPTCHA'
// and '#captcha_admin_mode' is not enabled.
- $is_admin = \Drupal::currentUser()->hasPermission('skip CAPTCHA');
+ $is_admin = $this->currentUser->hasPermission('skip CAPTCHA');
if ($is_admin && empty($element['#captcha_admin_mode'])) {
$element['#access'] = FALSE;
$element['#captcha_admin_mode'] = TRUE;
}
// Always enable admin mode for test.
- $is_test = (strpos(\Drupal::routeMatch()->getRouteName(), '.webform.test_form') !== FALSE) ? TRUE : FALSE;
+ $is_test = (strpos($this->routeMatch->getRouteName(), '.webform.test_form') !== FALSE) ? TRUE : FALSE;
if ($is_test) {
$element['#captcha_admin_mode'] = TRUE;
}
@@ -108,7 +125,7 @@ class Captcha extends WebformElementBase {
// @see \Drupal\captcha\Element\Captcha::processCaptchaElement
'#captcha_info' => ['form_id' => ''],
];
- if (\Drupal::moduleHandler()->moduleExists('image_captcha')) {
+ if ($this->moduleHandler->moduleExists('image_captcha')) {
$element['#captcha_type'] = 'image_captcha/Image';
}
@@ -145,7 +162,7 @@ class Captcha extends WebformElementBase {
$captcha_types['default'] = $this->t('Default challenge type');
// We do our own version of Drupal's module_invoke_all() here because
// we want to build an array with custom keys and values.
- foreach (\Drupal::moduleHandler()->getImplementations('captcha') as $module) {
+ foreach ($this->moduleHandler->getImplementations('captcha') as $module) {
$result = call_user_func_array($module . '_captcha', ['list']);
if (is_array($result)) {
foreach ($result as $type) {
diff --git a/src/Plugin/WebformElement/ContainerBase.php b/src/Plugin/WebformElement/ContainerBase.php
index bc3295099..885c9b749 100644
--- a/src/Plugin/WebformElement/ContainerBase.php
+++ b/src/Plugin/WebformElement/ContainerBase.php
@@ -118,7 +118,7 @@ abstract class ContainerBase extends WebformElementBase {
*/
protected function formatHtmlItem(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
/** @var \Drupal\webform\WebformSubmissionViewBuilderInterface $view_builder */
- $view_builder = \Drupal::entityTypeManager()->getViewBuilder('webform_submission');
+ $view_builder = $this->entityTypeManager->getViewBuilder('webform_submission');
$children = $view_builder->buildElements($element, $webform_submission, $options, 'html');
if (empty($children)) {
return [];
@@ -168,7 +168,7 @@ abstract class ContainerBase extends WebformElementBase {
'#type' => 'webform_section',
'#id' => $element['#webform_id'],
'#title' => $element['#title'],
- '#title_tag' => \Drupal::config('webform.settings')->get('element.default_section_title_tag'),
+ '#title_tag' => $this->configFactory->get('webform.settings')->get('element.default_section_title_tag'),
'#attributes' => $attributes,
] + $children;
}
@@ -179,7 +179,7 @@ abstract class ContainerBase extends WebformElementBase {
*/
protected function formatTextItem(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
/** @var \Drupal\webform\WebformSubmissionViewBuilderInterface $view_builder */
- $view_builder = \Drupal::entityTypeManager()->getViewBuilder('webform_submission');
+ $view_builder = $this->entityTypeManager->getViewBuilder('webform_submission');
$children = $view_builder->buildElements($element, $webform_submission, $options, 'text');
if (empty($children)) {
return [];
@@ -210,7 +210,7 @@ abstract class ContainerBase extends WebformElementBase {
$template = trim($element['#format_' . $name]);
if (strpos($template, 'children') != FALSE) {
/** @var \Drupal\webform\WebformSubmissionViewBuilderInterface $view_builder */
- $view_builder = \Drupal::entityTypeManager()->getViewBuilder('webform_submission');
+ $view_builder = $this->entityTypeManager->getViewBuilder('webform_submission');
$context['children'] = $view_builder->buildElements($element, $webform_submission, $options, $name);
}
diff --git a/src/Plugin/WebformElement/DateBase.php b/src/Plugin/WebformElement/DateBase.php
index 85f94b909..54cca85c3 100644
--- a/src/Plugin/WebformElement/DateBase.php
+++ b/src/Plugin/WebformElement/DateBase.php
@@ -16,12 +16,29 @@ use Drupal\webform\Utility\WebformArrayHelper;
use Drupal\webform\Utility\WebformDateHelper;
use Drupal\webform\WebformSubmissionInterface;
use Drupal\webform\WebformInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a base 'date' class.
*/
abstract class DateBase extends WebformElementBase {
+ /**
+ * The date formatter service.
+ *
+ * @var \Drupal\Core\Datetime\DateFormatterInterface
+ */
+ protected $dateFormatter;
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+ $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
+ $instance->dateFormatter = $container->get('date.formatter');
+ return $instance;
+ }
+
/**
* {@inheritdoc}
*/
@@ -170,7 +187,7 @@ abstract class DateBase extends WebformElementBase {
return $value;
}
elseif (DateFormat::load($format)) {
- return \Drupal::service('date.formatter')->format($timestamp, $format);
+ return $this->dateFormatter->format($timestamp, $format);
}
else {
return static::formatDate($format, $timestamp);
@@ -381,12 +398,12 @@ abstract class DateBase extends WebformElementBase {
elseif (is_array($element[$property])) {
foreach ($element[$property] as $key => $value) {
$timestamp = strtotime($value);
- $element[$property][$key] = ($timestamp) ? \Drupal::service('date.formatter')->format($timestamp, 'html_' . $this->getDateType($element)) : NULL;
+ $element[$property][$key] = ($timestamp) ? $this->dateFormatter->format($timestamp, 'html_' . $this->getDateType($element)) : NULL;
}
}
else {
$timestamp = strtotime($element[$property]);
- $element[$property] = ($timestamp) ? \Drupal::service('date.formatter')->format($timestamp, 'html_' . $this->getDateType($element)) : NULL;
+ $element[$property] = ($timestamp) ? $this->dateFormatter->format($timestamp, 'html_' . $this->getDateType($element)) : NULL;
}
}
diff --git a/src/Plugin/WebformElement/Email.php b/src/Plugin/WebformElement/Email.php
index ced4174f6..28a74c792 100644
--- a/src/Plugin/WebformElement/Email.php
+++ b/src/Plugin/WebformElement/Email.php
@@ -3,6 +3,7 @@
namespace Drupal\webform\Plugin\WebformElement;
use Drupal\webform\WebformSubmissionInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a 'email' element.
@@ -17,6 +18,22 @@ use Drupal\webform\WebformSubmissionInterface;
*/
class Email extends TextBase {
+ /**
+ * The path validator service.
+ *
+ * @var \Drupal\Core\Path\PathValidatorInterface
+ */
+ protected $pathValidator;
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+ $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
+ $instance->pathValidator = $container->get('path.validator');
+ return $instance;
+ }
+
/**
* {@inheritdoc}
*/
@@ -45,7 +62,7 @@ class Email extends TextBase {
return [
'#type' => 'link',
'#title' => $value,
- '#url' => \Drupal::pathValidator()->getUrlIfValid('mailto:' . $value),
+ '#url' => $this->pathValidator->getUrlIfValid('mailto:' . $value),
];
default:
diff --git a/src/Plugin/WebformElement/LanguageSelect.php b/src/Plugin/WebformElement/LanguageSelect.php
index ed77e12c0..9f21dc849 100644
--- a/src/Plugin/WebformElement/LanguageSelect.php
+++ b/src/Plugin/WebformElement/LanguageSelect.php
@@ -4,6 +4,7 @@ namespace Drupal\webform\Plugin\WebformElement;
use Drupal\webform\Plugin\WebformElementBase;
use Drupal\webform\WebformSubmissionInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a 'language_select' element.
@@ -18,6 +19,22 @@ use Drupal\webform\WebformSubmissionInterface;
*/
class LanguageSelect extends WebformElementBase {
+ /**
+ * The language manager service.
+ *
+ * @var \Drupal\Core\Language\LanguageManagerInterface
+ */
+ protected $languageManager;
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+ $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
+ $instance->languageManager = $container->get('language_manager');
+ return $instance;
+ }
+
/**
* {@inheritdoc}
*/
@@ -39,7 +56,7 @@ class LanguageSelect extends WebformElementBase {
protected function formatTextItem(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
$value = $this->getValue($element, $webform_submission, $options);
- $language = \Drupal::languageManager()->getLanguage($value);
+ $language = $this->languageManager->getLanguage($value);
$format = $this->getItemFormat($element);
switch ($format) {
case 'langcode':
diff --git a/src/Plugin/WebformElement/ProcessedText.php b/src/Plugin/WebformElement/ProcessedText.php
index a5e0d8ff0..624a120ce 100644
--- a/src/Plugin/WebformElement/ProcessedText.php
+++ b/src/Plugin/WebformElement/ProcessedText.php
@@ -5,6 +5,7 @@ namespace Drupal\webform\Plugin\WebformElement;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Mail\MailFormatHelper;
use Drupal\webform\WebformSubmissionInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a 'processed_text' element.
@@ -20,6 +21,22 @@ use Drupal\webform\WebformSubmissionInterface;
*/
class ProcessedText extends WebformMarkupBase {
+ /**
+ * The renderer.
+ *
+ * @var \Drupal\Core\Render\RendererInterface
+ */
+ protected $renderer;
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+ $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
+ $instance->renderer = $container->get('renderer');
+ return $instance;
+ }
+
/**
* {@inheritdoc}
*/
@@ -28,7 +45,7 @@ class ProcessedText extends WebformMarkupBase {
// Works around filter_default_format() throwing fatal error when
// user is not allowed to use any filter formats.
// @see filter_default_format.
- $formats = filter_formats(\Drupal::currentUser());
+ $formats = filter_formats($this->currentUser);
$format = reset($formats);
$default_format = $format ? $format->id() : filter_fallback_format();
}
@@ -61,7 +78,7 @@ class ProcessedText extends WebformMarkupBase {
// Copy to element so that we can render it without altering the actual
// $element.
$render_element = $element;
- $html = (string) \Drupal::service('renderer')->renderPlain($render_element);
+ $html = (string) $this->renderer->renderPlain($render_element);
$element['#markup'] = MailFormatHelper::htmlToText($html);
// Must remove #type, #text, and #format.
@@ -74,7 +91,7 @@ class ProcessedText extends WebformMarkupBase {
* {@inheritdoc}
*/
public function preview() {
- return (\Drupal::moduleHandler()->moduleExists('filter')) ? parent::preview() : [];
+ return ($this->moduleHandler->moduleExists('filter')) ? parent::preview() : [];
}
/**
@@ -85,7 +102,7 @@ class ProcessedText extends WebformMarkupBase {
// modal, then clicking the image button opens another modal,
// which closes the original modal.
// @todo Remove the below workaround once this issue is resolved.
- if (!$form_state->getUserInput() && \Drupal::currentUser()->hasPermission('administer webform')) {
+ if (!$form_state->getUserInput() && $this->currentUser->hasPermission('administer webform')) {
$this->messenger()->addWarning($this->t('Processed text element can not be opened within a modal. Please see Issue #2741877: Nested modals don\'t work.'));
}
$form = parent::form($form, $form_state);
diff --git a/src/Plugin/WebformElement/Table.php b/src/Plugin/WebformElement/Table.php
index abdc468fb..314fd4573 100644
--- a/src/Plugin/WebformElement/Table.php
+++ b/src/Plugin/WebformElement/Table.php
@@ -7,6 +7,7 @@ use Drupal\Core\Render\Element;
use Drupal\webform\Plugin\WebformElementBase;
use Drupal\webform\WebformInterface;
use Drupal\webform\WebformSubmissionInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a 'table' element.
@@ -21,6 +22,22 @@ use Drupal\webform\WebformSubmissionInterface;
*/
class Table extends WebformElementBase {
+ /**
+ * The renderer.
+ *
+ * @var \Drupal\Core\Render\RendererInterface
+ */
+ protected $renderer;
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+ $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
+ $instance->renderer = $container->get('renderer');
+ return $instance;
+ }
+
/**
* {@inheritdoc}
*/
@@ -142,7 +159,7 @@ class Table extends WebformElementBase {
protected function formatTextItem(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
// Render the HTML table.
$build = $this->formatHtml($element, $webform_submission, $options);
- $html = \Drupal::service('renderer')->renderPlain($build);
+ $html = $this->renderer->renderPlain($build);
// Convert table in pipe delimited plain text.
$html = preg_replace('#\s*\s*
' . WebformYaml::encode($data) . '']; - $this->messenger()->addWarning(\Drupal::service('renderer')->renderPlain($build)); + $this->messenger()->addWarning($this->renderer->renderPlain($build)); } } diff --git a/src/Plugin/WebformHandler/EmailWebformHandler.php b/src/Plugin/WebformHandler/EmailWebformHandler.php index 3697dfa73..60c2f5613 100644 --- a/src/Plugin/WebformHandler/EmailWebformHandler.php +++ b/src/Plugin/WebformHandler/EmailWebformHandler.php @@ -4,31 +4,20 @@ namespace Drupal\webform\Plugin\WebformHandler; use Drupal\Component\Render\FormattableMarkup; use Drupal\Component\Utility\Html; -use Drupal\Core\Config\ConfigFactoryInterface; -use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Language\LanguageManagerInterface; -use Drupal\Core\Logger\LoggerChannelFactoryInterface; -use Drupal\Core\Mail\MailManagerInterface; use Drupal\Core\Render\Markup; -use Drupal\Core\Session\AccountInterface; use Drupal\Core\Url; use Drupal\webform\Element\WebformAjaxElementTrait; use Drupal\webform\Element\WebformMessage; use Drupal\webform\Element\WebformSelectOther; use Drupal\webform\Plugin\WebformElement\WebformCompositeBase; -use Drupal\webform\Plugin\WebformElementManagerInterface; use Drupal\webform\Plugin\WebformHandlerBase; use Drupal\webform\Plugin\WebformHandlerMessageInterface; use Drupal\webform\Twig\WebformTwigExtension; use Drupal\webform\Utility\Mail; use Drupal\webform\Utility\WebformElementHelper; use Drupal\webform\Utility\WebformOptionsHelper; -use Drupal\webform\WebformSubmissionConditionsValidatorInterface; use Drupal\webform\WebformSubmissionInterface; -use Drupal\webform\WebformThemeManagerInterface; -use Drupal\webform\WebformTokenManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -134,40 +123,19 @@ class EmailWebformHandler extends WebformHandlerBase implements WebformHandlerMe */ protected $defaultValues; - /** - * {@inheritdoc} - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, LoggerChannelFactoryInterface $logger_factory, ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager, WebformSubmissionConditionsValidatorInterface $conditions_validator, AccountInterface $current_user, ModuleHandlerInterface $module_handler, LanguageManagerInterface $language_manager, MailManagerInterface $mail_manager, WebformThemeManagerInterface $theme_manager, WebformTokenManagerInterface $token_manager, WebformElementManagerInterface $element_manager) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $logger_factory, $config_factory, $entity_type_manager, $conditions_validator); - $this->currentUser = $current_user; - $this->moduleHandler = $module_handler; - $this->languageManager = $language_manager; - $this->mailManager = $mail_manager; - $this->themeManager = $theme_manager; - $this->tokenManager = $token_manager; - $this->elementManager = $element_manager; - } - /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('logger.factory'), - $container->get('config.factory'), - $container->get('entity_type.manager'), - $container->get('webform_submission.conditions_validator'), - $container->get('current_user'), - $container->get('module_handler'), - $container->get('language_manager'), - $container->get('plugin.manager.mail'), - $container->get('webform.theme_manager'), - $container->get('webform.token_manager'), - $container->get('plugin.manager.webform.element') - ); + $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition); + $instance->currentUser = $container->get('current_user'); + $instance->moduleHandler = $container->get('module_handler'); + $instance->languageManager = $container->get('language_manager'); + $instance->mailManager = $container->get('plugin.manager.mail'); + $instance->themeManager = $container->get('webform.theme_manager'); + $instance->tokenManager = $container->get('webform.token_manager'); + $instance->elementManager = $container->get('plugin.manager.webform.element'); + return $instance; } /** diff --git a/src/Plugin/WebformHandler/RemotePostWebformHandler.php b/src/Plugin/WebformHandler/RemotePostWebformHandler.php index a6c9d2268..831fcd80a 100644 --- a/src/Plugin/WebformHandler/RemotePostWebformHandler.php +++ b/src/Plugin/WebformHandler/RemotePostWebformHandler.php @@ -2,25 +2,17 @@ namespace Drupal\webform\Plugin\WebformHandler; -use Drupal\Core\Config\ConfigFactoryInterface; -use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\Routing\TrustedRedirectResponse; use Drupal\Core\Serialization\Yaml; -use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Drupal\file\Entity\File; use Drupal\webform\Element\WebformMessage; use Drupal\webform\Plugin\WebformElement\WebformManagedFileBase; -use Drupal\webform\Plugin\WebformElementManagerInterface; use Drupal\webform\Plugin\WebformHandlerBase; use Drupal\webform\WebformInterface; use Drupal\webform\WebformMessageManagerInterface; -use Drupal\webform\WebformSubmissionConditionsValidatorInterface; use Drupal\webform\WebformSubmissionInterface; -use Drupal\webform\WebformTokenManagerInterface; -use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\RequestException; use Psr\Http\Message\ResponseInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -87,36 +79,17 @@ class RemotePostWebformHandler extends WebformHandlerBase { 'metatag', ]; - /** - * {@inheritdoc} - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, LoggerChannelFactoryInterface $logger_factory, ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager, WebformSubmissionConditionsValidatorInterface $conditions_validator, ModuleHandlerInterface $module_handler, ClientInterface $http_client, WebformTokenManagerInterface $token_manager, WebformMessageManagerInterface $message_manager, WebformElementManagerInterface $element_manager) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $logger_factory, $config_factory, $entity_type_manager, $conditions_validator); - $this->moduleHandler = $module_handler; - $this->httpClient = $http_client; - $this->tokenManager = $token_manager; - $this->messageManager = $message_manager; - $this->elementManager = $element_manager; - } - /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('logger.factory'), - $container->get('config.factory'), - $container->get('entity_type.manager'), - $container->get('webform_submission.conditions_validator'), - $container->get('module_handler'), - $container->get('http_client'), - $container->get('webform.token_manager'), - $container->get('webform.message_manager'), - $container->get('plugin.manager.webform.element') - ); + $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition); + $instance->moduleHandler = $container->get('module_handler'); + $instance->httpClient = $container->get('http_client'); + $instance->tokenManager = $container->get('webform.token_manager'); + $instance->messageManager = $container->get('webform.message_manager'); + $instance->elementManager = $container->get('plugin.manager.webform.element'); + return $instance; } /** @@ -147,6 +120,7 @@ class RemotePostWebformHandler extends WebformHandlerBase { * {@inheritdoc} */ public function defaultConfiguration() { + // @todo Determine why entity field manager dependency can't be injected. $field_names = array_keys(\Drupal::service('entity_field.manager')->getBaseFieldDefinitions('webform_submission')); $excluded_data = array_combine($field_names, $field_names); return [ @@ -831,7 +805,7 @@ class RemotePostWebformHandler extends WebformHandlerBase { '#markup' => $message, ]; - $this->messenger()->addMessage(\Drupal::service('renderer')->renderPlain($build), $type); + $this->messenger()->addMessage($this->renderer->renderPlain($build), $type); } /** @@ -888,7 +862,7 @@ class RemotePostWebformHandler extends WebformHandlerBase { $build_message = [ '#markup' => $this->replaceTokens($custom_response_message, $this->getWebform(), $token_data), ]; - $this->messenger()->addError(\Drupal::service('renderer')->renderPlain($build_message)); + $this->messenger()->addError($this->renderer->renderPlain($build_message)); } else { $this->messageManager->display(WebformMessageManagerInterface::SUBMISSION_EXCEPTION_MESSAGE, 'error'); diff --git a/src/Plugin/WebformHandler/SettingsWebformHandler.php b/src/Plugin/WebformHandler/SettingsWebformHandler.php index 9cceace5b..63b2802ad 100644 --- a/src/Plugin/WebformHandler/SettingsWebformHandler.php +++ b/src/Plugin/WebformHandler/SettingsWebformHandler.php @@ -3,18 +3,12 @@ namespace Drupal\webform\Plugin\WebformHandler; use Drupal\Component\Utility\Unicode; -use Drupal\Core\Config\ConfigFactoryInterface; -use Drupal\Core\Config\TypedConfigManagerInterface; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Logger\LoggerChannelFactoryInterface; -use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\webform\Entity\Webform; use Drupal\webform\Plugin\WebformHandlerBase; use Drupal\webform\Utility\WebformArrayHelper; use Drupal\webform\WebformInterface; -use Drupal\webform\WebformSubmissionConditionsValidatorInterface; use Drupal\webform\WebformSubmissionInterface; -use Drupal\webform\WebformTokenManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -47,30 +41,14 @@ class SettingsWebformHandler extends WebformHandlerBase { */ protected $tokenManager; - /** - * {@inheritdoc} - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, LoggerChannelFactoryInterface $logger_factory, ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager, WebformSubmissionConditionsValidatorInterface $conditions_validator, TypedConfigManagerInterface $typed_config, WebformTokenManagerInterface $token_manager) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $logger_factory, $config_factory, $entity_type_manager, $conditions_validator); - $this->typedConfigManager = $typed_config; - $this->tokenManager = $token_manager; - } - /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('logger.factory'), - $container->get('config.factory'), - $container->get('entity_type.manager'), - $container->get('webform_submission.conditions_validator'), - $container->get('config.typed'), - $container->get('webform.token_manager') - ); + $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition); + $instance->typedConfigManager = $container->get('config.typed'); + $instance->tokenManager = $container->get('webform.token_manager'); + return $instance; } /** @@ -349,7 +327,7 @@ class SettingsWebformHandler extends WebformHandlerBase { '#header' => $header, '#rows' => $rows, ]; - $this->messenger()->addWarning(\Drupal::service('renderer')->renderPlain($build)); + $this->messenger()->addWarning($this->renderer->renderPlain($build)); } /****************************************************************************/ diff --git a/src/Plugin/WebformHandlerBase.php b/src/Plugin/WebformHandlerBase.php index 452b2d115..c5b2f3d8b 100644 --- a/src/Plugin/WebformHandlerBase.php +++ b/src/Plugin/WebformHandlerBase.php @@ -2,17 +2,13 @@ namespace Drupal\webform\Plugin; -use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Logger\LoggerChannelFactoryInterface; use Drupal\Core\Plugin\PluginBase; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Access\AccessResult; use Drupal\webform\Utility\WebformElementHelper; use Drupal\webform\WebformInterface; -use Drupal\webform\WebformSubmissionConditionsValidatorInterface; use Drupal\webform\WebformSubmissionInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -89,6 +85,13 @@ abstract class WebformHandlerBase extends PluginBase implements WebformHandlerIn */ protected $loggerFactory; + /** + * The renderer. + * + * @var \Drupal\Core\Render\RendererInterface + */ + protected $renderer; + /** * Webform submission storage. * @@ -111,7 +114,7 @@ abstract class WebformHandlerBase extends PluginBase implements WebformHandlerIn protected $tokenManager; /** - * Constructs a WebformHandlerBase object. + * {@inheritdoc} * * IMPORTANT: * Webform handlers are initialized and serialized when they are attached to a @@ -121,50 +124,20 @@ abstract class WebformHandlerBase extends PluginBase implements WebformHandlerIn * from being thrown when a form is serialized via an Ajax callback and/or * form build. * - * @param array $configuration - * A configuration array containing information about the plugin instance. - * @param string $plugin_id - * The plugin_id for the plugin instance. - * @param mixed $plugin_definition - * The plugin implementation definition. - * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory - * The logger factory. - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The configuration factory. - * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager - * The entity type manager. - * @param \Drupal\webform\WebformSubmissionConditionsValidatorInterface $conditions_validator - * The webform submission conditions (#states) validator. - * - * @see \Drupal\webform\Entity\Webform::getHandlers */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, LoggerChannelFactoryInterface $logger_factory, ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager, WebformSubmissionConditionsValidatorInterface $conditions_validator) { - parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->loggerFactory = $logger_factory; - $this->configFactory = $config_factory; - $this->submissionStorage = $entity_type_manager->getStorage('webform_submission'); - $this->conditionsValidator = $conditions_validator; + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + $instance = new static($configuration, $plugin_id, $plugin_definition); - // @todo Webform 8.x-6.x: Properly inject the token manager. - // @todo Webform 8.x-6.x: Update handlers that injects the token manager. - $this->tokenManager = \Drupal::service('webform.token_manager'); + $instance->loggerFactory = $container->get('logger.factory'); + $instance->configFactory = $container->get('config.factory'); + $instance->renderer = $container->get('renderer'); + $instance->submissionStorage = $container->get('entity_type.manager')->getStorage('webform_submission'); + $instance->conditionsValidator = $container->get('webform_submission.conditions_validator'); + $instance->tokenManager = $container->get('webform.token_manager'); - $this->setConfiguration($configuration); - } + $instance->setConfiguration($configuration); - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('logger.factory'), - $container->get('config.factory'), - $container->get('entity_type.manager'), - $container->get('webform_submission.conditions_validator') - ); + return $instance; } /** diff --git a/src/Plugin/WebformSourceEntity/QueryStringWebformSourceEntity.php b/src/Plugin/WebformSourceEntity/QueryStringWebformSourceEntity.php index 633e471e6..165594ddd 100644 --- a/src/Plugin/WebformSourceEntity/QueryStringWebformSourceEntity.php +++ b/src/Plugin/WebformSourceEntity/QueryStringWebformSourceEntity.php @@ -2,16 +2,9 @@ namespace Drupal\webform\Plugin\WebformSourceEntity; -use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Core\Language\LanguageManagerInterface; -use Drupal\Core\Plugin\ContainerFactoryPluginInterface; -use Drupal\Core\Plugin\PluginBase; -use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\TypedData\TranslatableInterface; -use Drupal\webform\Plugin\WebformSourceEntityInterface; -use Drupal\webform\WebformEntityReferenceManagerInterface; +use Drupal\webform\Plugin\WebformSourceEntityBase; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\RequestStack; /** * Detect source entity by examining query string. @@ -22,7 +15,7 @@ use Symfony\Component\HttpFoundation\RequestStack; * weight = 0 * ) */ -class QueryStringWebformSourceEntity extends PluginBase implements WebformSourceEntityInterface, ContainerFactoryPluginInterface { +class QueryStringWebformSourceEntity extends WebformSourceEntityBase { /** * Entity type manager service. @@ -32,7 +25,7 @@ class QueryStringWebformSourceEntity extends PluginBase implements WebformSource protected $entityTypeManager; /** - * Current route match service. + * The current route match. * * @var \Drupal\Core\Routing\RouteMatchInterface */ @@ -59,50 +52,17 @@ class QueryStringWebformSourceEntity extends PluginBase implements WebformSource */ protected $webformEntityReferenceManager; - /** - * QueryStringWebformSourceEntity constructor. - * - * @param array $configuration - * A configuration array containing information about the plugin instance. - * @param string $plugin_id - * The plugin_id for the plugin instance. - * @param mixed $plugin_definition - * The plugin implementation definition. - * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager - * The "entity_type.manager" service. - * @param \Drupal\Core\Routing\RouteMatchInterface $route_match - * The "current_route_match" service. - * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack - * The "request_stack" service. - * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager - * The "language_manager" service. - * @param \Drupal\webform\WebformEntityReferenceManagerInterface $webform_entity_reference_manager - * The "webform.entity_reference_manager" service. - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, RouteMatchInterface $route_match, RequestStack $request_stack, LanguageManagerInterface $language_manager, WebformEntityReferenceManagerInterface $webform_entity_reference_manager) { - parent::__construct($configuration, $plugin_id, $plugin_definition); - - $this->entityTypeManager = $entity_type_manager; - $this->routeMatch = $route_match; - $this->request = $request_stack->getCurrentRequest(); - $this->languageManager = $language_manager; - $this->webformEntityReferenceManager = $webform_entity_reference_manager; - } - /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('entity_type.manager'), - $container->get('current_route_match'), - $container->get('request_stack'), - $container->get('language_manager'), - $container->get('webform.entity_reference_manager') - ); + $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition); + $instance->entityTypeManager = $container->get('entity_type.manager'); + $instance->routeMatch = $container->get('current_route_match'); + $instance->request = $container->get('request_stack')->getCurrentRequest(); + $instance->languageManager = $container->get('language_manager'); + $instance->webformEntityReferenceManager = $container->get('webform.entity_reference_manager'); + return $instance; } /** diff --git a/src/Plugin/WebformSourceEntity/RouteParametersWebformSourceEntity.php b/src/Plugin/WebformSourceEntity/RouteParametersWebformSourceEntity.php index fba4d6264..a0ef8a41a 100644 --- a/src/Plugin/WebformSourceEntity/RouteParametersWebformSourceEntity.php +++ b/src/Plugin/WebformSourceEntity/RouteParametersWebformSourceEntity.php @@ -3,10 +3,7 @@ namespace Drupal\webform\Plugin\WebformSourceEntity; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Plugin\ContainerFactoryPluginInterface; -use Drupal\Core\Plugin\PluginBase; -use Drupal\Core\Routing\RouteMatchInterface; -use Drupal\webform\Plugin\WebformSourceEntityInterface; +use Drupal\webform\Plugin\WebformSourceEntityBase; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -18,43 +15,22 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * weight = 100 * ) */ -class RouteParametersWebformSourceEntity extends PluginBase implements WebformSourceEntityInterface, ContainerFactoryPluginInterface { +class RouteParametersWebformSourceEntity extends WebformSourceEntityBase { /** - * Current route match service. + * The current route match. * * @var \Drupal\Core\Routing\RouteMatchInterface */ protected $routeMatch; - /** - * RouteParametersWebformSourceEntity constructor. - * - * @param array $configuration - * A configuration array containing information about the plugin instance. - * @param string $plugin_id - * The plugin_id for the plugin instance. - * @param mixed $plugin_definition - * The plugin implementation definition. - * @param \Drupal\Core\Routing\RouteMatchInterface $route_match - * The "current_route_match" service. - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, RouteMatchInterface $route_match) { - parent::__construct($configuration, $plugin_id, $plugin_definition); - - $this->routeMatch = $route_match; - } - /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('current_route_match') - ); + $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition); + $instance->routeMatch = $container->get('current_route_match'); + return $instance; } /** diff --git a/src/Plugin/WebformSourceEntityBase.php b/src/Plugin/WebformSourceEntityBase.php new file mode 100644 index 000000000..00f47851f --- /dev/null +++ b/src/Plugin/WebformSourceEntityBase.php @@ -0,0 +1,25 @@ +requestStack = $request_stack; - $this->entityTypeManager = $entity_type_manager; - $this->webformSourceEntityManager = $webform_source_entity_manager; - $this->accessRulesManager = $access_rules_manager; - } - /** * {@inheritdoc} */ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { - return new static( - $entity_type, - $container->get('request_stack'), - $container->get('entity_type.manager'), - $container->get('plugin.manager.webform.source_entity'), - $container->get('webform.access_rules_manager') - ); + $instance = new static($entity_type); + $instance->requestStack = $container->get('request_stack'); + $instance->entityTypeManager = $container->get('entity_type.manager'); + $instance->webformSourceEntityManager = $container->get('plugin.manager.webform.source_entity'); + $instance->accessRulesManager = $container->get('webform.access_rules_manager'); + return $instance; } /** diff --git a/src/WebformEntityElementsForm.php b/src/WebformEntityElementsForm.php index 6b6e32706..a22a890e5 100644 --- a/src/WebformEntityElementsForm.php +++ b/src/WebformEntityElementsForm.php @@ -5,10 +5,8 @@ namespace Drupal\webform; use Drupal\Core\Entity\BundleEntityFormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; -use Drupal\Core\Render\ElementInfoManagerInterface; use Drupal\Core\Serialization\Yaml; use Drupal\webform\Form\WebformDialogFormTrait; -use Drupal\webform\Plugin\WebformElementManagerInterface; use Drupal\webform\Utility\WebformYaml; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -47,36 +45,16 @@ class WebformEntityElementsForm extends BundleEntityFormBase { */ protected $tokenManager; - /** - * Constructs a WebformEntityElementsForm. - * - * @param \Drupal\Core\Render\ElementInfoManagerInterface $element_info - * The element manager. - * @param \Drupal\webform\Plugin\WebformElementManagerInterface $element_manager - * The webform element manager. - * @param \Drupal\webform\WebformEntityElementsValidatorInterface $elements_validator - * Webform element validator. - * @param \Drupal\webform\WebformTokenManagerInterface $token_manager - * The webform token manager. - */ - public function __construct(ElementInfoManagerInterface $element_info, WebformElementManagerInterface $element_manager, WebformEntityElementsValidatorInterface $elements_validator, WebformTokenManagerInterface $token_manager) { - $this->elementInfo = $element_info; - $this->elementManager = $element_manager; - $this->elementsValidator = $elements_validator; - $this->tokenManager = $token_manager; - - } - /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { - return new static( - $container->get('plugin.manager.element_info'), - $container->get('plugin.manager.webform.element'), - $container->get('webform.elements_validator'), - $container->get('webform.token_manager') - ); + $instance = parent::create($container); + $instance->elementInfo = $container->get('plugin.manager.element_info'); + $instance->elementManager = $container->get('plugin.manager.webform.element'); + $instance->elementsValidator = $container->get('webform.elements_validator'); + $instance->tokenManager = $container->get('webform.token_manager'); + return $instance; } /** diff --git a/src/WebformEntityHandlersForm.php b/src/WebformEntityHandlersForm.php index b838b5268..d271bb21d 100644 --- a/src/WebformEntityHandlersForm.php +++ b/src/WebformEntityHandlersForm.php @@ -9,7 +9,6 @@ use Drupal\Core\Url; use Drupal\webform\Ajax\WebformRefreshCommand; use Drupal\webform\Form\WebformEntityAjaxFormTrait; use Drupal\webform\Plugin\WebformHandlerInterface; -use Drupal\webform\Plugin\WebformHandlerManagerInterface; use Drupal\webform\Utility\WebformDialogHelper; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -36,23 +35,13 @@ class WebformEntityHandlersForm extends EntityForm { */ protected $handlerManager; - /** - * Constructs a WebformEntityHandlersForm. - * - * @param \Drupal\webform\Plugin\WebformHandlerManagerInterface $handler_manager - * The webform handler manager. - */ - public function __construct(WebformHandlerManagerInterface $handler_manager) { - $this->handlerManager = $handler_manager; - } - /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { - return new static( - $container->get('plugin.manager.webform.handler') - ); + $instance = parent::create($container); + $instance->handlerManager = $container->get('plugin.manager.webform.handler'); + return $instance; } /** diff --git a/src/WebformEntityListBuilder.php b/src/WebformEntityListBuilder.php index d91c95934..f547bcc52 100644 --- a/src/WebformEntityListBuilder.php +++ b/src/WebformEntityListBuilder.php @@ -5,16 +5,12 @@ namespace Drupal\webform; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\Entity\ConfigEntityListBuilder; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Core\Session\AccountInterface; use Drupal\Core\Url; use Drupal\webform\Element\WebformHtmlEditor; use Drupal\webform\Utility\WebformDialogHelper; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\RequestStack; /** * Defines a class to build a listing of webform entities. @@ -30,6 +26,13 @@ class WebformEntityListBuilder extends ConfigEntityListBuilder { */ protected $request; + /** + * The configuration object factory. + * + * @var \Drupal\Core\Config\ConfigFactoryInterface + */ + protected $configFactory; + /** * The current user. * @@ -80,50 +83,33 @@ class WebformEntityListBuilder extends ConfigEntityListBuilder { protected $roleStorage; /** - * Constructs a new WebformListBuilder object. - * - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type - * The entity type definition. - * @param \Drupal\Core\Entity\EntityStorageInterface $storage - * The entity storage class. - * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack - * The request stack. - * @param \Drupal\Core\Session\AccountInterface $current_user - * The current user. - * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager - * The entity type manager. - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The configuration factory. + * {@inheritdoc} */ - public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, RequestStack $request_stack, AccountInterface $current_user, EntityTypeManagerInterface $entity_type_manager, ConfigFactoryInterface $config_factory = NULL) { - parent::__construct($entity_type, $storage); - $this->request = $request_stack->getCurrentRequest(); - $this->currentUser = $current_user; + public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { + /** @var \Drupal\webform\WebformEntityListBuilder $instance */ + $instance = parent::createInstance($container, $entity_type); + + $entity_type_manager = $container->get('entity_type.manager'); + + $instance->request = $container->get('request_stack')->getCurrentRequest(); + $instance->configFactory = $container->get('config.factory'); + $instance->currentUser = $container->get('current_user'); + $instance->submissionStorage = $entity_type_manager->getStorage('webform_submission'); + $instance->userStorage = $entity_type_manager->getStorage('user'); + $instance->roleStorage = $entity_type_manager->getStorage('user_role'); + $instance->initialize(); + return $instance; + } + /** + * Initialize WebformEntityListBuilder object. + */ + protected function initialize() { $query = $this->request->query; - $config = $config_factory->get('webform.settings'); + $config = $this->configFactory->get('webform.settings'); $this->keys = ($query->has('search')) ? $query->get('search') : ''; $this->category = ($query->has('category')) ? $query->get('category') : $config->get('form.filter_category'); $this->state = ($query->has('state')) ? $query->get('state') : $config->get('form.filter_state'); - - $this->submissionStorage = $entity_type_manager->getStorage('webform_submission'); - $this->userStorage = $entity_type_manager->getStorage('user'); - $this->roleStorage = $entity_type_manager->getStorage('user_role'); - - } - - /** - * {@inheritdoc} - */ - public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { - return new static( - $entity_type, - $container->get('entity_type.manager')->getStorage($entity_type->id()), - $container->get('request_stack'), - $container->get('current_user'), - $container->get('entity_type.manager'), - $container->get('config.factory') - ); } /** diff --git a/src/WebformEntityStorage.php b/src/WebformEntityStorage.php index ef803b32e..2ff0c9395 100644 --- a/src/WebformEntityStorage.php +++ b/src/WebformEntityStorage.php @@ -2,17 +2,10 @@ namespace Drupal\webform; -use Drupal\Component\Uuid\UuidInterface; use Drupal\Core\Cache\Cache; -use Drupal\Core\Cache\MemoryCache\MemoryCacheInterface; -use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\Entity\ConfigEntityStorage; -use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Core\File\FileSystemInterface; -use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\StreamWrapper\StreamWrapperInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -36,7 +29,7 @@ class WebformEntityStorage extends ConfigEntityStorage implements WebformEntityS protected $entityTypeManager; /** - * The helpers to operate on files. + * The file system service. * * @var \Drupal\Core\File\FileSystemInterface */ @@ -49,49 +42,15 @@ class WebformEntityStorage extends ConfigEntityStorage implements WebformEntityS */ protected $totals; - /** - * Constructs a WebformEntityStorage object. - * - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type - * The entity type definition. - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The config factory service. - * @param \Drupal\Component\Uuid\UuidInterface $uuid_service - * The UUID service. - * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager - * The language manager. - * @param \Drupal\Core\Database\Connection $database - * The database connection to be used. - * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager - * The entity type manager service. - * @param \Drupal\Core\Cache\MemoryCache\MemoryCacheInterface $memory_cache - * The memory cache. - * @param \Drupal\Core\File\FileSystemInterface $file_system - * The helpers to operate on files. - * - * @todo Webform 8.x-6.x: Move $memory_cache right after $language_manager. - */ - public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, Connection $database, EntityTypeManagerInterface $entity_type_manager, MemoryCacheInterface $memory_cache = NULL, FileSystemInterface $file_system) { - parent::__construct($entity_type, $config_factory, $uuid_service, $language_manager, $memory_cache); - $this->database = $database; - $this->entityTypeManager = $entity_type_manager; - $this->fileSystem = $file_system; - } - /** * {@inheritdoc} */ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { - return new static( - $entity_type, - $container->get('config.factory'), - $container->get('uuid'), - $container->get('language_manager'), - $container->get('database'), - $container->get('entity_type.manager'), - $container->get('entity.memory_cache'), - $container->get('file_system') - ); + $instance = parent::createInstance($container, $entity_type); + $instance->database = $container->get('database'); + $instance->entityTypeManager = $container->get('entity_type.manager'); + $instance->fileSystem = $container->get('file_system'); + return $instance; } /** diff --git a/src/WebformOptionsListBuilder.php b/src/WebformOptionsListBuilder.php index 22a39ec21..29c61b20d 100644 --- a/src/WebformOptionsListBuilder.php +++ b/src/WebformOptionsListBuilder.php @@ -4,7 +4,6 @@ namespace Drupal\webform; use Drupal\Core\Config\Entity\ConfigEntityListBuilder; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Form\OptGroup; use Drupal\Core\Url; @@ -12,7 +11,6 @@ use Drupal\webform\Entity\WebformOptions; use Drupal\webform\Utility\WebformDialogHelper; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\RequestStack; /** * Defines a class to build a listing of webform options entities. @@ -36,32 +34,24 @@ class WebformOptionsListBuilder extends ConfigEntityListBuilder { protected $category; /** - * Constructs a new WebformOptionsListBuilder object. - * - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type - * The entity type definition. - * @param \Drupal\Core\Entity\EntityStorageInterface $storage - * The entity storage class. - * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack - * The request stack. + * {@inheritdoc} */ - public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, RequestStack $request_stack) { - parent::__construct($entity_type, $storage); - $this->request = $request_stack->getCurrentRequest(); + public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { + /** @var \Drupal\webform\WebformOptionsListBuilder $instance */ + $instance = parent::createInstance($container, $entity_type); - $this->keys = $this->request->query->get('search'); - $this->category = $this->request->query->get('category'); + $instance->request = $container->get('request_stack')->getCurrentRequest(); + + $instance->initialize(); + return $instance; } /** - * {@inheritdoc} + * Initialize WebformOptionsListBuilder object. */ - public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { - return new static( - $entity_type, - $container->get('entity.manager')->getStorage($entity_type->id()), - $container->get('request_stack') - ); + protected function initialize() { + $this->keys = $this->request->query->get('search'); + $this->category = $this->request->query->get('category'); } /** diff --git a/src/WebformOptionsStorage.php b/src/WebformOptionsStorage.php index 7da117523..fa394c1cf 100644 --- a/src/WebformOptionsStorage.php +++ b/src/WebformOptionsStorage.php @@ -3,16 +3,10 @@ namespace Drupal\webform; use Drupal\Component\Render\FormattableMarkup; -use Drupal\Component\Uuid\UuidInterface; -use Drupal\Core\Cache\MemoryCache\MemoryCacheInterface; -use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\Entity\ConfigEntityStorage; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Language\LanguageManagerInterface; -use Drupal\Core\Render\ElementInfoManagerInterface; use Drupal\Core\Serialization\Yaml; use Drupal\webform\Element\WebformCompositeBase; -use Drupal\webform\Plugin\WebformElementManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -48,45 +42,14 @@ class WebformOptionsStorage extends ConfigEntityStorage implements WebformOption */ protected $usedByWebforms; - /** - * Constructs a WebformOptionsStorage object. - * - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type - * The entity type definition. - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The config factory service. - * @param \Drupal\Component\Uuid\UuidInterface $uuid_service - * The UUID service. - * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager - * The language manager. - * @param \Drupal\Core\Render\ElementInfoManagerInterface $element_info - * The element info manager. - * @param \Drupal\webform\Plugin\WebformElementManagerInterface $element_manager - * The webform element manager. - * @param \Drupal\Core\Cache\MemoryCache\MemoryCacheInterface $memory_cache - * The memory cache. - * - * @todo Webform 8.x-6.x: Move $memory_cache right after $language_manager. - */ - public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, ElementInfoManagerInterface $element_info, WebformElementManagerInterface $element_manager, MemoryCacheInterface $memory_cache = NULL) { - parent::__construct($entity_type, $config_factory, $uuid_service, $language_manager, $memory_cache); - $this->elementInfo = $element_info; - $this->elementManager = $element_manager; - } - /** * {@inheritdoc} */ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { - return new static( - $entity_type, - $container->get('config.factory'), - $container->get('uuid'), - $container->get('language_manager'), - $container->get('plugin.manager.element_info'), - $container->get('plugin.manager.webform.element'), - $container->get('entity.memory_cache') - ); + $instance = parent::createInstance($container, $entity_type); + $instance->elementInfo = $container->get('plugin.manager.element_info'); + $instance->elementManager = $container->get('plugin.manager.webform.element'); + return $instance; } /** diff --git a/src/WebformSubmissionAccessControlHandler.php b/src/WebformSubmissionAccessControlHandler.php index 68c842818..4bdaf9924 100644 --- a/src/WebformSubmissionAccessControlHandler.php +++ b/src/WebformSubmissionAccessControlHandler.php @@ -9,7 +9,6 @@ use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Session\AccountInterface; use Drupal\webform\Access\WebformAccessResult; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\RequestStack; /** * Defines the access control handler for the webform submission entity type. @@ -32,32 +31,14 @@ class WebformSubmissionAccessControlHandler extends EntityAccessControlHandler i */ protected $request; - /** - * WebformSubmissionAccessControlHandler constructor. - * - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type - * The entity type definition. - * @param \Drupal\webform\WebformAccessRulesManagerInterface $access_rules_manager - * Webform access rules manager service. - * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack - * The request stack. - */ - public function __construct(EntityTypeInterface $entity_type, WebformAccessRulesManagerInterface $access_rules_manager, RequestStack $request_stack) { - parent::__construct($entity_type); - - $this->accessRulesManager = $access_rules_manager; - $this->request = $request_stack->getCurrentRequest(); - } - /** * {@inheritdoc} */ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { - return new static( - $entity_type, - $container->get('webform.access_rules_manager'), - $container->get('request_stack') - ); + $instance = new static($entity_type); + $instance->accessRulesManager = $container->get('webform.access_rules_manager'); + $instance->request = $container->get('request_stack')->getCurrentRequest(); + return $instance; } /** diff --git a/src/WebformSubmissionExporter.php b/src/WebformSubmissionExporter.php index b94e79055..113f06985 100644 --- a/src/WebformSubmissionExporter.php +++ b/src/WebformSubmissionExporter.php @@ -34,7 +34,7 @@ class WebformSubmissionExporter implements WebformSubmissionExporterInterface { protected $configFactory; /** - * File system service. + * The file system service. * * @var \Drupal\Core\File\FileSystemInterface */ diff --git a/src/WebformSubmissionForm.php b/src/WebformSubmissionForm.php index 97256dbe3..f612a7fc1 100644 --- a/src/WebformSubmissionForm.php +++ b/src/WebformSubmissionForm.php @@ -7,7 +7,6 @@ use Drupal\Component\Utility\Bytes; use Drupal\Component\Utility\Html; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Cache\Cache; -use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManagerInterface; use Drupal\Core\Entity\EntityRepositoryInterface; @@ -15,11 +14,7 @@ use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Form\FormState; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Messenger\MessengerInterface; -use Drupal\Core\PageCache\ResponsePolicy\KillSwitch; -use Drupal\Core\Path\AliasManagerInterface; -use Drupal\Core\Path\PathValidatorInterface; use Drupal\Core\Render\Element; -use Drupal\Core\Render\RendererInterface; use Drupal\Core\Routing\TrustedRedirectResponse; use Drupal\Core\Template\Attribute; use Drupal\Core\Url; @@ -61,6 +56,13 @@ class WebformSubmissionForm extends ContentEntityForm { */ protected $renderer; + /** + * The kill switch. + * + * @var \Drupal\Core\PageCache\ResponsePolicy\KillSwitch + */ + protected $killSwitch; + /** * The path alias manager. * @@ -69,7 +71,7 @@ class WebformSubmissionForm extends ContentEntityForm { protected $aliasManager; /** - * The path validator. + * The path validator service. * * @var \Drupal\Core\Path\PathValidatorInterface */ @@ -124,6 +126,13 @@ class WebformSubmissionForm extends ContentEntityForm { */ protected $webformEntityReferenceManager; + /** + * The selection plugin manager service. + * + * @var \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManagerInterface + */ + protected $selectionManager; + /** * The webform submission generation service. * @@ -152,20 +161,6 @@ class WebformSubmissionForm extends ContentEntityForm { */ protected $statesPrefix; - /** - * The kill switch. - * - * @var \Drupal\Core\PageCache\ResponsePolicy\KillSwitch - */ - protected $killSwitch; - - /** - * Selection Plugin Manager service. - * - * @var \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManagerInterface - */ - protected $selectionManager; - /** * Stores the original submission data passed via the EntityFormBuilder. * @@ -175,98 +170,26 @@ class WebformSubmissionForm extends ContentEntityForm { */ protected $originalData; - /** - * Constructs a WebformSubmissionForm object. - * - * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository - * The entity repository. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The factory for configuration objects. - * @param \Drupal\Core\Render\RendererInterface $renderer - * The renderer service. - * @param \Drupal\Core\Path\AliasManagerInterface $alias_manager - * The path alias manager. - * @param \Drupal\Core\Path\PathValidatorInterface $path_validator - * The path validator. - * @param \Drupal\webform\WebformRequestInterface $request_handler - * The webform request handler. - * @param \Drupal\webform\Plugin\WebformElementManagerInterface $element_manager - * The webform element manager. - * @param \Drupal\webform\WebformThirdPartySettingsManagerInterface $third_party_settings_manager - * The webform third party settings manager. - * @param \Drupal\webform\WebformMessageManagerInterface $message_manager - * The webform message manager. - * @param \Drupal\webform\WebformTokenManagerInterface $token_manager - * The webform token manager. - * @param \Drupal\webform\WebformSubmissionConditionsValidatorInterface $conditions_validator - * The webform submission conditions (#states) validator. - * @param \Drupal\webform\WebformEntityReferenceManagerInterface $webform_entity_reference_manager - * The webform entity reference manager. - * @param \Drupal\webform\WebformSubmissionGenerateInterface $submission_generate - * The webform submission generation service. - * @param \Drupal\Core\PageCache\ResponsePolicy\KillSwitch $killSwitch - * The page cache kill switch service. - * @param \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManagerInterface $selection_manager - * The selection plugin manager. - */ - public function __construct( - EntityRepositoryInterface $entity_repository, - ConfigFactoryInterface $config_factory, - RendererInterface $renderer, - AliasManagerInterface $alias_manager, - PathValidatorInterface $path_validator, - WebformRequestInterface $request_handler, - WebformElementManagerInterface $element_manager, - WebformThirdPartySettingsManagerInterface $third_party_settings_manager, - WebformMessageManagerInterface $message_manager, - WebformTokenManagerInterface $token_manager, - WebformSubmissionConditionsValidatorInterface $conditions_validator, - WebformEntityReferenceManagerInterface $webform_entity_reference_manager, - WebformSubmissionGenerateInterface $submission_generate, - KillSwitch $killSwitch, - SelectionPluginManagerInterface $selection_manager - ) { - parent::__construct($entity_repository); - $this->configFactory = $config_factory; - $this->renderer = $renderer; - $this->requestHandler = $request_handler; - $this->aliasManager = $alias_manager; - $this->pathValidator = $path_validator; - $this->elementManager = $element_manager; - $this->thirdPartySettingsManager = $third_party_settings_manager; - $this->messageManager = $message_manager; - $this->tokenManager = $token_manager; - $this->conditionsValidator = $conditions_validator; - $this->webformEntityReferenceManager = $webform_entity_reference_manager; - $this->generate = $submission_generate; - $this->killSwitch = $killSwitch; - $this->selectionManager = $selection_manager; - - } - /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { - return new static( - $container->get('entity.repository'), - $container->get('config.factory'), - $container->get('renderer'), - $container->get('path.alias_manager'), - $container->get('path.validator'), - $container->get('webform.request'), - $container->get('plugin.manager.webform.element'), - $container->get('webform.third_party_settings_manager'), - $container->get('webform.message_manager'), - $container->get('webform.token_manager'), - $container->get('webform_submission.conditions_validator'), - $container->get('webform.entity_reference_manager'), - $container->get('webform_submission.generate'), - $container->get('page_cache_kill_switch'), - $container->get('plugin.manager.entity_reference_selection') - ); + $instance = parent::create($container); + $instance->configFactory = $container->get('config.factory'); + $instance->renderer = $container->get('renderer'); + $instance->killSwitch = $container->get('page_cache_kill_switch'); + $instance->requestHandler = $container->get('webform.request'); + $instance->aliasManager = $container->get('path.alias_manager'); + $instance->pathValidator = $container->get('path.validator'); + $instance->elementManager = $container->get('plugin.manager.webform.element'); + $instance->thirdPartySettingsManager = $container->get('webform.third_party_settings_manager'); + $instance->messageManager = $container->get('webform.message_manager'); + $instance->tokenManager = $container->get('webform.token_manager'); + $instance->conditionsValidator = $container->get('webform_submission.conditions_validator'); + $instance->webformEntityReferenceManager = $container->get('webform.entity_reference_manager'); + $instance->generate = $container->get('webform_submission.generate'); + $instance->selectionManager = $container->get('plugin.manager.entity_reference_selection'); + return $instance; } /** diff --git a/src/WebformSubmissionListBuilder.php b/src/WebformSubmissionListBuilder.php index c8dff6eb1..a1a6b338b 100644 --- a/src/WebformSubmissionListBuilder.php +++ b/src/WebformSubmissionListBuilder.php @@ -3,25 +3,18 @@ namespace Drupal\webform; use Drupal\Component\Render\FormattableMarkup; -use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Database\Database; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityListBuilder; -use Drupal\Core\Entity\EntityStorageInterface; -use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Link; -use Drupal\Core\Routing\RouteMatchInterface; -use Drupal\Core\Session\AccountInterface; use Drupal\Core\Url; use Drupal\Core\Utility\TableSort; use Drupal\views\Views; use Drupal\webform\Controller\WebformSubmissionController; -use Drupal\webform\Plugin\WebformElementManagerInterface; use Drupal\webform\Utility\WebformArrayHelper; use Drupal\webform\Utility\WebformDialogHelper; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -252,55 +245,26 @@ class WebformSubmissionListBuilder extends EntityListBuilder { * {@inheritdoc} */ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { - return new static( - $entity_type, - $container->get('entity_type.manager')->getStorage($entity_type->id()), - $container->get('entity_type.manager'), - $container->get('current_route_match'), - $container->get('request_stack'), - $container->get('current_user'), - $container->get('config.factory'), - $container->get('webform.request'), - $container->get('plugin.manager.webform.element'), - $container->get('webform.message_manager') - ); + /** @var \Drupal\webform\WebformSubmissionListBuilder $instance */ + $instance = parent::createInstance($container, $entity_type); + + $instance->entityTypeManager = $container->get('entity_type.manager'); + $instance->routeMatch = $container->get('current_route_match'); + $instance->request = $container->get('request_stack')->getCurrentRequest(); + $instance->currentUser = $container->get('current_user'); + $instance->configFactory = $container->get('config.factory'); + $instance->requestHandler = $container->get('webform.request'); + $instance->elementManager = $container->get('plugin.manager.webform.element'); + $instance->messageManager = $container->get('webform.message_manager'); + + $instance->initialize(); + return $instance; } /** - * Constructs a new WebformSubmissionListBuilder object. - * - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type - * The entity type definition. - * @param \Drupal\Core\Entity\EntityStorageInterface $storage - * The entity storage class. - * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager - * The entity type manager. - * @param \Drupal\Core\Routing\RouteMatchInterface $route_match - * The current route match. - * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack - * The request stack. - * @param \Drupal\Core\Session\AccountInterface $current_user - * The current user. - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The configuration factory. - * @param \Drupal\webform\WebformRequestInterface $webform_request - * The webform request handler. - * @param \Drupal\webform\Plugin\WebformElementManagerInterface $element_manager - * The webform element manager. - * @param \Drupal\webform\WebformMessageManagerInterface $message_manager - * The webform message manager. + * Initialize WebformSubmissionListBuilder object. */ - public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, EntityTypeManagerInterface $entity_type_manager, RouteMatchInterface $route_match, RequestStack $request_stack, AccountInterface $current_user, ConfigFactoryInterface $config_factory, WebformRequestInterface $webform_request, WebformElementManagerInterface $element_manager, WebformMessageManagerInterface $message_manager) { - parent::__construct($entity_type, $storage); - $this->entityTypeManager = $entity_type_manager; - $this->routeMatch = $route_match; - $this->request = $request_stack->getCurrentRequest(); - $this->currentUser = $current_user; - $this->configFactory = $config_factory; - $this->requestHandler = $webform_request; - $this->elementManager = $element_manager; - $this->messageManager = $message_manager; - + protected function initialize() { $this->keys = $this->request->query->get('search'); $this->state = $this->request->query->get('state'); $this->sourceEntityTypeId = $this->request->query->get('entity'); diff --git a/src/WebformSubmissionNotesForm.php b/src/WebformSubmissionNotesForm.php index 3dc0b8709..fdffdabc0 100644 --- a/src/WebformSubmissionNotesForm.php +++ b/src/WebformSubmissionNotesForm.php @@ -3,12 +3,9 @@ namespace Drupal\webform; use Drupal\Core\Entity\ContentEntityForm; -use Drupal\Core\Entity\EntityRepositoryInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\webform\Form\WebformDialogFormTrait; use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\Component\Datetime\TimeInterface; -use Drupal\Core\Entity\EntityTypeBundleInfoInterface; /** * Controller for webform submission notes. @@ -24,35 +21,13 @@ class WebformSubmissionNotesForm extends ContentEntityForm { */ protected $requestHandler; - /** - * Constructs a ContentEntityForm object. - * - * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository - * The entity repository. - * @param \Drupal\webform\WebformRequestInterface $webform_request - * The webform request handler. - * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info - * The entity type bundle service. - * @param \Drupal\Component\Datetime\TimeInterface $time - * The time service. - */ - public function __construct(EntityRepositoryInterface $entity_repository, WebformRequestInterface $webform_request, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL) { - // Calling the parent constructor. - parent::__construct($entity_repository, $entity_type_bundle_info, $time); - - $this->requestHandler = $webform_request; - } - /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { - return new static( - $container->get('entity.repository'), - $container->get('webform.request'), - $container->get('entity_type.bundle.info'), - $container->get('datetime.time') - ); + $instance = parent::create($container); + $instance->requestHandler = $container->get('webform.request'); + return $instance; } /** diff --git a/src/WebformSubmissionStorage.php b/src/WebformSubmissionStorage.php index b73ed447f..3224f2b2d 100644 --- a/src/WebformSubmissionStorage.php +++ b/src/WebformSubmissionStorage.php @@ -2,26 +2,14 @@ namespace Drupal\webform; -use Drupal\Component\Datetime\TimeInterface; -use Drupal\Core\Cache\CacheBackendInterface; -use Drupal\Core\Cache\MemoryCache\MemoryCacheInterface; -use Drupal\Core\Database\Connection; use Drupal\Core\Database\Query\AlterableInterface; -use Drupal\Core\Database\ReplicaKillSwitch; -use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityStorageException; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Entity\Query\QueryInterface; -use Drupal\Core\Language\LanguageManagerInterface; -use Drupal\Core\Serialization\Yaml; -use Drupal\Core\Database\Database; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Entity\Query\QueryInterface; use Drupal\Core\Entity\Sql\SqlContentEntityStorage; -use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Session\AccountInterface; -use Drupal\Core\Session\AccountProxyInterface; use Drupal\Core\StreamWrapper\StreamWrapperInterface; -use Drupal\user\Entity\User; use Drupal\user\UserInterface; use Drupal\webform\Plugin\WebformElement\WebformManagedFileBase; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -73,39 +61,17 @@ class WebformSubmissionStorage extends SqlContentEntityStorage implements Webfor */ protected $accessRulesManager; - /** - * WebformSubmissionStorage constructor. - * - * @todo Webform 8.x-6.x: Move $time before $access_rules_manager. - * @todo Webform 8.x-6.x: Move $memory_cache right after $language_manager. - */ - public function __construct(EntityTypeInterface $entity_type, Connection $database, EntityManagerInterface $entity_manager, CacheBackendInterface $cache, LanguageManagerInterface $language_manager, AccountProxyInterface $current_user, WebformAccessRulesManagerInterface $access_rules_manager, TimeInterface $time = NULL, MemoryCacheInterface $memory_cache = NULL, FileSystemInterface $file_system = NULL, ReplicaKillSwitch $replica_kill_switch = NULL) { - parent::__construct($entity_type, $database, $entity_manager, $cache, $language_manager, $memory_cache); - - $this->currentUser = $current_user; - $this->accessRulesManager = $access_rules_manager; - $this->time = $time ?: \Drupal::time(); - $this->fileSystem = $file_system ?: \Drupal::service('file_system'); - $this->replicaKillSwitch = $replica_kill_switch ?: \Drupal::service('database.replica_kill_switch'); - } - /** * {@inheritdoc} */ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { - return new static( - $entity_type, - $container->get('database'), - $container->get('entity.manager'), - $container->get('cache.entity'), - $container->get('language_manager'), - $container->get('current_user'), - $container->get('webform.access_rules_manager'), - $container->get('datetime.time'), - $container->get('entity.memory_cache'), - $container->get('file_system'), - $container->get('database.replica_kill_switch') - ); + $instance = parent::createInstance($container, $entity_type); + $instance->time = $container->get('datetime.time'); + $instance->replicaKillSwitch = $container->get('database.replica_kill_switch'); + $instance->currentUser = $container->get('current_user'); + $instance->fileSystem = $container->get('file_system'); + $instance->accessRulesManager = $container->get('webform.access_rules_manager'); + return $instance; } /** diff --git a/src/WebformSubmissionViewBuilder.php b/src/WebformSubmissionViewBuilder.php index a6f0a2e64..308ee3c8d 100644 --- a/src/WebformSubmissionViewBuilder.php +++ b/src/WebformSubmissionViewBuilder.php @@ -4,13 +4,9 @@ namespace Drupal\webform; use Drupal\Core\Access\AccessResultInterface; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityViewBuilder; -use Drupal\Core\Routing\RouteMatchInterface; -use Drupal\Core\Language\LanguageManagerInterface; use Drupal\webform\Plugin\WebformElementAttachmentInterface; -use Drupal\webform\Plugin\WebformElementManagerInterface; use Drupal\webform\Twig\WebformTwigExtension; use Drupal\webform\Utility\WebformElementHelper; use Drupal\webform\Utility\WebformYaml; @@ -49,47 +45,16 @@ class WebformSubmissionViewBuilder extends EntityViewBuilder implements WebformS */ protected $conditionsValidator; - /** - * Constructs a WebformSubmissionViewBuilder. - * - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type - * The entity type definition. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager service. - * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager - * The language manager. - * @param \Drupal\webform\WebformRequestInterface $webform_request - * The webform request handler. - * @param \Drupal\webform\Plugin\WebformElementManagerInterface $element_manager - * The webform element manager service. - * @param \Drupal\webform\WebformSubmissionConditionsValidatorInterface $conditions_validator - * The webform submission conditions (#states) validator. - * @param \Drupal\Core\Routing\RouteMatchInterface $route_match - * The route match object. - * - * @todo Webform 8.x-6.x: Move $route_match before $webform_request. - */ - public function __construct(EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, WebformRequestInterface $webform_request, WebformElementManagerInterface $element_manager, WebformSubmissionConditionsValidatorInterface $conditions_validator, RouteMatchInterface $route_match = NULL) { - parent::__construct($entity_type, $entity_manager, $language_manager); - $this->requestHandler = $webform_request; - $this->elementManager = $element_manager; - $this->conditionsValidator = $conditions_validator; - $this->routeMatch = $route_match ?: \Drupal::routeMatch(); - } - /** * {@inheritdoc} */ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { - return new static( - $entity_type, - $container->get('entity.manager'), - $container->get('language_manager'), - $container->get('webform.request'), - $container->get('plugin.manager.webform.element'), - $container->get('webform_submission.conditions_validator'), - $container->get('current_route_match') - ); + $instance = parent::createInstance($container, $entity_type); + $instance->requestHandler = $container->get('webform.request'); + $instance->elementManager = $container->get('plugin.manager.webform.element'); + $instance->conditionsValidator = $container->get('webform_submission.conditions_validator'); + $instance->routeMatch = $container->get('current_route_match'); + return $instance; } /** diff --git a/src/WebformThirdPartySettingsManager.php b/src/WebformThirdPartySettingsManager.php index 6f2a351a9..9b571d587 100644 --- a/src/WebformThirdPartySettingsManager.php +++ b/src/WebformThirdPartySettingsManager.php @@ -29,7 +29,7 @@ class WebformThirdPartySettingsManager implements WebformThirdPartySettingsManag protected $moduleHandler; /** - * The path validator. + * The path validator service. * * @var \Drupal\Core\Path\PathValidatorInterface */ @@ -57,7 +57,7 @@ class WebformThirdPartySettingsManager implements WebformThirdPartySettingsManag * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler class to use for loading includes. * @param \Drupal\Core\Path\PathValidatorInterface $path_validator - * The path validator. + * The path validator service. * @param \Drupal\webform\WebformAddonsManagerInterface $addons_manager * The webform add-ons manager. */ diff --git a/tests/modules/webform_test_ajax/src/Plugin/Block/WebformTestAjaxBlock.php b/tests/modules/webform_test_ajax/src/Plugin/Block/WebformTestAjaxBlock.php index a2a8ba619..f23e60974 100644 --- a/tests/modules/webform_test_ajax/src/Plugin/Block/WebformTestAjaxBlock.php +++ b/tests/modules/webform_test_ajax/src/Plugin/Block/WebformTestAjaxBlock.php @@ -5,7 +5,6 @@ namespace Drupal\webform_test_ajax\Plugin\Block; use Drupal\Component\Serialization\Json; use Drupal\Core\Block\BlockBase; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; -use Drupal\Core\Routing\RedirectDestinationInterface; use Drupal\webform\Entity\Webform; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -27,33 +26,13 @@ class WebformTestAjaxBlock extends BlockBase implements ContainerFactoryPluginIn */ protected $redirectDestination; - /** - * Creates a WebformTestAjaxBlock instance. - * - * @param array $configuration - * A configuration array containing information about the plugin instance. - * @param string $plugin_id - * The plugin_id for the plugin instance. - * @param mixed $plugin_definition - * The plugin implementation definition. - * @param \Drupal\Core\Routing\RedirectDestinationInterface $redirect_destination - * The redirect destination service. - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, RedirectDestinationInterface $redirect_destination) { - parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->redirectDestination = $redirect_destination; - } - /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('redirect.destination') - ); + $instance = new static($configuration, $plugin_id, $plugin_definition); + $instance->redirectDestination = $container->get('redirect.destination'); + return $instance; } /** diff --git a/tests/modules/webform_test_handler/src/Plugin/WebformHandler/TestEntityMappingWebformHandler.php b/tests/modules/webform_test_handler/src/Plugin/WebformHandler/TestEntityMappingWebformHandler.php index 75fc67393..90bd76965 100644 --- a/tests/modules/webform_test_handler/src/Plugin/WebformHandler/TestEntityMappingWebformHandler.php +++ b/tests/modules/webform_test_handler/src/Plugin/WebformHandler/TestEntityMappingWebformHandler.php @@ -7,6 +7,7 @@ use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Serialization\Yaml; use Drupal\webform\Plugin\WebformHandlerBase; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Webform submission entity mapping test handler. @@ -26,6 +27,30 @@ use Drupal\webform\Plugin\WebformHandlerBase; */ class TestEntityMappingWebformHandler extends WebformHandlerBase { + /** + * The entity type manager. + * + * @var \Drupal\Core\Entity\EntityTypeManagerInterface + */ + protected $entityTypeManager; + + /** + * The entity field manager. + * + * @var \Drupal\Core\Entity\EntityFieldManagerInterface + */ + protected $entityFieldManager; + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + $instance = new static($configuration, $plugin_id, $plugin_definition); + $instance->entityTypeManager = $container->get('entity_type.manager'); + $instance->entityFieldManager = $container->get('entity_field.manager'); + return $instance; + } + /** * {@inheritdoc} */ @@ -54,7 +79,6 @@ class TestEntityMappingWebformHandler extends WebformHandlerBase { public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $this->applyFormStateToConfiguration($form_state); - $entity_type_manager = \Drupal::entityTypeManager(); // Define #ajax callback. $ajax = [ @@ -68,7 +92,7 @@ class TestEntityMappingWebformHandler extends WebformHandlerBase { // Get entity type options. $entity_type_options = []; - foreach ($entity_type_manager->getDefinitions() as $entity_type_id => $entity_type) { + foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) { if ($entity_type instanceof ContentEntityTypeInterface) { $entity_type_options[$entity_type_id] = $entity_type->getLabel(); } @@ -92,10 +116,10 @@ class TestEntityMappingWebformHandler extends WebformHandlerBase { // Get entity type bundle options. /** @var \Drupal\Core\Entity\ContentEntityInterface $entity_type */ - $entity_type = $entity_type_manager->getDefinition($this->configuration['entity_type']); + $entity_type = $this->entityTypeManager->getDefinition($this->configuration['entity_type']); $bundle_options = []; if ($bundle_entity_type = $entity_type->getBundleEntityType()) { - if ($bundles = $entity_type_manager->getStorage($bundle_entity_type)->loadMultiple()) { + if ($bundles = $this->entityTypeManager->getStorage($bundle_entity_type)->loadMultiple()) { foreach ($bundles as $bundle_id => $bundle) { $bundle_options[$bundle_id] = $bundle->label(); } @@ -136,7 +160,7 @@ class TestEntityMappingWebformHandler extends WebformHandlerBase { } // Get field options. - $fields = \Drupal::service('entity_field.manager')->getFieldDefinitions($this->configuration['entity_type'], $this->configuration['bundle']); + $fields = $this->entityFieldManager->getFieldDefinitions($this->configuration['entity_type'], $this->configuration['bundle']); $field_options = []; foreach ($fields as $field_name => $field) { $field_options[$field_name] = $field->getLabel(); diff --git a/tests/modules/webform_test_handler/src/Plugin/WebformHandler/TestWebformHandler.php b/tests/modules/webform_test_handler/src/Plugin/WebformHandler/TestWebformHandler.php index 1d1eaa7c5..61dd0afc0 100644 --- a/tests/modules/webform_test_handler/src/Plugin/WebformHandler/TestWebformHandler.php +++ b/tests/modules/webform_test_handler/src/Plugin/WebformHandler/TestWebformHandler.php @@ -105,7 +105,7 @@ class TestWebformHandler extends WebformHandlerBase { */ public function confirmForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) { $this->messenger()->addStatus($this->configuration['message'], TRUE); - \Drupal::logger('webform.test_form')->notice($this->configuration['message']); + $this->loggerFactory->get('webform.test_form')->notice($this->configuration['message']); $this->displayMessage(__FUNCTION__); } @@ -258,7 +258,7 @@ class TestWebformHandler extends WebformHandlerBase { '@context1' => $context1, ]; $this->messenger()->addStatus($this->t('Invoked @id: @class_name:@method_name @context1', $t_args), TRUE); - \Drupal::logger('webform.test_form')->notice('Invoked: @class_name:@method_name @context1', $t_args); + $this->loggerFactory->get('webform.test_form')->notice('Invoked: @class_name:@method_name @context1', $t_args); } } diff --git a/tests/src/Functional/Element/WebformElementManagedFileTestBase.php b/tests/src/Functional/Element/WebformElementManagedFileTestBase.php index a5e8e389a..c01b651a6 100644 --- a/tests/src/Functional/Element/WebformElementManagedFileTestBase.php +++ b/tests/src/Functional/Element/WebformElementManagedFileTestBase.php @@ -20,7 +20,7 @@ abstract class WebformElementManagedFileTestBase extends WebformElementBrowserTe public static $modules = ['file', 'webform']; /** - * File usage manager. + * The file usage service. * * @var \Drupal\file\FileUsage\FileUsageInterface */ diff --git a/tests/src/Functional/Element/WebformElementTextFormatTest.php b/tests/src/Functional/Element/WebformElementTextFormatTest.php index 2113f8ff2..f9134f173 100644 --- a/tests/src/Functional/Element/WebformElementTextFormatTest.php +++ b/tests/src/Functional/Element/WebformElementTextFormatTest.php @@ -31,7 +31,7 @@ class WebformElementTextFormatTest extends WebformElementBrowserTestBase { protected static $testWebforms = ['test_element_text_format']; /** - * File usage manager. + * The file usage service. * * @var \Drupal\file\FileUsage\FileUsageInterface */ diff --git a/tests/src/Functional/WebformEditorTest.php b/tests/src/Functional/WebformEditorTest.php index b9e4a032c..1163b2f25 100644 --- a/tests/src/Functional/WebformEditorTest.php +++ b/tests/src/Functional/WebformEditorTest.php @@ -23,7 +23,7 @@ class WebformEditorTest extends WebformBrowserTestBase { public static $modules = ['file', 'webform']; /** - * File usage manager. + * The file usage service. * * @var \Drupal\file\FileUsage\FileUsageInterface */ diff --git a/tests/src/Unit/Plugin/Block/WebformBlockTest.php b/tests/src/Unit/Plugin/Block/WebformBlockTest.php index 57786ec8b..9d9f7aced 100644 --- a/tests/src/Unit/Plugin/Block/WebformBlockTest.php +++ b/tests/src/Unit/Plugin/Block/WebformBlockTest.php @@ -4,6 +4,7 @@ namespace Drupal\Tests\webform\Unit\Plugin\Block; use Drupal\Core\Access\AccessResult; use Drupal\Core\Cache\Context\CacheContextsManager; +use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Session\AccountInterface; @@ -135,13 +136,19 @@ class WebformBlockTest extends UnitTestCase { ->disableOriginalConstructor() ->getMock(); + // Build container. + $container = new ContainerBuilder(); + $container->set('request_stack', $request_stack); + $container->set('entity_type.manager', $entity_type_manager); + $container->set('webform.token_manager', $token_manager); + $configuration = ['webform_id' => $webform->id()]; $plugin_id = 'webform_block'; $plugin_definition = ['provider' => 'unit_test']; - return new WebformBlock($configuration, $plugin_id, $plugin_definition, $request_stack, $entity_type_manager, $token_manager); + return WebformBlock::create($container, $configuration, $plugin_id, $plugin_definition); } } diff --git a/tests/src/Unit/Plugin/WebformSourceEntity/QueryStringWebformSourceEntityTest.php b/tests/src/Unit/Plugin/WebformSourceEntity/QueryStringWebformSourceEntityTest.php index fceba7fd9..168a56b4a 100644 --- a/tests/src/Unit/Plugin/WebformSourceEntity/QueryStringWebformSourceEntityTest.php +++ b/tests/src/Unit/Plugin/WebformSourceEntity/QueryStringWebformSourceEntityTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\webform\Unit\Plugin\WebformSourceEntity; +use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; @@ -128,10 +129,18 @@ class QueryStringWebformSourceEntityTest extends UnitTestCase { $language_manager->method('getCurrentLanguage') ->willReturn(new Language(['id' => 'es'])); + // Build container. + $container = new ContainerBuilder(); + $container->set('entity_type.manager', $entity_type_manager); + $container->set('current_route_match', $route_match); + $container->set('request_stack', $request_stack); + $container->set('language_manager', $language_manager); + $container->set('webform.entity_reference_manager', $webform_entity_reference_manager); + /**************************************************************************/ // Create QueryStringWebformSourceEntity plugin instance. - $plugin = new QueryStringWebformSourceEntity([], 'query_string', [], $entity_type_manager, $route_match, $request_stack, $language_manager, $webform_entity_reference_manager); + $plugin = QueryStringWebformSourceEntity::create($container, [], 'query_string', []); $output = $plugin->getSourceEntity($options['ignored_types']); if ($expect_source_entity) { diff --git a/tests/src/Unit/Plugin/WebformSourceEntity/RouteParametersWebformSourceEntityTest.php b/tests/src/Unit/Plugin/WebformSourceEntity/RouteParametersWebformSourceEntityTest.php index 694d336d1..0e0351f79 100644 --- a/tests/src/Unit/Plugin/WebformSourceEntity/RouteParametersWebformSourceEntityTest.php +++ b/tests/src/Unit/Plugin/WebformSourceEntity/RouteParametersWebformSourceEntityTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\webform\Unit\Plugin\WebformSourceEntity; +use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\webform\Plugin\WebformSourceEntity\RouteParametersWebformSourceEntity; @@ -57,7 +58,13 @@ class RouteParametersWebformSourceEntityTest extends UnitTestCase { $route_match->method('getParameters') ->willReturn(new ParameterBag($route_parameters)); - $plugin = new RouteParametersWebformSourceEntity([], 'route_parameters', [], $route_match); + // Build container. + $container = new ContainerBuilder(); + $container->set('current_route_match', $route_match); + + /**************************************************************************/ + + $plugin = RouteParametersWebformSourceEntity::create($container, [], 'route_parameters', []); $output = $plugin->getSourceEntity($ignored_types); if ($expect_source_entity) { diff --git a/tests/src/Unit/WebformEntityAccessControlHandlerTest.php b/tests/src/Unit/WebformEntityAccessControlHandlerTest.php index eac7c80a9..8cb9eb575 100644 --- a/tests/src/Unit/WebformEntityAccessControlHandlerTest.php +++ b/tests/src/Unit/WebformEntityAccessControlHandlerTest.php @@ -206,10 +206,17 @@ class WebformEntityAccessControlHandlerTest extends UnitTestCase { ) ); + // Build container. + $container = new ContainerBuilder(); + $container->set('request_stack', $request_stack); + $container->set('entity_type.manager', $entity_type_manager); + $container->set('plugin.manager.webform.source_entity', $webform_source_entity_manager); + $container->set('webform.access_rules_manager', $access_rules_manager); + /**************************************************************************/ // Create webform access control handler. - $access_handler = new WebformEntityAccessControlHandler($entity_type, $request_stack, $entity_type_manager, $webform_source_entity_manager, $access_rules_manager); + $access_handler = WebformEntityAccessControlHandler::createInstance($container, $entity_type); // Check access. $access_result = $access_handler->checkAccess($webform, $operation, $account);