| @@ 9-48 (lines=40) @@ | ||
| 6 | use Magento\Framework\ObjectManagerInterface; |
|
| 7 | use Magento\Framework\Registry; |
|
| 8 | ||
| 9 | class ProductFixtureRollback |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * @var Registry |
|
| 13 | */ |
|
| 14 | private $registry; |
|
| 15 | /** |
|
| 16 | * @var ProductRepositoryInterface |
|
| 17 | */ |
|
| 18 | private $productRepository; |
|
| 19 | ||
| 20 | public function __construct(Registry $registry, ProductRepositoryInterface $productRepository) |
|
| 21 | { |
|
| 22 | $this->registry = $registry; |
|
| 23 | $this->productRepository = $productRepository; |
|
| 24 | } |
|
| 25 | ||
| 26 | public static function create(ObjectManagerInterface $objectManager = null) |
|
| 27 | { |
|
| 28 | if ($objectManager === null) { |
|
| 29 | $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); |
|
| 30 | } |
|
| 31 | return new self( |
|
| 32 | $objectManager->get(Registry::class), |
|
| 33 | $objectManager->get(ProductRepositoryInterface::class) |
|
| 34 | ); |
|
| 35 | } |
|
| 36 | ||
| 37 | public function execute(ProductFixture ...$productFixtures) |
|
| 38 | { |
|
| 39 | $this->registry->unregister('isSecureArea'); |
|
| 40 | $this->registry->register('isSecureArea', true); |
|
| 41 | ||
| 42 | foreach ($productFixtures as $productFixture) { |
|
| 43 | $this->productRepository->deleteById($productFixture->getSku()); |
|
| 44 | } |
|
| 45 | ||
| 46 | $this->registry->unregister('isSecureArea'); |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||
| @@ 9-48 (lines=40) @@ | ||
| 6 | use Magento\Framework\ObjectManagerInterface; |
|
| 7 | use Magento\Framework\Registry; |
|
| 8 | ||
| 9 | class CustomerFixtureRollback |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * @var Registry |
|
| 13 | */ |
|
| 14 | private $registry; |
|
| 15 | /** |
|
| 16 | * @var CustomerRepositoryInterface |
|
| 17 | */ |
|
| 18 | private $customerRepository; |
|
| 19 | ||
| 20 | public function __construct(Registry $registry, CustomerRepositoryInterface $customerRepository) |
|
| 21 | { |
|
| 22 | $this->registry = $registry; |
|
| 23 | $this->customerRepository = $customerRepository; |
|
| 24 | } |
|
| 25 | ||
| 26 | public static function create(ObjectManagerInterface $objectManager = null) |
|
| 27 | { |
|
| 28 | if ($objectManager === null) { |
|
| 29 | $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); |
|
| 30 | } |
|
| 31 | return new self( |
|
| 32 | $objectManager->get(Registry::class), |
|
| 33 | $objectManager->get(CustomerRepositoryInterface::class) |
|
| 34 | ); |
|
| 35 | } |
|
| 36 | ||
| 37 | public function execute(CustomerFixture ...$customerFixtures) |
|
| 38 | { |
|
| 39 | $this->registry->unregister('isSecureArea'); |
|
| 40 | $this->registry->register('isSecureArea', true); |
|
| 41 | ||
| 42 | foreach ($customerFixtures as $customerFixture) { |
|
| 43 | $this->customerRepository->deleteById($customerFixture->getId()); |
|
| 44 | } |
|
| 45 | ||
| 46 | $this->registry->unregister('isSecureArea'); |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||
| @@ 9-48 (lines=40) @@ | ||
| 6 | use Magento\Framework\ObjectManagerInterface; |
|
| 7 | use Magento\Framework\Registry; |
|
| 8 | ||
| 9 | class CategoryFixtureRollback |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * @var Registry |
|
| 13 | */ |
|
| 14 | private $registry; |
|
| 15 | /** |
|
| 16 | * @var CategoryRepositoryInterface |
|
| 17 | */ |
|
| 18 | private $categoryRepository; |
|
| 19 | ||
| 20 | public function __construct(Registry $registry, CategoryRepositoryInterface $categoryRepository) |
|
| 21 | { |
|
| 22 | $this->registry = $registry; |
|
| 23 | $this->categoryRepository = $categoryRepository; |
|
| 24 | } |
|
| 25 | ||
| 26 | public static function create(ObjectManagerInterface $objectManager = null) |
|
| 27 | { |
|
| 28 | if ($objectManager === null) { |
|
| 29 | $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); |
|
| 30 | } |
|
| 31 | return new self( |
|
| 32 | $objectManager->get(Registry::class), |
|
| 33 | $objectManager->get(CategoryRepositoryInterface::class) |
|
| 34 | ); |
|
| 35 | } |
|
| 36 | ||
| 37 | public function execute(CategoryFixture ...$categoryFixtures) |
|
| 38 | { |
|
| 39 | $this->registry->unregister('isSecureArea'); |
|
| 40 | $this->registry->register('isSecureArea', true); |
|
| 41 | ||
| 42 | foreach ($categoryFixtures as $categoryFixture) { |
|
| 43 | $this->categoryRepository->deleteByIdentifier($categoryFixture->getId()); |
|
| 44 | } |
|
| 45 | ||
| 46 | $this->registry->unregister('isSecureArea'); |
|
| 47 | } |
|
| 48 | } |
|
| 49 | ||