diff --git a/src/Commands/QueueUiCommands.php b/src/Commands/QueueUiCommands.php index a8026b4999ecbcadf0456ded960024dc69fe84cd..c95b82a195b97b3dcae5fbac752100f6342d62d7 100644 --- a/src/Commands/QueueUiCommands.php +++ b/src/Commands/QueueUiCommands.php @@ -3,8 +3,8 @@ namespace Drupal\queue_ui\Commands; use Drupal\Core\Batch\BatchBuilder; -use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\Queue\QueueWorkerManagerInterface; +use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\queue_ui\QueueUIBatchInterface; use Drupal\queue_ui\QueueUIManager; use Drush\Commands\DrushCommands; diff --git a/src/Controller/QueueProcessController.php b/src/Controller/QueueProcessController.php index 6758a8ee4547ba1eff34a8c09efb266faa5ea55a..3ea9c5cce15aa3a3a41549df4d92ead69ff9d46f 100644 --- a/src/Controller/QueueProcessController.php +++ b/src/Controller/QueueProcessController.php @@ -6,11 +6,14 @@ use Drupal\Core\Access\AccessResult; use Drupal\Core\Access\AccessResultInterface; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Session\AccountProxyInterface; +use Drupal\queue_ui\QueueUIBatchInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; /** * Controller for the queue process route. + * + * @phpstan-consistent-constructor */ class QueueProcessController implements ContainerInjectionInterface { @@ -21,14 +24,24 @@ class QueueProcessController implements ContainerInjectionInterface { */ protected $batch; + /** + * Constructor for QueueProcessController. + * + * @param \Drupal\queue_ui\QueueUIBatchInterface|null $batch + * Queue UI batch instance. + */ + public function __construct(QueueUIBatchInterface $batch = NULL) { + if ($batch === NULL) { + $batch = \Drupal::service('queue_ui.batch'); + } + $this->batch = $batch; + } + /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { - $instance = new static(); - $instance->batch = $container->get('queue_ui.batch'); - - return $instance; + return new static($container->get('queue_ui.batch')); } /** diff --git a/src/Form/ConfirmClearForm.php b/src/Form/ConfirmClearForm.php index 3213611eb5934cae2debed3719f5bbf499b51b25..e60da739e7c3d0dfd3b8c94b053b7bfb811d6bb6 100644 --- a/src/Form/ConfirmClearForm.php +++ b/src/Form/ConfirmClearForm.php @@ -16,6 +16,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * Class ConfirmClearForm declaration. * * @package Drupal\queue_ui\Form + * @phpstan-consistent-constructor */ class ConfirmClearForm extends ConfirmFormBase { diff --git a/src/Form/ConfirmItemDeleteForm.php b/src/Form/ConfirmItemDeleteForm.php index 6c924ab014e8b5bf5e40eda18d5d006d3d249288..5397282d82fc2d46edd80dc7ad95bc92b60fdff0 100644 --- a/src/Form/ConfirmItemDeleteForm.php +++ b/src/Form/ConfirmItemDeleteForm.php @@ -13,6 +13,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * Class ConfirmItemDeleteForm declaration. * * @package Drupal\queue_ui\Form + * @phpstan-consistent-constructor */ class ConfirmItemDeleteForm extends ConfirmFormBase { diff --git a/src/Form/ConfirmItemReleaseForm.php b/src/Form/ConfirmItemReleaseForm.php index f9675891bb9aad054bab70c93aae2ac91fb8c74c..977666a9dc3c2e5552705e291b507f1d992c672e 100644 --- a/src/Form/ConfirmItemReleaseForm.php +++ b/src/Form/ConfirmItemReleaseForm.php @@ -13,6 +13,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * Class ConfirmItemReleaseForm declaration. * * @package Drupal\queue_ui\Form + * @phpstan-consistent-constructor */ class ConfirmItemReleaseForm extends ConfirmFormBase { diff --git a/src/Form/InspectForm.php b/src/Form/InspectForm.php index 58a0f5f8d12afd88a76734c17996cd9acc204c6d..ced76a729481c8fbbd81223522024ee7d7293fba 100644 --- a/src/Form/InspectForm.php +++ b/src/Form/InspectForm.php @@ -12,6 +12,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * Class InspectForm declaration. * * @package Drupal\queue_ui\Form + * @phpstan-consistent-constructor */ class InspectForm extends FormBase { @@ -101,6 +102,7 @@ class InspectForm extends FormBase { ], ]; } + return $form; } /** diff --git a/src/Form/ItemDetailForm.php b/src/Form/ItemDetailForm.php index 36e8a938570e8d9028538fa6c459b461c1583615..135f779a6961b9fb075a49dc01793ece63086723 100644 --- a/src/Form/ItemDetailForm.php +++ b/src/Form/ItemDetailForm.php @@ -2,10 +2,10 @@ namespace Drupal\queue_ui\Form; +use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\RendererInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\queue_ui\QueueUIManager; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -13,6 +13,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * Class QueueUIInspectForm declaration. * * @package Drupal\queue_ui\Form + * @phpstan-consistent-constructor */ class ItemDetailForm extends FormBase { @@ -128,6 +129,7 @@ class ItemDetailForm extends FormBase { ], ]; } + return $form; } /** diff --git a/src/Form/OverviewForm.php b/src/Form/OverviewForm.php index efe1ec9d01814bbb876835a32ffa23b234985f75..46758b3a1fbc1d8d474a046ca343191fd5817fb5 100644 --- a/src/Form/OverviewForm.php +++ b/src/Form/OverviewForm.php @@ -4,6 +4,8 @@ namespace Drupal\queue_ui\Form; use Drupal\Core\Database\Database; use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Form\FormBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Queue\QueueFactory; use Drupal\Core\Queue\QueueWorkerManagerInterface; @@ -14,13 +16,12 @@ use Drupal\Core\Url; use Drupal\queue_ui\QueueUIBatchInterface; use Drupal\queue_ui\QueueUIManager; use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\Core\Form\FormBase; -use Drupal\Core\Form\FormStateInterface; /** * Class QueueUIOverviewForm declaration. * * @package Drupal\queue_ui\Form + * @phpstan-consistent-constructor */ class OverviewForm extends FormBase { diff --git a/src/Plugin/QueueUI/DatabaseQueue.php b/src/Plugin/QueueUI/DatabaseQueue.php index e22ff5fe4ab793872b76160ba630b0046e06af13..8555604837ecd7bb13f502fd7c834eaeb9b67ec3 100644 --- a/src/Plugin/QueueUI/DatabaseQueue.php +++ b/src/Plugin/QueueUI/DatabaseQueue.php @@ -12,6 +12,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; /** * Defines the default Drupal Queue UI backend. * + * @phpstan-consistent-constructor * @QueueUI( * id = "database_queue", * class_name = "DatabaseQueue" diff --git a/src/QueueUIBatch.php b/src/QueueUIBatch.php index f905efda190d3dbae133f8635b3bd488aec0bf52..8e442c5ad365d71d2d148f77bd1b4f622e320256 100644 --- a/src/QueueUIBatch.php +++ b/src/QueueUIBatch.php @@ -185,9 +185,9 @@ class QueueUIBatch implements QueueUIBatchInterface { ); } elseif (!isset($results['processed'])) { - $this->messenger->addWarning(\Drupal::translation() - ->translate("Items were not processed. Try to release existing items or add new items to the queues.") - ); + $this->messenger->addWarning($this->t( + "Items were not processed. Try to release existing items or add new items to the queues." + )); } // Display errors. diff --git a/src/QueueUIPermissions.php b/src/QueueUIPermissions.php index 662efeb80ba97b4f27fffa24c1e49301cf1a998f..5b393757586ce5f2e2be41e128d7744dbc7aa6d5 100644 --- a/src/QueueUIPermissions.php +++ b/src/QueueUIPermissions.php @@ -3,11 +3,14 @@ namespace Drupal\queue_ui; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; +use Drupal\Core\Queue\QueueWorkerManagerInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides dynamic permissions for the queue_ui module. + * + * @phpstan-consistent-constructor */ class QueueUIPermissions implements ContainerInjectionInterface { @@ -20,14 +23,24 @@ class QueueUIPermissions implements ContainerInjectionInterface { */ private $queueWorkerManager; + /** + * Constructor for QueueUIPermissions. + * + * @param \Drupal\Core\Queue\QueueWorkerManagerInterface|null $queueWorkerManager + * Queue worker manager instance. + */ + public function __construct(QueueWorkerManagerInterface $queueWorkerManager = NULL) { + if ($queueWorkerManager === NULL) { + $queueWorkerManager = \Drupal::service('plugin.manager.queue_worker'); + } + $this->queueWorkerManager = $queueWorkerManager; + } + /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { - $instance = new static(); - $instance->queueWorkerManager = $container->get('plugin.manager.queue_worker'); - - return $instance; + return new static($container->get('plugin.manager.queue_worker')); } /** diff --git a/tests/src/FunctionalJavascript/BulkOperationsTest.php b/tests/src/FunctionalJavascript/BulkOperationsTest.php index 15ef8c6e29a1f8ef741845c842f37f7ef0e6f2b8..965062164b2ad3e08f8190260989283f12e97da6 100644 --- a/tests/src/FunctionalJavascript/BulkOperationsTest.php +++ b/tests/src/FunctionalJavascript/BulkOperationsTest.php @@ -40,7 +40,7 @@ class BulkOperationsTest extends WebDriverTestBase { * * @throws \Drupal\Core\Entity\EntityStorageException */ - public function testDefaultBulkOperation(): void { + final public function testDefaultBulkOperation(): void { $this->drupalLogin($this->createUser(['admin queue_ui'])); $formUrl = Url::fromRoute('queue_ui.overview_form'); $session = $this->assertSession(); @@ -53,6 +53,8 @@ class BulkOperationsTest extends WebDriverTestBase { 'queues[queue_order_worker_E]' => 'queue_order_worker_E', 'queues[queue_order_worker_F]' => 'queue_order_worker_F', ], 'Apply to selected items'); + $session->waitForText('Processing queues'); + $session->waitForElementRemoved('css', '[data-drupal-progress]'); $this->assertJsCondition('document.querySelector("[data-drupal-messages]")'); $session->statusMessageContains( 'Items were not processed. Try to release existing items or add new items to the queues.'