diff --git a/app/code/Magento/AsynchronousOperations/Model/BulkManagement.php b/app/code/Magento/AsynchronousOperations/Model/BulkManagement.php index faf01921e5737..983bac21f3c1b 100644 --- a/app/code/Magento/AsynchronousOperations/Model/BulkManagement.php +++ b/app/code/Magento/AsynchronousOperations/Model/BulkManagement.php @@ -3,25 +3,26 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\AsynchronousOperations\Model; -use Magento\Framework\App\ObjectManager; -use Magento\Framework\App\ResourceConnection; use Magento\AsynchronousOperations\Api\Data\BulkSummaryInterface; use Magento\AsynchronousOperations\Api\Data\BulkSummaryInterfaceFactory; use Magento\AsynchronousOperations\Api\Data\OperationInterface; -use Magento\Framework\MessageQueue\BulkPublisherInterface; -use Magento\Framework\EntityManager\EntityManager; -use Magento\Framework\EntityManager\MetadataPool; use Magento\AsynchronousOperations\Model\ResourceModel\Operation\CollectionFactory; use Magento\Authorization\Model\UserContextInterface; +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\Bulk\BulkManagementInterface; +use Magento\Framework\EntityManager\EntityManager; +use Magento\Framework\EntityManager\MetadataPool; +use Magento\Framework\MessageQueue\BulkPublisherInterface; +use Psr\Log\LoggerInterface; /** - * Class BulkManagement - * - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * Asynchronous Bulk Management */ -class BulkManagement implements \Magento\Framework\Bulk\BulkManagementInterface +class BulkManagement implements BulkManagementInterface { /** * @var EntityManager @@ -54,12 +55,12 @@ class BulkManagement implements \Magento\Framework\Bulk\BulkManagementInterface private $resourceConnection; /** - * @var \Magento\Authorization\Model\UserContextInterface + * @var UserContextInterface */ private $userContext; /** - * @var \Psr\Log\LoggerInterface + * @var LoggerInterface */ private $logger; @@ -71,7 +72,7 @@ class BulkManagement implements \Magento\Framework\Bulk\BulkManagementInterface * @param BulkPublisherInterface $publisher * @param MetadataPool $metadataPool * @param ResourceConnection $resourceConnection - * @param \Psr\Log\LoggerInterface $logger + * @param LoggerInterface $logger * @param UserContextInterface $userContext */ public function __construct( @@ -81,8 +82,8 @@ public function __construct( BulkPublisherInterface $publisher, MetadataPool $metadataPool, ResourceConnection $resourceConnection, - \Psr\Log\LoggerInterface $logger, - UserContextInterface $userContext = null + LoggerInterface $logger, + UserContextInterface $userContext ) { $this->entityManager = $entityManager; $this->bulkSummaryFactory= $bulkSummaryFactory; @@ -91,7 +92,7 @@ public function __construct( $this->resourceConnection = $resourceConnection; $this->publisher = $publisher; $this->logger = $logger; - $this->userContext = $userContext ?: ObjectManager::getInstance()->get(UserContextInterface::class); + $this->userContext = $userContext; } /** diff --git a/app/code/Magento/AsynchronousOperations/Model/MassConsumer.php b/app/code/Magento/AsynchronousOperations/Model/MassConsumer.php index e3ba8b0681971..e2f756a9e8fcd 100644 --- a/app/code/Magento/AsynchronousOperations/Model/MassConsumer.php +++ b/app/code/Magento/AsynchronousOperations/Model/MassConsumer.php @@ -3,17 +3,16 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - declare(strict_types=1); namespace Magento\AsynchronousOperations\Model; -use Magento\Framework\Registry; use Magento\Framework\MessageQueue\CallbackInvokerInterface; use Magento\Framework\MessageQueue\ConsumerConfigurationInterface; +use Magento\Framework\MessageQueue\ConsumerInterface; use Magento\Framework\MessageQueue\EnvelopeInterface; use Magento\Framework\MessageQueue\QueueInterface; -use Magento\Framework\MessageQueue\ConsumerInterface; +use Magento\Framework\Registry; /** * Class Consumer used to process OperationInterface messages. @@ -28,19 +27,19 @@ class MassConsumer implements ConsumerInterface private $invoker; /** - * @var \Magento\Framework\MessageQueue\ConsumerConfigurationInterface + * @var ConsumerConfigurationInterface */ private $configuration; /** - * @var Registry + * @var MassConsumerEnvelopeCallbackFactory */ - private $registry; + private $massConsumerEnvelopeCallback; /** - * @var MassConsumerEnvelopeCallbackFactory + * @var Registry */ - private $massConsumerEnvelopeCallback; + private $registry; /** * Initialize dependencies. @@ -54,13 +53,12 @@ public function __construct( CallbackInvokerInterface $invoker, ConsumerConfigurationInterface $configuration, MassConsumerEnvelopeCallbackFactory $massConsumerEnvelopeCallback, - Registry $registry = null + Registry $registry ) { $this->invoker = $invoker; $this->configuration = $configuration; $this->massConsumerEnvelopeCallback = $massConsumerEnvelopeCallback; - $this->registry = $registry ?? \Magento\Framework\App\ObjectManager::getInstance() - ->get(Registry::class); + $this->registry = $registry; } /** diff --git a/app/code/Magento/AsynchronousOperations/Model/MassSchedule.php b/app/code/Magento/AsynchronousOperations/Model/MassSchedule.php index 89d468159c6e9..6e36339b8bff1 100644 --- a/app/code/Magento/AsynchronousOperations/Model/MassSchedule.php +++ b/app/code/Magento/AsynchronousOperations/Model/MassSchedule.php @@ -3,24 +3,22 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - declare(strict_types=1); namespace Magento\AsynchronousOperations\Model; -use Magento\Framework\App\ObjectManager; -use Magento\Framework\DataObject\IdentityGeneratorInterface; -use Magento\Framework\Exception\LocalizedException; -use Magento\AsynchronousOperations\Api\Data\ItemStatusInterfaceFactory; use Magento\AsynchronousOperations\Api\Data\AsyncResponseInterface; use Magento\AsynchronousOperations\Api\Data\AsyncResponseInterfaceFactory; use Magento\AsynchronousOperations\Api\Data\ItemStatusInterface; -use Magento\Framework\Bulk\BulkManagementInterface; -use Magento\Framework\Exception\BulkException; -use Psr\Log\LoggerInterface; +use Magento\AsynchronousOperations\Api\Data\ItemStatusInterfaceFactory; use Magento\AsynchronousOperations\Model\ResourceModel\Operation\OperationRepository; use Magento\Authorization\Model\UserContextInterface; +use Magento\Framework\Bulk\BulkManagementInterface; +use Magento\Framework\DataObject\IdentityGeneratorInterface; use Magento\Framework\Encryption\Encryptor; +use Magento\Framework\Exception\BulkException; +use Magento\Framework\Exception\LocalizedException; +use Psr\Log\LoggerInterface; /** * Class MassSchedule used for adding multiple entities as Operations to Bulk Management with the status tracking @@ -30,7 +28,7 @@ class MassSchedule { /** - * @var \Magento\Framework\DataObject\IdentityGeneratorInterface + * @var IdentityGeneratorInterface */ private $identityService; @@ -45,7 +43,7 @@ class MassSchedule private $itemStatusInterfaceFactory; /** - * @var \Magento\Framework\Bulk\BulkManagementInterface + * @var BulkManagementInterface */ private $bulkManagement; @@ -60,7 +58,7 @@ class MassSchedule private $operationRepository; /** - * @var \Magento\Authorization\Model\UserContextInterface + * @var UserContextInterface */ private $userContext; @@ -79,7 +77,7 @@ class MassSchedule * @param LoggerInterface $logger * @param OperationRepository $operationRepository * @param UserContextInterface $userContext - * @param Encryptor|null $encryptor + * @param Encryptor $encryptor */ public function __construct( IdentityGeneratorInterface $identityService, @@ -88,8 +86,8 @@ public function __construct( BulkManagementInterface $bulkManagement, LoggerInterface $logger, OperationRepository $operationRepository, - UserContextInterface $userContext = null, - Encryptor $encryptor = null + UserContextInterface $userContext, + Encryptor $encryptor ) { $this->identityService = $identityService; $this->itemStatusInterfaceFactory = $itemStatusInterfaceFactory; @@ -97,8 +95,8 @@ public function __construct( $this->bulkManagement = $bulkManagement; $this->logger = $logger; $this->operationRepository = $operationRepository; - $this->userContext = $userContext ?: ObjectManager::getInstance()->get(UserContextInterface::class); - $this->encryptor = $encryptor ?: ObjectManager::getInstance()->get(Encryptor::class); + $this->userContext = $userContext; + $this->encryptor = $encryptor; } /**