From 5618a8c86efb22ac99b4c8fd66a7b54b36f0e075 Mon Sep 17 00:00:00 2001 From: Thomas Klein Date: Sun, 17 Mar 2024 15:44:03 +0100 Subject: [PATCH 01/31] Update FUNDING.yml --- .github/FUNDING.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index ec162a1c..4748360f 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,7 +1,7 @@ # These are supported funding model platforms #github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -patreon: thomas_klein # Replace with a single Patreon username +#patreon: # Replace with a single Patreon username #open_collective: # Replace with a single Open Collective username #ko_fi: # Replace with a single Ko-fi username #tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel @@ -9,4 +9,4 @@ patreon: thomas_klein # Replace with a single Patreon username #liberapay: # Replace with a single Liberapay username #issuehunt: # Replace with a single IssueHunt username #otechie: # Replace with a single Otechie username -custom: ['https://secure.payplug.com/p/jtN33xM'] +custom: ['https://www.helloasso.com/associations/opengento/formulaires/1'] From 86853596a2abab5400b5a35fb0fcaede82b925eb Mon Sep 17 00:00:00 2001 From: Thomas Klein Date: Mon, 17 Jun 2024 23:24:27 +0200 Subject: [PATCH 02/31] #138 - WIP Remove ActionInterface abstraction --- Api/ActionInterface.php | 1 + Block/Adminhtml/Action/Edit/BackButton.php | 36 ------ Block/Adminhtml/Action/Edit/ExecuteButton.php | 29 ----- Block/Adminhtml/Action/Edit/ResetButton.php | 24 ---- Block/Adminhtml/Customer/Edit/EraseButton.php | 2 +- .../Adminhtml/Customer/Edit/ExportButton.php | 2 +- Console/Command/EraseCommand.php | 41 +++---- Console/Command/ExportCommand.php | 37 ++---- Controller/AbstractAction.php | 30 ++--- Controller/AbstractGuest.php | 18 +-- Controller/AbstractPrivacy.php | 31 ++--- Controller/Adminhtml/AbstractAction.php | 10 +- Controller/Adminhtml/Action/Execute.php | 91 -------------- Controller/Adminhtml/Action/InlineEdit.php | 112 ----------------- Controller/Adminhtml/Action/MassDelete.php | 85 ------------- Controller/Adminhtml/Action/NewAction.php | 31 ----- Controller/Adminhtml/Guest/Erase.php | 24 ++-- Controller/Adminhtml/Guest/Export.php | 44 ++----- Controller/Adminhtml/Privacy/Erase.php | 28 ++--- Controller/Adminhtml/Privacy/Export.php | 44 ++----- Controller/Adminhtml/Privacy/MassErase.php | 34 +++--- Controller/Adminhtml/Privacy/MassExport.php | 62 ++++------ Controller/Guest/Download.php | 6 +- Controller/Guest/Erase.php | 20 +--- Controller/Guest/Export.php | 20 +--- Controller/Guest/UndoErase.php | 20 +--- Controller/Privacy/Download.php | 19 +-- Controller/Privacy/Erase.php | 8 +- Controller/Privacy/ErasePost.php | 31 +---- Controller/Privacy/Export.php | 20 +--- Controller/Privacy/Settings.php | 3 +- Controller/Privacy/UndoErase.php | 20 +--- Cron/EraseEntity.php | 2 +- Cron/EraseEntityScheduler.php | 2 +- Cron/ExportEntity.php | 2 +- Cron/ExportEntityExpired.php | 2 +- Model/Action/AbstractAction.php | 41 ------- Model/Action/ActionComposite.php | 112 ----------------- Model/Action/ActionFactory.php | 53 -------- Model/Action/ArgumentReader.php | 26 ---- Model/Action/Context.php | 44 ------- Model/Action/ContextBuilder.php | 84 ------------- Model/Action/Erase/ArgumentReader.php | 21 ---- Model/Action/Erase/CancelAction.php | 85 ------------- Model/Action/Erase/CreateAction.php | 66 ---------- Model/Action/Erase/ExecuteAction.php | 41 ------- Model/Action/Erase/NotifierActionBundle.php | 60 ---------- Model/Action/Export/ArgumentReader.php | 27 ----- Model/Action/Export/CreateAction.php | 66 ---------- Model/Action/Export/CreateOrExportAction.php | 70 ----------- Model/Action/Export/ExportAction.php | 56 --------- Model/Action/Export/NotifierActionBundle.php | 60 ---------- Model/Action/PerformedBy/AdminUser.php | 2 +- Model/Action/PerformedBy/Console.php | 2 +- Model/Action/PerformedBy/Customer.php | 2 +- Model/Action/PerformedBy/Guest.php | 2 +- Model/Action/PerformedBy/NotEmptyStrategy.php | 2 +- Model/Action/Result.php | 57 --------- Model/Action/ResultBuilder.php | 69 ----------- Model/ActionEntity.php | 1 + Model/ActionEntityBuilder.php | 2 +- Model/ActionEntityRepository.php | 2 +- Model/Archive/ArchiveManager.php | 2 +- Model/Archive/Zip.php | 3 +- Model/Config.php | 3 +- Model/Config/PrivacyMessage.php | 2 +- Model/Config/Source/ActionStates.php | 3 +- Model/Config/Source/EraseComponents.php | 3 +- Model/Config/Source/OrderPendingStates.php | 2 +- .../Source/VirtualArrayArgumentList.php | 3 +- .../Source/VirtualCustomerAttributes.php | 2 +- .../Config/Source/VirtualEntityAttributes.php | 3 +- .../CustomerAddressDataProcessor.php | 2 +- .../Processor/CustomerDataProcessor.php | 4 +- .../Processor/OrderDataProcessor.php | 2 +- .../Processor/QuoteDataProcessor.php | 2 +- .../Processor/SubscriberDataProcessor.php | 2 +- Model/Customer/CustomerChecker.php | 2 +- .../CustomerAddressDataProcessor.php | 2 +- .../Processor/CustomerDataProcessor.php | 2 +- .../Delete/Processor/OrderDataProcessor.php | 2 +- .../Delete/Processor/QuoteDataProcessor.php | 2 +- .../Processor/SubscriberDataProcessor.php | 2 +- Model/Customer/Erase/Notifier.php | 2 +- Model/Customer/Export/Notifier.php | 2 +- .../CustomerAddressDataProcessor.php | 2 +- .../Processor/CustomerDataProcessor.php | 2 +- .../Export/Processor/OrderDataProcessor.php | 2 +- .../Export/Processor/QuoteDataProcessor.php | 2 +- .../Processor/SubscriberDataProcessor.php | 2 +- Model/Customer/Notifier/MailSender.php | 2 +- Model/Customer/OrigDataRegistry.php | 2 +- .../SourceProvider/IdleFilterModifier.php | 2 +- Model/Entity/DataCollector.php | 2 +- Model/Entity/DataCollectorGeneric.php | 3 +- Model/Entity/Document.php | 2 +- Model/Entity/EntityCheckerFactory.php | 3 +- Model/Entity/EntityIterator.php | 2 +- Model/Entity/EntityTypeList.php | 2 +- Model/Entity/EntityTypeResolver.php | 2 +- .../EntityValue/CustomAttributesProcessor.php | 3 +- .../EntityValue/ExtensibleDataProcessor.php | 3 +- .../Entity/EntityValue/StrategyProcessor.php | 2 +- Model/Entity/Metadata.php | 3 +- .../Entity/SourceProvider/FilterModifier.php | 2 +- .../SourceProvider/ModifierComposite.php | 2 +- .../Entity/SourceProvider/ModifierFactory.php | 2 +- .../NotErasedFilterModifier.php | 3 +- Model/Entity/SourceProviderFactory.php | 3 +- Model/Erase/EraseEntityScheduler.php | 2 +- Model/Erase/EraseSalesInformation.php | 2 +- Model/Erase/SecureEraseEntityManagement.php | 2 +- Model/EraseEntityChecker.php | 2 +- Model/EraseEntityManagement.php | 2 +- Model/EraseEntityRepository.php | 2 +- Model/Export/ExportEntityData.php | 2 +- Model/Export/ExportToFile.php | 4 +- Model/ExportEntityChecker.php | 2 +- Model/ExportEntityManagement.php | 2 +- Model/ExportEntityRepository.php | 2 +- Model/Newsletter/Subscriber.php | 4 +- Model/Notifier/AbstractMailSender.php | 1 + .../Processor/OrderDataProcessor.php | 2 +- .../Processor/QuoteDataProcessor.php | 2 +- .../Processor/SubscriberDataProcessor.php | 2 +- .../Delete/Processor/OrderDataProcessor.php | 2 +- .../Delete/Processor/QuoteDataProcessor.php | 2 +- .../Processor/SubscriberDataProcessor.php | 2 +- Model/Order/Erase/Notifier.php | 2 +- Model/Order/Export/Notifier.php | 2 +- .../Export/Processor/OrderDataProcessor.php | 2 +- .../Export/Processor/QuoteDataProcessor.php | 2 +- .../Processor/SubscriberDataProcessor.php | 2 +- Model/Order/Notifier/MailSender.php | 4 +- Model/Order/OrderChecker.php | 3 +- .../SourceProvider/GuestFilterModifier.php | 2 +- .../ResourceModel/ActionEntity/Validator.php | 2 +- .../ActionEntity/Validator/StateValidator.php | 3 +- Model/ResourceModel/EraseEntity.php | 1 + Model/ResourceModel/ExportEntity.php | 1 + Observer/DeleteExport.php | 2 +- Observer/InvalidateExport.php | 2 +- Service/Anonymize/Anonymizer/AlphaLower.php | 2 +- Service/Anonymize/Anonymizer/AlphaNum.php | 2 +- Service/Anonymize/Anonymizer/AlphaUpper.php | 2 +- Service/Anonymize/Anonymizer/Anonymous.php | 2 +- Service/Anonymize/Anonymizer/Date.php | 2 +- Service/Anonymize/Anonymizer/Email.php | 2 +- Service/Anonymize/Anonymizer/Entity.php | 3 +- Service/Anonymize/Anonymizer/NullValue.php | 2 +- Service/Anonymize/Anonymizer/Number.php | 3 +- Service/Anonymize/Anonymizer/Phone.php | 2 +- Service/Anonymize/Anonymizer/Street.php | 3 +- Service/Anonymize/AnonymizerFactory.php | 3 +- Service/Anonymize/Metadata.php | 3 +- .../Entity/EntityValue/Processor.php | 3 +- .../Entity/EntityValue/SmartProcessor.php | 3 +- Service/Erase/Metadata.php | 3 +- Service/Erase/Processor/EraseProcessor.php | 3 +- Service/Erase/ProcessorFactory.php | 3 +- .../ProcessorResolver/ProcessorResolver.php | 3 +- .../ProcessorResolverStrategy.php | 2 +- Service/Erase/ProcessorResolverFactory.php | 3 +- .../Export/Processor/CompositeProcessor.php | 3 +- .../Entity/EntityValue/DataProcessor.php | 3 +- .../Entity/EntityValue/EntityProcessor.php | 3 +- Service/Export/ProcessorFactory.php | 3 +- Service/Export/Renderer/CsvRenderer.php | 4 +- Service/Export/Renderer/HtmlRenderer.php | 3 +- .../Renderer/HtmlRenderer/LayoutInitiator.php | 3 +- .../Renderer/HtmlRenderer/View/Renderer.php | 4 +- Service/Export/Renderer/JsonRenderer.php | 2 +- Service/Export/Renderer/PdfRenderer.php | 2 +- Service/Export/Renderer/XmlRenderer.php | 2 +- Service/Export/RendererFactory.php | 3 +- ViewModel/Cookie/NoticeDataProvider.php | 2 +- .../Customer/Guest/EraseDataProvider.php | 2 +- .../Customer/Guest/ExportDataProvider.php | 2 +- .../Privacy/EraseCustomerDataProvider.php | 2 +- .../Customer/Privacy/EraseDataProvider.php | 2 +- .../Privacy/ExportCustomerDataProvider.php | 2 +- .../Customer/Privacy/ExportDataProvider.php | 2 +- .../Customer/Privacy/SettingsDataProvider.php | 2 +- etc/acl.xml | 6 +- etc/adminhtml/di.xml | 40 ------- etc/di.xml | 2 - view/adminhtml/layout/gdpr_action_new.xml | 15 --- .../ui_component/gdpr_action_form.xml | 113 ------------------ .../ui_component/gdpr_action_listing.xml | 54 --------- 189 files changed, 354 insertions(+), 2205 deletions(-) delete mode 100644 Block/Adminhtml/Action/Edit/BackButton.php delete mode 100644 Block/Adminhtml/Action/Edit/ExecuteButton.php delete mode 100644 Block/Adminhtml/Action/Edit/ResetButton.php delete mode 100644 Controller/Adminhtml/Action/Execute.php delete mode 100644 Controller/Adminhtml/Action/InlineEdit.php delete mode 100644 Controller/Adminhtml/Action/MassDelete.php delete mode 100644 Controller/Adminhtml/Action/NewAction.php delete mode 100644 Model/Action/AbstractAction.php delete mode 100644 Model/Action/ActionComposite.php delete mode 100644 Model/Action/ActionFactory.php delete mode 100644 Model/Action/ArgumentReader.php delete mode 100644 Model/Action/Context.php delete mode 100644 Model/Action/ContextBuilder.php delete mode 100644 Model/Action/Erase/ArgumentReader.php delete mode 100644 Model/Action/Erase/CancelAction.php delete mode 100644 Model/Action/Erase/CreateAction.php delete mode 100644 Model/Action/Erase/ExecuteAction.php delete mode 100644 Model/Action/Erase/NotifierActionBundle.php delete mode 100644 Model/Action/Export/ArgumentReader.php delete mode 100644 Model/Action/Export/CreateAction.php delete mode 100644 Model/Action/Export/CreateOrExportAction.php delete mode 100644 Model/Action/Export/ExportAction.php delete mode 100644 Model/Action/Export/NotifierActionBundle.php delete mode 100644 Model/Action/Result.php delete mode 100644 Model/Action/ResultBuilder.php delete mode 100644 view/adminhtml/layout/gdpr_action_new.xml delete mode 100644 view/adminhtml/ui_component/gdpr_action_form.xml diff --git a/Api/ActionInterface.php b/Api/ActionInterface.php index 9b53a483..e79986cc 100644 --- a/Api/ActionInterface.php +++ b/Api/ActionInterface.php @@ -13,6 +13,7 @@ /** * @api + * @todo remove */ interface ActionInterface { diff --git a/Block/Adminhtml/Action/Edit/BackButton.php b/Block/Adminhtml/Action/Edit/BackButton.php deleted file mode 100644 index 4028505a..00000000 --- a/Block/Adminhtml/Action/Edit/BackButton.php +++ /dev/null @@ -1,36 +0,0 @@ -urlBuilder = $urlBuilder; - } - - public function getButtonData(): array - { - return [ - 'label' => new Phrase('Back'), - 'on_click' => 'location.href = "' . $this->urlBuilder->getUrl('*/*/') . '";', - 'class' => 'back', - 'sort_order' => 10, - ]; - } -} diff --git a/Block/Adminhtml/Action/Edit/ExecuteButton.php b/Block/Adminhtml/Action/Edit/ExecuteButton.php deleted file mode 100644 index b8a7c52e..00000000 --- a/Block/Adminhtml/Action/Edit/ExecuteButton.php +++ /dev/null @@ -1,29 +0,0 @@ - new Phrase('Execute Action'), - 'class' => 'primary', - 'data_attribute' => [ - 'mage-init' => ['button' => ['event' => 'save']], - 'form-role' => 'save', - ], - 'on_click' => 'location.reload();', - 'sort_order' => 30, - 'aclResource' => 'Opengento_Gdpr::gdpr_actions_execute', - ]; - } -} diff --git a/Block/Adminhtml/Action/Edit/ResetButton.php b/Block/Adminhtml/Action/Edit/ResetButton.php deleted file mode 100644 index 60a13db3..00000000 --- a/Block/Adminhtml/Action/Edit/ResetButton.php +++ /dev/null @@ -1,24 +0,0 @@ - new Phrase('Reset'), - 'class' => 'reset', - 'on_click' => 'location.reload();', - 'sort_order' => 20, - ]; - } -} diff --git a/Block/Adminhtml/Customer/Edit/EraseButton.php b/Block/Adminhtml/Customer/Edit/EraseButton.php index f29dc37c..fb8e6362 100644 --- a/Block/Adminhtml/Customer/Edit/EraseButton.php +++ b/Block/Adminhtml/Customer/Edit/EraseButton.php @@ -15,7 +15,7 @@ use Opengento\Gdpr\Api\EraseEntityCheckerInterface; use Opengento\Gdpr\Model\Config; -final class EraseButton extends GenericButton implements ButtonProviderInterface +class EraseButton extends GenericButton implements ButtonProviderInterface { private EraseEntityCheckerInterface $eraseCustomerChecker; diff --git a/Block/Adminhtml/Customer/Edit/ExportButton.php b/Block/Adminhtml/Customer/Edit/ExportButton.php index 80218807..ca16fad4 100644 --- a/Block/Adminhtml/Customer/Edit/ExportButton.php +++ b/Block/Adminhtml/Customer/Edit/ExportButton.php @@ -14,7 +14,7 @@ use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; use Opengento\Gdpr\Model\Config; -final class ExportButton extends GenericButton implements ButtonProviderInterface +class ExportButton extends GenericButton implements ButtonProviderInterface { private Config $config; diff --git a/Console/Command/EraseCommand.php b/Console/Command/EraseCommand.php index 0d6a8536..46557968 100644 --- a/Console/Command/EraseCommand.php +++ b/Console/Command/EraseCommand.php @@ -7,14 +7,15 @@ namespace Opengento\Gdpr\Console\Command; +use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\App\Area; use Magento\Framework\App\State; use Magento\Framework\Console\Cli; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Registry; -use Opengento\Gdpr\Api\ActionInterface; -use Opengento\Gdpr\Model\Action\ArgumentReader; -use Opengento\Gdpr\Model\Action\ContextBuilder; +use Opengento\Gdpr\Api\Data\EraseEntityInterface; +use Opengento\Gdpr\Api\EraseEntityManagementInterface; +use Opengento\Gdpr\Api\EraseEntityRepositoryInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -25,25 +26,14 @@ class EraseCommand extends Command private const INPUT_ARGUMENT_ENTITY_ID = 'entity_id'; private const INPUT_ARGUMENT_ENTITY_TYPE = 'entity_type'; - private State $appState; - - private Registry $registry; - - private ActionInterface $action; - - private ContextBuilder $actionContextBuilder; - public function __construct( - State $appState, - Registry $registry, - ActionInterface $action, - ContextBuilder $actionContextBuilder, + private State $appState, + private Registry $registry, + private EraseEntityManagementInterface $eraseManagement, + private EraseEntityRepositoryInterface $eraseEntityRepository, + private SearchCriteriaBuilder $searchCriteriaBuilder, string $name = 'gdpr:entity:erase' ) { - $this->appState = $appState; - $this->registry = $registry; - $this->action = $action; - $this->actionContextBuilder = $actionContextBuilder; parent::__construct($name); } @@ -82,15 +72,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int $entityType = $input->getArgument(self::INPUT_ARGUMENT_ENTITY_TYPE); try { - foreach ($entityIds as $entityId) { - $this->action->execute( - $this->actionContextBuilder->setParameters( - [ArgumentReader::ENTITY_ID => $entityId, ArgumentReader::ENTITY_TYPE => $entityType] - )->create() - ); + $this->searchCriteriaBuilder->addFilter(EraseEntityInterface::ENTITY_ID, $entityIds, 'in'); + $this->searchCriteriaBuilder->addFilter(EraseEntityInterface::ENTITY_TYPE, $entityType); + $eraseEntityList = $this->eraseEntityRepository->getList($this->searchCriteriaBuilder->create()); + foreach ($eraseEntityList->getItems() as $eraseEntity) { + $this->eraseManagement->process($eraseEntity); $output->writeln( - 'Entity\'s (' . $entityType . ') with ID "' . $entityId . '" has been erased.' + 'Entity\'s (' . $entityType . ') with ID "' . $eraseEntity->getEntityId() . '" has been erased.' ); } } catch (LocalizedException $e) { diff --git a/Console/Command/ExportCommand.php b/Console/Command/ExportCommand.php index 9af11c0a..77eed265 100644 --- a/Console/Command/ExportCommand.php +++ b/Console/Command/ExportCommand.php @@ -8,15 +8,14 @@ namespace Opengento\Gdpr\Console\Command; use Exception; +use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\App\Area; use Magento\Framework\App\State; use Magento\Framework\Console\Cli; use Magento\Framework\Exception\LocalizedException; -use Opengento\Gdpr\Api\ActionInterface; use Opengento\Gdpr\Api\Data\ExportEntityInterface; -use Opengento\Gdpr\Model\Action\ArgumentReader; -use Opengento\Gdpr\Model\Action\ContextBuilder; -use Opengento\Gdpr\Model\Action\Export\ArgumentReader as ExportArgumentReader; +use Opengento\Gdpr\Api\ExportEntityManagementInterface; +use Opengento\Gdpr\Api\ExportEntityRepositoryInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -29,21 +28,13 @@ class ExportCommand extends Command private const INPUT_ARGUMENT_ENTITY_TYPE = 'entity_type'; private const INPUT_OPTION_FILENAME = 'filename'; - private State $appState; - - private ActionInterface $action; - - private ContextBuilder $actionContextBuilder; - public function __construct( - State $appState, - ActionInterface $action, - ContextBuilder $actionContextBuilder, + private State $appState, + private ExportEntityManagementInterface $exportEntityManagement, + private ExportEntityRepositoryInterface $exportEntityRepository, + private SearchCriteriaBuilder $searchCriteriaBuilder, string $name = 'gdpr:entity:export' ) { - $this->appState = $appState; - $this->action = $action; - $this->actionContextBuilder = $actionContextBuilder; parent::__construct($name); } @@ -87,15 +78,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $fileName = $input->getOption(self::INPUT_OPTION_FILENAME); try { - foreach ($entityIds as $entityId) { - $this->actionContextBuilder->setParameters([ - ArgumentReader::ENTITY_ID => $entityId, - ArgumentReader::ENTITY_TYPE => $entityType, - ExportArgumentReader::EXPORT_FILE_NAME => $fileName . '_' . $entityId - ]); - $result = $this->action->execute($this->actionContextBuilder->create())->getResult(); - /** @var ExportEntityInterface $exportEntity */ - $exportEntity = $result[ExportArgumentReader::EXPORT_ENTITY]; + $this->searchCriteriaBuilder->addFilter(ExportEntityInterface::ENTITY_ID, $entityIds, 'in'); + $this->searchCriteriaBuilder->addFilter(ExportEntityInterface::ENTITY_TYPE, $entityType); + $exportEntityList = $this->exportEntityRepository->getList($this->searchCriteriaBuilder->create()); + foreach ($exportEntityList->getItems() as $exportEntity) { + $this->exportEntityManagement->export($exportEntity); $output->writeln( 'Entity\'s related data have been exported to: ' . $exportEntity->getFilePath() . '.' diff --git a/Controller/AbstractAction.php b/Controller/AbstractAction.php index fc279b2f..0d4db48b 100644 --- a/Controller/AbstractAction.php +++ b/Controller/AbstractAction.php @@ -19,27 +19,14 @@ abstract class AbstractAction implements ActionInterface { - protected RequestInterface $request; - - protected ResultFactory $resultFactory; - - protected ManagerInterface $messageManager; - - protected Config $config; - public function __construct( - RequestInterface $request, - ResultFactory $resultFactory, - ManagerInterface $messageManager, - Config $config - ) { - $this->request = $request; - $this->resultFactory = $resultFactory; - $this->messageManager = $messageManager; - $this->config = $config; - } + protected RequestInterface $request, + protected ResultFactory $resultFactory, + protected ManagerInterface $messageManager, + protected Config $config + ) {} - public function execute() + public function execute(): ResultInterface|ResponseInterface { return $this->isAllowed() ? $this->executeAction() : $this->forwardNoRoute(); } @@ -47,17 +34,16 @@ public function execute() /** * Execute action based on request and return result * - * @return ResultInterface|ResponseInterface * @throws NotFoundException */ - abstract protected function executeAction(); + abstract protected function executeAction(): ResultInterface|ResponseInterface; protected function isAllowed(): bool { return $this->config->isModuleEnabled(); } - protected function forwardNoRoute(): ResultInterface + final protected function forwardNoRoute(): ResultInterface { /** @var Forward $resultForward */ $resultForward = $this->resultFactory->create(ResultFactory::TYPE_FORWARD); diff --git a/Controller/AbstractGuest.php b/Controller/AbstractGuest.php index fd2a1e51..83c036a5 100644 --- a/Controller/AbstractGuest.php +++ b/Controller/AbstractGuest.php @@ -8,6 +8,7 @@ namespace Opengento\Gdpr\Controller; use Magento\Framework\App\RequestInterface; +use Magento\Framework\App\ResponseInterface; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Message\ManagerInterface; @@ -18,34 +19,25 @@ abstract class AbstractGuest extends AbstractAction { - /** - * @var OrderLoaderInterface - */ - protected OrderLoaderInterface $orderLoader; - - protected Registry $registry; - public function __construct( RequestInterface $request, ResultFactory $resultFactory, ManagerInterface $messageManager, Config $config, - OrderLoaderInterface $orderLoader, - Registry $registry + protected OrderLoaderInterface $orderLoader, + protected Registry $registry ) { - $this->orderLoader = $orderLoader; - $this->registry = $registry; parent::__construct($request, $resultFactory, $messageManager, $config); } - public function execute() + final public function execute(): ResultInterface|ResponseInterface { $result = $this->orderLoader->load($this->request); return $result instanceof ResultInterface ? $result : parent::execute(); } - protected function currentOrder(): OrderInterface + final protected function currentOrder(): OrderInterface { return $this->registry->registry('current_order'); } diff --git a/Controller/AbstractPrivacy.php b/Controller/AbstractPrivacy.php index fced185e..646a5588 100644 --- a/Controller/AbstractPrivacy.php +++ b/Controller/AbstractPrivacy.php @@ -10,43 +10,38 @@ use Magento\Customer\Model\Session; use Magento\Framework\App\RequestInterface; use Magento\Framework\App\Response\Http; +use Magento\Framework\App\ResponseInterface; use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Exception\NotFoundException; +use Magento\Framework\Exception\SessionException; use Magento\Framework\Message\ManagerInterface; use Opengento\Gdpr\Model\Config; /** * This class is introduced to handle customer authentication verification. * We can't use the default AccountInterface or AccountPlugin - * as they requires the action to inherit the default Magento AbstractAction - * which is deprecated and which suffer of performance issues + * as they require the action to inherit the default Magento AbstractAction + * which is deprecated and which suffer performance issues */ abstract class AbstractPrivacy extends AbstractAction { - /** - * @var Session - */ - protected Session $customerSession; - - /** - * @var Http - */ - private Http $response; - public function __construct( RequestInterface $request, ResultFactory $resultFactory, ManagerInterface $messageManager, Config $config, - Session $customerSession, - Http $response + protected Session $customerSession, + protected Http $response ) { - $this->customerSession = $customerSession; - $this->response = $response; parent::__construct($request, $resultFactory, $messageManager, $config); } - public function execute() + /** + * @throws NotFoundException + * @throws SessionException + */ + final public function execute(): ResultInterface|ResponseInterface { return $this->customerSession->authenticate() ? $this->defaultAction() : $this->response; } @@ -54,7 +49,7 @@ public function execute() /** * @throws NotFoundException */ - private function defaultAction() + private function defaultAction(): ResultInterface|ResponseInterface { return $this->isAllowed() ? $this->executeAction() : $this->forwardNoRoute(); } diff --git a/Controller/Adminhtml/AbstractAction.php b/Controller/Adminhtml/AbstractAction.php index 3da9b942..996b6656 100644 --- a/Controller/Adminhtml/AbstractAction.php +++ b/Controller/Adminhtml/AbstractAction.php @@ -28,13 +28,9 @@ public function __construct( parent::__construct($context); } - public function execute() + public function execute(): ResultInterface|ResponseInterface { - if ($this->isAllowed()) { - return $this->executeAction(); - } - - return $this->forwardNoRoute(); + return $this->isAllowed() ? $this->executeAction() : $this->forwardNoRoute(); } /** @@ -43,7 +39,7 @@ public function execute() * @return ResultInterface|ResponseInterface * @throws NotFoundException */ - abstract protected function executeAction(); + abstract protected function executeAction(): ResultInterface|ResponseInterface; protected function isAllowed(): bool { diff --git a/Controller/Adminhtml/Action/Execute.php b/Controller/Adminhtml/Action/Execute.php deleted file mode 100644 index 3ccc56d7..00000000 --- a/Controller/Adminhtml/Action/Execute.php +++ /dev/null @@ -1,91 +0,0 @@ -actionFactory = $actionFactory; - $this->contextBuilder = $contextBuilder; - $this->actionStates = $actionStates; - parent::__construct($context); - } - - public function execute(): Redirect - { - /** @var Redirect $resultRedirect */ - $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); - $resultRedirect->setPath('*/*/new'); - - try { - $result = $this->proceed($this->getRequest()->getParam('type')); - $resultRedirect->setPath('*/*/'); - $this->messageManager->addSuccessMessage( - new Phrase('The action state is now: %1.', [$this->actionStates->getOptionText($result->getState())]) - ); - } catch (AbstractAggregateException $e) { - $this->messageManager->addErrorMessage($e->getMessage()); - foreach ($e->getErrors() as $exception) { - $this->messageManager->addErrorMessage($exception->getMessage()); - } - } catch (LocalizedException $e) { - $this->messageManager->addErrorMessage($e->getMessage()); - } catch (Exception $e) { - $this->messageManager->addExceptionMessage($e, new Phrase('An error occurred on the server.')); - } - - return $resultRedirect; - } - - /** - * @param string $actionType - * @return ActionResultInterface - * @throws LocalizedException - */ - private function proceed(string $actionType): ActionResultInterface - { - $parameters = []; - /** @var array $param */ - foreach ((array) $this->getRequest()->getParam('parameters', []) as $param) { - $parameters[$param['name']] = $param['value']; - } - $this->contextBuilder->setParameters($parameters); - - return $this->actionFactory->get($actionType)->execute($this->contextBuilder->create()); - } -} diff --git a/Controller/Adminhtml/Action/InlineEdit.php b/Controller/Adminhtml/Action/InlineEdit.php deleted file mode 100644 index 3d0dd214..00000000 --- a/Controller/Adminhtml/Action/InlineEdit.php +++ /dev/null @@ -1,112 +0,0 @@ -actionRepository = $actionRepository; - $this->hydratorPool = $hydratorPool; - $this->logger = $logger; - $this->allowedAttributes = $allowedAttributes; - parent::__construct($context); - } - - public function execute() - { - /** @var Json $resultJson */ - $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON); - $error = false; - $messages = []; - $postItems = $this->getRequest()->getParam('items', []); - - if (!$postItems || !is_array($postItems) || !$this->getRequest()->getParam('isAjax')) { - return $resultJson->setData(['messages' => [new Phrase('Please correct the data sent.')], 'error' => true]); - } - - foreach ($postItems as $actionId => $item) { - try { - $this->edit($actionId, $item); - } catch (LocalizedException $e) { - $messages[] = new Phrase('Action with ID "%1": %2', [$actionId, $e->getMessage()]); - $error = true; - } catch (Exception $e) { - $this->logger->error($e->getMessage(), $e->getTrace()); - $messages[] = new Phrase( - 'Action with ID "%1": %2', - [$actionId, new Phrase('An error occurred on the server.')] - ); - $error = true; - } - } - - return $resultJson->setData(compact('messages', 'error')); - } - - /** - * @param int $actionId - * @param array $data - * @return void - * @throws LocalizedException - * @todo improve extensibility: these settings should be global and be used to disable field in the ui grid - */ - private function edit(int $actionId, array $data): void - { - $hydrator = $this->hydratorPool->getHydrator(ActionEntityInterface::class); - $actionEntity = $this->actionRepository->getById($actionId); - - $allowedAttributes = array_merge( - $this->allowedAttributes['*'] ?? [], - $this->allowedAttributes[$actionEntity->getState()] ?? [] - ); - - /** @var ActionEntityInterface $actionEntity */ - $actionEntity = $hydrator->hydrate( - $actionEntity, - array_intersect_key($data, array_fill_keys($allowedAttributes, null)) - ); - - $this->actionRepository->save($actionEntity); - } -} diff --git a/Controller/Adminhtml/Action/MassDelete.php b/Controller/Adminhtml/Action/MassDelete.php deleted file mode 100644 index e47546f7..00000000 --- a/Controller/Adminhtml/Action/MassDelete.php +++ /dev/null @@ -1,85 +0,0 @@ -filter = $filter; - $this->collectionFactory = $collectionFactory; - $this->actionRepository = $actionRepository; - parent::__construct($context); - } - - public function execute(): Redirect - { - /** @var Redirect $resultRedirect */ - $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); - $resultRedirect->setPath('*/*/'); - - try { - $this->massAction($this->filter->getCollection($this->collectionFactory->create())); - } catch (LocalizedException $e) { - $this->messageManager->addErrorMessage($e->getMessage()); - } catch (Exception $e) { - $this->messageManager->addExceptionMessage($e, $e->getMessage()); - } - - return $resultRedirect; - } - - /** - * @param AbstractDb $collection - * @return void - * @throws CouldNotDeleteException - * @throws NoSuchEntityException - */ - private function massAction(AbstractDb $collection): void - { - $count = $collection->count(); - - /** @var ActionInterface $actionEntity */ - foreach ($collection->getItems() as $actionEntity) { - $this->actionRepository->delete($actionEntity); - } - - $this->messageManager->addSuccessMessage(new Phrase('A total of %1 record(s) have been deleted.', [$count])); - } -} diff --git a/Controller/Adminhtml/Action/NewAction.php b/Controller/Adminhtml/Action/NewAction.php deleted file mode 100644 index f29ca439..00000000 --- a/Controller/Adminhtml/Action/NewAction.php +++ /dev/null @@ -1,31 +0,0 @@ -resultFactory->create(ResultFactory::TYPE_PAGE); - $resultPage->setActiveMenu('Opengento_Gdpr::gdpr_actions'); - $resultPage->getConfig()->getTitle()->set(new Phrase('Execute New Action')); - $resultPage->addBreadcrumb(new Phrase('GDPR'), new Phrase('GDPR')); - $resultPage->addBreadcrumb(new Phrase('Execute New Action'), new Phrase('Execute New Action')); - - return $resultPage; - } -} diff --git a/Controller/Adminhtml/Guest/Erase.php b/Controller/Adminhtml/Guest/Erase.php index 8c08cc7e..b4d7bd29 100644 --- a/Controller/Adminhtml/Guest/Erase.php +++ b/Controller/Adminhtml/Guest/Erase.php @@ -14,40 +14,30 @@ use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Phrase; -use Opengento\Gdpr\Api\ActionInterface; +use Opengento\Gdpr\Api\EraseEntityManagementInterface; +use Opengento\Gdpr\Api\EraseEntityRepositoryInterface; use Opengento\Gdpr\Controller\Adminhtml\AbstractAction; -use Opengento\Gdpr\Model\Action\ArgumentReader; -use Opengento\Gdpr\Model\Action\ContextBuilder; use Opengento\Gdpr\Model\Config; class Erase extends AbstractAction implements HttpPostActionInterface { public const ADMIN_RESOURCE = 'Opengento_Gdpr::order_erase'; - private ActionInterface $action; - - private ContextBuilder $actionContextBuilder; - public function __construct( Context $context, Config $config, - ActionInterface $action, - ContextBuilder $actionContextBuilder + private EraseEntityManagementInterface $eraseEntityManagement, + private EraseEntityRepositoryInterface $eraseEntityRepository, ) { - $this->action = $action; - $this->actionContextBuilder = $actionContextBuilder; parent::__construct($context, $config); } protected function executeAction() { - $this->actionContextBuilder->setParameters([ - ArgumentReader::ENTITY_ID => (int) $this->getRequest()->getParam('id'), - ArgumentReader::ENTITY_TYPE => 'order' - ]); - try { - $this->action->execute($this->actionContextBuilder->create()); + $this->eraseEntityManagement->process( + $this->eraseEntityRepository->getByEntity((int)$this->getRequest()->getParam('id'), 'order') + ); $this->messageManager->addSuccessMessage(new Phrase('You erased the order.')); } catch (LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); diff --git a/Controller/Adminhtml/Guest/Export.php b/Controller/Adminhtml/Guest/Export.php index 417ce35f..fc57885f 100644 --- a/Controller/Adminhtml/Guest/Export.php +++ b/Controller/Adminhtml/Guest/Export.php @@ -12,59 +12,39 @@ use Magento\Backend\Model\View\Result\Redirect; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\Response\Http\FileFactory; +use Magento\Framework\App\ResponseInterface; use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Phrase; -use Opengento\Gdpr\Api\ActionInterface; -use Opengento\Gdpr\Api\Data\ExportEntityInterface; +use Opengento\Gdpr\Api\ExportEntityManagementInterface; +use Opengento\Gdpr\Api\ExportEntityRepositoryInterface; use Opengento\Gdpr\Controller\Adminhtml\AbstractAction; -use Opengento\Gdpr\Model\Action\ArgumentReader; -use Opengento\Gdpr\Model\Action\ContextBuilder; -use Opengento\Gdpr\Model\Action\Export\ArgumentReader as ExportArgumentReader; use Opengento\Gdpr\Model\Config; class Export extends AbstractAction { public const ADMIN_RESOURCE = 'Opengento_Gdpr::order_export'; - /** - * @var FileFactory - */ - private FileFactory $fileFactory; - - private ActionInterface $action; - - private ContextBuilder $actionContextBuilder; - public function __construct( Context $context, Config $config, - FileFactory $fileFactory, - ActionInterface $action, - ContextBuilder $actionContextBuilder + private ExportEntityManagementInterface $exportEntityManagement, + private ExportEntityRepositoryInterface $exportEntityRepository, + private FileFactory $fileFactory ) { - $this->fileFactory = $fileFactory; - $this->action = $action; - $this->actionContextBuilder = $actionContextBuilder; parent::__construct($context, $config); } - protected function executeAction() + protected function executeAction(): ResultInterface|ResponseInterface { - $entityId = (int) $this->getRequest()->getParam('id'); - - $this->actionContextBuilder->setParameters([ - ArgumentReader::ENTITY_ID => $entityId, - ArgumentReader::ENTITY_TYPE => 'order' - ]); - try { - $result = $this->action->execute($this->actionContextBuilder->create())->getResult(); - /** @var ExportEntityInterface $exportEntity */ - $exportEntity = $result[ExportArgumentReader::EXPORT_ENTITY]; + $exportEntity = $this->exportEntityManagement->export( + $this->exportEntityRepository->getByEntity((int)$this->getRequest()->getParam('id'), 'order') + ); return $this->fileFactory->create( - 'guest_privacy_data_' . $entityId . '.zip', + 'guest_privacy_data_' . $exportEntity->getEntityId() . '.zip', [ 'type' => 'filename', 'value' => $exportEntity->getFilePath(), diff --git a/Controller/Adminhtml/Privacy/Erase.php b/Controller/Adminhtml/Privacy/Erase.php index 3b9e6bad..cc578b13 100644 --- a/Controller/Adminhtml/Privacy/Erase.php +++ b/Controller/Adminhtml/Privacy/Erase.php @@ -11,43 +11,35 @@ use Magento\Backend\App\Action\Context; use Magento\Backend\Model\View\Result\Redirect; use Magento\Framework\App\Action\HttpPostActionInterface; +use Magento\Framework\App\ResponseInterface; use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Phrase; -use Opengento\Gdpr\Api\ActionInterface; +use Opengento\Gdpr\Api\EraseEntityManagementInterface; +use Opengento\Gdpr\Api\EraseEntityRepositoryInterface; use Opengento\Gdpr\Controller\Adminhtml\AbstractAction; -use Opengento\Gdpr\Model\Action\ArgumentReader; -use Opengento\Gdpr\Model\Action\ContextBuilder; use Opengento\Gdpr\Model\Config; class Erase extends AbstractAction implements HttpPostActionInterface { public const ADMIN_RESOURCE = 'Opengento_Gdpr::customer_erase'; - private ActionInterface $action; - - private ContextBuilder $actionContextBuilder; - public function __construct( Context $context, Config $config, - ActionInterface $action, - ContextBuilder $actionContextBuilder + private EraseEntityManagementInterface $eraseEntityManagement, + private EraseEntityRepositoryInterface $eraseEntityRepository ) { - $this->action = $action; - $this->actionContextBuilder = $actionContextBuilder; parent::__construct($context, $config); } - protected function executeAction() + protected function executeAction(): ResultInterface|ResponseInterface { - $this->actionContextBuilder->setParameters([ - ArgumentReader::ENTITY_ID => (int) $this->getRequest()->getParam('id'), - ArgumentReader::ENTITY_TYPE => 'customer' - ]); - try { - $this->action->execute($this->actionContextBuilder->create()); + $this->eraseEntityManagement->process( + $this->eraseEntityRepository->getByEntity((int)$this->getRequest()->getParam('id'), 'customer') + ); $this->messageManager->addSuccessMessage(new Phrase('You erased the customer.')); } catch (LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); diff --git a/Controller/Adminhtml/Privacy/Export.php b/Controller/Adminhtml/Privacy/Export.php index 3a1198b2..9949f755 100644 --- a/Controller/Adminhtml/Privacy/Export.php +++ b/Controller/Adminhtml/Privacy/Export.php @@ -12,59 +12,39 @@ use Magento\Backend\Model\View\Result\Redirect; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\Response\Http\FileFactory; +use Magento\Framework\App\ResponseInterface; use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Phrase; -use Opengento\Gdpr\Api\ActionInterface; -use Opengento\Gdpr\Api\Data\ExportEntityInterface; +use Opengento\Gdpr\Api\ExportEntityManagementInterface; +use Opengento\Gdpr\Api\ExportEntityRepositoryInterface; use Opengento\Gdpr\Controller\Adminhtml\AbstractAction; -use Opengento\Gdpr\Model\Action\ArgumentReader; -use Opengento\Gdpr\Model\Action\ContextBuilder; -use Opengento\Gdpr\Model\Action\Export\ArgumentReader as ExportArgumentReader; use Opengento\Gdpr\Model\Config; class Export extends AbstractAction { public const ADMIN_RESOURCE = 'Opengento_Gdpr::customer_export'; - /** - * @var FileFactory - */ - private FileFactory $fileFactory; - - private ActionInterface $action; - - private ContextBuilder $actionContextBuilder; - public function __construct( Context $context, Config $config, - FileFactory $fileFactory, - ActionInterface $action, - ContextBuilder $actionContextBuilder + private FileFactory $fileFactory, + private ExportEntityManagementInterface $exportEntityManagement, + private ExportEntityRepositoryInterface $exportEntityRepository, ) { - $this->fileFactory = $fileFactory; - $this->action = $action; - $this->actionContextBuilder = $actionContextBuilder; parent::__construct($context, $config); } - protected function executeAction() + protected function executeAction(): ResultInterface|ResponseInterface { - $customerId = (int) $this->getRequest()->getParam('id'); - - $this->actionContextBuilder->setParameters([ - ArgumentReader::ENTITY_ID => $customerId, - ArgumentReader::ENTITY_TYPE => 'customer' - ]); - try { - $result = $this->action->execute($this->actionContextBuilder->create())->getResult(); - /** @var ExportEntityInterface $exportEntity */ - $exportEntity = $result[ExportArgumentReader::EXPORT_ENTITY]; + $exportEntity = $this->exportEntityManagement->export( + $this->exportEntityRepository->getByEntity((int)$this->getRequest()->getParam('id'), 'customer') + ); return $this->fileFactory->create( - 'customer_privacy_data_' . $customerId . '.zip', + 'customer_privacy_data_' . $exportEntity->getEntityId() . '.zip', [ 'type' => 'filename', 'value' => $exportEntity->getFilePath(), diff --git a/Controller/Adminhtml/Privacy/MassErase.php b/Controller/Adminhtml/Privacy/MassErase.php index 1babed60..b3b3b4f4 100644 --- a/Controller/Adminhtml/Privacy/MassErase.php +++ b/Controller/Adminhtml/Privacy/MassErase.php @@ -13,50 +13,46 @@ use Magento\Customer\Controller\Adminhtml\Index\AbstractMassAction; use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory; use Magento\Eav\Model\Entity\Collection\AbstractCollection; +use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Phrase; use Magento\Ui\Component\MassAction\Filter; -use Opengento\Gdpr\Api\ActionInterface; -use Opengento\Gdpr\Model\Action\ArgumentReader; -use Opengento\Gdpr\Model\Action\ContextBuilder; +use Opengento\Gdpr\Api\Data\EraseEntityInterface; +use Opengento\Gdpr\Api\EraseEntityManagementInterface; +use Opengento\Gdpr\Api\EraseEntityRepositoryInterface; class MassErase extends AbstractMassAction { public const ADMIN_RESOURCE = 'Opengento_Gdpr::customer_erase'; - private ActionInterface $action; - - private ContextBuilder $actionContextBuilder; - public function __construct( Context $context, Filter $filter, CollectionFactory $collectionFactory, - ActionInterface $action, - ContextBuilder $actionContextBuilder + private EraseEntityManagementInterface $eraseEntityManagement, + private EraseEntityRepositoryInterface $eraseEntityRepository, + private SearchCriteriaBuilder $searchCriteriaBuilder ) { - $this->action = $action; - $this->actionContextBuilder = $actionContextBuilder; parent::__construct($context, $filter, $collectionFactory); } - protected function massAction(AbstractCollection $collection) + protected function massAction(AbstractCollection $collection): Redirect|ResultInterface|\Magento\Framework\App\ResponseInterface { $customerErased = 0; - foreach ($collection->getAllIds() as $customerId) { - $this->actionContextBuilder->setParameters([ - ArgumentReader::ENTITY_ID => (int) $customerId, - ArgumentReader::ENTITY_TYPE => 'customer' - ]); + $this->searchCriteriaBuilder->addFilter(EraseEntityInterface::ENTITY_ID, $collection->getAllIds(), 'in'); + $this->searchCriteriaBuilder->addFilter(EraseEntityInterface::ENTITY_TYPE, 'customer'); + $eraseEntityList = $this->eraseEntityRepository->getList($this->searchCriteriaBuilder->create()); + foreach ($eraseEntityList->getItems() as $eraseEntity) { try { - $this->action->execute($this->actionContextBuilder->create()); + $this->eraseEntityManagement->process($eraseEntity); $customerErased++; } catch (LocalizedException $e) { $this->messageManager->addErrorMessage( - new Phrase('Customer with id "%1": %2', [$customerId, $e->getMessage()]) + new Phrase('Customer with id "%1": %2', [$eraseEntity->getEntityId(), $e->getMessage()]) ); } catch (Exception $e) { $this->messageManager->addExceptionMessage($e, new Phrase('An error occurred on the server.')); diff --git a/Controller/Adminhtml/Privacy/MassExport.php b/Controller/Adminhtml/Privacy/MassExport.php index 295e9a73..52bb246a 100644 --- a/Controller/Adminhtml/Privacy/MassExport.php +++ b/Controller/Adminhtml/Privacy/MassExport.php @@ -13,47 +13,32 @@ use Magento\Customer\Controller\Adminhtml\Index\AbstractMassAction; use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory; use Magento\Eav\Model\Entity\Collection\AbstractCollection; +use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\Response\Http\FileFactory; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Phrase; use Magento\Ui\Component\MassAction\Filter; -use Opengento\Gdpr\Api\ActionInterface; use Opengento\Gdpr\Api\Data\ExportEntityInterface; -use Opengento\Gdpr\Model\Action\ArgumentReader; -use Opengento\Gdpr\Model\Action\ContextBuilder; -use Opengento\Gdpr\Model\Action\Export\ArgumentReader as ExportArgumentReader; +use Opengento\Gdpr\Api\ExportEntityManagementInterface; +use Opengento\Gdpr\Api\ExportEntityRepositoryInterface; use Opengento\Gdpr\Model\Archive\ArchiveManager; class MassExport extends AbstractMassAction { public const ADMIN_RESOURCE = 'Opengento_Gdpr::customer_export'; - /** - * @var FileFactory - */ - private FileFactory $fileFactory; - - private ArchiveManager $archiveManager; - - private ActionInterface $action; - - private ContextBuilder $actionContextBuilder; - public function __construct( Context $context, Filter $filter, CollectionFactory $collectionFactory, - FileFactory $fileFactory, - ArchiveManager $archiveManager, - ActionInterface $action, - ContextBuilder $actionContextBuilder + private FileFactory $fileFactory, + private ArchiveManager $archiveManager, + private ExportEntityManagementInterface $exportEntityManagement, + private ExportEntityRepositoryInterface $exportEntityRepository, + private SearchCriteriaBuilder $searchCriteriaBuilder ) { - $this->fileFactory = $fileFactory; - $this->archiveManager = $archiveManager; - $this->action = $action; - $this->actionContextBuilder = $actionContextBuilder; parent::__construct($context, $filter, $collectionFactory); } @@ -61,18 +46,25 @@ protected function massAction(AbstractCollection $collection) { $archiveFileName = 'customers_privacy_data.zip'; - try { - foreach ($collection->getAllIds() as $customerId) { - $this->actionContextBuilder->setParameters([ - ArgumentReader::ENTITY_ID => (int) $customerId, - ArgumentReader::ENTITY_TYPE => 'customer' - ]); - $result = $this->action->execute($this->actionContextBuilder->create())->getResult(); - /** @var ExportEntityInterface $exportEntity */ - $exportEntity = $result[ExportArgumentReader::EXPORT_ENTITY]; - $this->archiveManager->addToArchive($exportEntity->getFilePath(), $archiveFileName, false); + $this->searchCriteriaBuilder->addFilter(ExportEntityInterface::ENTITY_ID, $collection->getAllIds(), 'in'); + $this->searchCriteriaBuilder->addFilter(ExportEntityInterface::ENTITY_TYPE, 'customer'); + $exportEntityList = $this->exportEntityRepository->getList($this->searchCriteriaBuilder->create()); + + foreach ($exportEntityList->getItems() as $exportEntity) { + try { + $this->archiveManager->addToArchive( + $this->exportEntityManagement->export($exportEntity)->getFilePath(), + $archiveFileName, + false + ); + } catch (LocalizedException $e) { + $this->messageManager->addErrorMessage( + new Phrase('Customer with id "%1": %2', [$exportEntity->getEntityId(), $e->getMessage()]) + ); } + } + try { return $this->fileFactory->create( $archiveFileName, [ @@ -82,10 +74,6 @@ protected function massAction(AbstractCollection $collection) ], DirectoryList::TMP ); - } catch (LocalizedException $e) { - $this->messageManager->addErrorMessage( - new Phrase('Customer with id "%1": %2', [$customerId ?? 'N/A', $e->getMessage()]) - ); } catch (Exception $e) { $this->messageManager->addExceptionMessage($e, new Phrase('An error occurred on the server.')); } diff --git a/Controller/Guest/Download.php b/Controller/Guest/Download.php index ec1659ae..2417b32b 100755 --- a/Controller/Guest/Download.php +++ b/Controller/Guest/Download.php @@ -12,8 +12,10 @@ use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\RequestInterface; use Magento\Framework\App\Response\Http\FileFactory; +use Magento\Framework\App\ResponseInterface; use Magento\Framework\Controller\Result\Redirect; use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Message\ManagerInterface; @@ -54,7 +56,7 @@ protected function isAllowed(): bool return parent::isAllowed() && $this->config->isExportEnabled(); } - protected function executeAction() + protected function executeAction(): ResultInterface|ResponseInterface|Redirect { try { /** @var OrderInterface $order */ @@ -64,7 +66,7 @@ protected function executeAction() 'customer_privacy_data_' . $order->getCustomerLastname() . '.zip', [ 'type' => 'filename', - 'value' => $this->exportRepository->getByEntity((int) $order->getEntityId(), 'order')->getFilePath(), + 'value' => $this->exportRepository->getByEntity((int)$order->getEntityId(), 'order')->getFilePath(), ], DirectoryList::TMP ); diff --git a/Controller/Guest/Erase.php b/Controller/Guest/Erase.php index 11823841..eb39ac11 100644 --- a/Controller/Guest/Erase.php +++ b/Controller/Guest/Erase.php @@ -17,18 +17,12 @@ use Magento\Framework\Phrase; use Magento\Framework\Registry; use Magento\Sales\Controller\AbstractController\OrderLoaderInterface; -use Opengento\Gdpr\Api\ActionInterface; +use Opengento\Gdpr\Api\EraseEntityManagementInterface; use Opengento\Gdpr\Controller\AbstractGuest; -use Opengento\Gdpr\Model\Action\ArgumentReader; -use Opengento\Gdpr\Model\Action\ContextBuilder; use Opengento\Gdpr\Model\Config; class Erase extends AbstractGuest implements HttpPostActionInterface { - private ActionInterface $action; - - private ContextBuilder $actionContextBuilder; - public function __construct( RequestInterface $request, ResultFactory $resultFactory, @@ -36,11 +30,8 @@ public function __construct( Config $config, OrderLoaderInterface $orderLoader, Registry $registry, - ActionInterface $action, - ContextBuilder $actionContextBuilder + private EraseEntityManagementInterface $eraseEntityManagement ) { - $this->action = $action; - $this->actionContextBuilder = $actionContextBuilder; parent::__construct($request, $resultFactory, $messageManager, $config, $orderLoader, $registry); } @@ -55,13 +46,8 @@ protected function executeAction(): Redirect $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $resultRedirect->setRefererOrBaseUrl(); - $this->actionContextBuilder->setParameters([ - ArgumentReader::ENTITY_ID => (int) $this->currentOrder()->getEntityId(), - ArgumentReader::ENTITY_TYPE => 'order' - ]); - try { - $this->action->execute($this->actionContextBuilder->create()); + $this->eraseEntityManagement->create((int)$this->currentOrder()->getEntityId(), 'order'); $this->messageManager->addWarningMessage(new Phrase('Your personal data is being removed soon.')); } catch (LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); diff --git a/Controller/Guest/Export.php b/Controller/Guest/Export.php index a65d877d..8159eed7 100755 --- a/Controller/Guest/Export.php +++ b/Controller/Guest/Export.php @@ -18,18 +18,12 @@ use Magento\Framework\Phrase; use Magento\Framework\Registry; use Magento\Sales\Controller\AbstractController\OrderLoaderInterface; -use Opengento\Gdpr\Api\ActionInterface; +use Opengento\Gdpr\Api\ExportEntityManagementInterface; use Opengento\Gdpr\Controller\AbstractGuest; -use Opengento\Gdpr\Model\Action\ArgumentReader; -use Opengento\Gdpr\Model\Action\ContextBuilder; use Opengento\Gdpr\Model\Config; class Export extends AbstractGuest implements HttpGetActionInterface { - private ActionInterface $action; - - private ContextBuilder $actionContextBuilder; - public function __construct( RequestInterface $request, ResultFactory $resultFactory, @@ -37,11 +31,8 @@ public function __construct( Config $config, OrderLoaderInterface $orderLoader, Registry $registry, - ActionInterface $action, - ContextBuilder $actionContextBuilder + private ExportEntityManagementInterface $exportEntityManagement ) { - $this->action = $action; - $this->actionContextBuilder = $actionContextBuilder; parent::__construct($request, $resultFactory, $messageManager, $config, $orderLoader, $registry); } @@ -56,13 +47,8 @@ protected function executeAction(): Redirect $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $resultRedirect->setRefererOrBaseUrl(); - $this->actionContextBuilder->setParameters([ - ArgumentReader::ENTITY_ID => (int) $this->currentOrder()->getEntityId(), - ArgumentReader::ENTITY_TYPE => 'order' - ]); - try { - $this->action->execute($this->actionContextBuilder->create()); + $this->exportEntityManagement->create((int)$this->currentOrder()->getEntityId(), 'order'); $this->messageManager->addSuccessMessage(new Phrase('You will be notified when the export is ready.')); } catch (AlreadyExistsException $e) { $this->messageManager->addNoticeMessage(new Phrase('A document is already available in your order page.')); diff --git a/Controller/Guest/UndoErase.php b/Controller/Guest/UndoErase.php index 23cbb390..f0e95faa 100644 --- a/Controller/Guest/UndoErase.php +++ b/Controller/Guest/UndoErase.php @@ -17,18 +17,12 @@ use Magento\Framework\Phrase; use Magento\Framework\Registry; use Magento\Sales\Controller\AbstractController\OrderLoaderInterface; -use Opengento\Gdpr\Api\ActionInterface; +use Opengento\Gdpr\Api\EraseEntityManagementInterface; use Opengento\Gdpr\Controller\AbstractGuest; -use Opengento\Gdpr\Model\Action\ArgumentReader; -use Opengento\Gdpr\Model\Action\ContextBuilder; use Opengento\Gdpr\Model\Config; class UndoErase extends AbstractGuest implements HttpPostActionInterface { - private ActionInterface $action; - - private ContextBuilder $actionContextBuilder; - public function __construct( RequestInterface $request, ResultFactory $resultFactory, @@ -36,11 +30,8 @@ public function __construct( Config $config, OrderLoaderInterface $orderLoader, Registry $registry, - ActionInterface $action, - ContextBuilder $actionContextBuilder + private EraseEntityManagementInterface $eraseEntityManagement ) { - $this->action = $action; - $this->actionContextBuilder = $actionContextBuilder; parent::__construct($request, $resultFactory, $messageManager, $config, $orderLoader, $registry); } @@ -55,13 +46,8 @@ protected function executeAction(): Redirect $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $resultRedirect->setRefererOrBaseUrl(); - $this->actionContextBuilder->setParameters([ - ArgumentReader::ENTITY_ID => (int) $this->currentOrder()->getEntityId(), - ArgumentReader::ENTITY_TYPE => 'order' - ]); - try { - $this->action->execute($this->actionContextBuilder->create()); + $this->eraseEntityManagement->cancel((int)$this->currentOrder()->getEntityId(), 'order'); $this->messageManager->addWarningMessage(new Phrase('You canceled your personal data deletion.')); } catch (LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); diff --git a/Controller/Privacy/Download.php b/Controller/Privacy/Download.php index 93bfde27..a84353a0 100755 --- a/Controller/Privacy/Download.php +++ b/Controller/Privacy/Download.php @@ -14,8 +14,10 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\App\Response\Http; use Magento\Framework\App\Response\Http\FileFactory; +use Magento\Framework\App\ResponseInterface; use Magento\Framework\Controller\Result\Redirect; use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Message\ManagerInterface; @@ -26,13 +28,6 @@ class Download extends AbstractPrivacy implements HttpGetActionInterface { - /** - * @var FileFactory - */ - private FileFactory $fileFactory; - - private ExportEntityRepositoryInterface $exportRepository; - public function __construct( RequestInterface $request, ResultFactory $resultFactory, @@ -40,11 +35,9 @@ public function __construct( Config $config, Http $response, Session $customerSession, - FileFactory $fileFactory, - ExportEntityRepositoryInterface $exportRepository + private FileFactory $fileFactory, + private ExportEntityRepositoryInterface $exportRepository ) { - $this->fileFactory = $fileFactory; - $this->exportRepository = $exportRepository; parent::__construct($request, $resultFactory, $messageManager, $config, $customerSession, $response); } @@ -53,10 +46,10 @@ protected function isAllowed(): bool return parent::isAllowed() && $this->config->isExportEnabled(); } - protected function executeAction() + protected function executeAction(): ResultInterface|ResponseInterface|Redirect { try { - $customerId = (int) $this->customerSession->getCustomerId(); + $customerId = (int)$this->customerSession->getCustomerId(); return $this->fileFactory->create( 'customer_privacy_data_' . $customerId . '.zip', diff --git a/Controller/Privacy/Erase.php b/Controller/Privacy/Erase.php index c0cdeea0..3ad59c4a 100755 --- a/Controller/Privacy/Erase.php +++ b/Controller/Privacy/Erase.php @@ -15,14 +15,13 @@ use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Message\ManagerInterface; use Magento\Framework\Phrase; +use Magento\Framework\View\Result\Page; use Opengento\Gdpr\Api\EraseEntityCheckerInterface; use Opengento\Gdpr\Controller\AbstractPrivacy; use Opengento\Gdpr\Model\Config; class Erase extends AbstractPrivacy implements HttpGetActionInterface { - private EraseEntityCheckerInterface $eraseCustomerChecker; - public function __construct( RequestInterface $request, ResultFactory $resultFactory, @@ -30,9 +29,8 @@ public function __construct( Config $config, Session $customerSession, Http $response, - EraseEntityCheckerInterface $eraseCustomerChecker + private EraseEntityCheckerInterface $eraseCustomerChecker ) { - $this->eraseCustomerChecker = $eraseCustomerChecker; parent::__construct($request, $resultFactory, $messageManager, $config, $customerSession, $response); } @@ -41,7 +39,7 @@ protected function isAllowed(): bool return parent::isAllowed() && $this->config->isErasureEnabled(); } - protected function executeAction() + protected function executeAction(): Page|Redirect { if ($this->eraseCustomerChecker->exists((int) $this->customerSession->getCustomerId(), 'customer')) { $this->messageManager->addErrorMessage(new Phrase('Your account is already being removed.')); diff --git a/Controller/Privacy/ErasePost.php b/Controller/Privacy/ErasePost.php index 00e7114e..7bb81fae 100755 --- a/Controller/Privacy/ErasePost.php +++ b/Controller/Privacy/ErasePost.php @@ -21,23 +21,12 @@ use Magento\Framework\Exception\State\UserLockedException; use Magento\Framework\Message\ManagerInterface; use Magento\Framework\Phrase; -use Opengento\Gdpr\Api\ActionInterface; +use Opengento\Gdpr\Api\EraseEntityManagementInterface; use Opengento\Gdpr\Controller\AbstractPrivacy; -use Opengento\Gdpr\Model\Action\ArgumentReader; -use Opengento\Gdpr\Model\Action\ContextBuilder; use Opengento\Gdpr\Model\Config; class ErasePost extends AbstractPrivacy implements HttpPostActionInterface { - /** - * @var AuthenticationInterface - */ - private AuthenticationInterface $authentication; - - private ActionInterface $action; - - private ContextBuilder $actionContextBuilder; - public function __construct( RequestInterface $request, ResultFactory $resultFactory, @@ -45,13 +34,9 @@ public function __construct( Config $config, Session $customerSession, Http $response, - AuthenticationInterface $authentication, - ActionInterface $action, - ContextBuilder $actionContextBuilder + private AuthenticationInterface $authentication, + private EraseEntityManagementInterface $eraseEntityManagement ) { - $this->authentication = $authentication; - $this->action = $action; - $this->actionContextBuilder = $actionContextBuilder; parent::__construct($request, $resultFactory, $messageManager, $config, $customerSession, $response); } @@ -66,15 +51,11 @@ protected function executeAction(): Redirect $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $resultRedirect->setPath('customer/privacy/settings'); - $customerId = (int) $this->customerSession->getCustomerId(); - $this->actionContextBuilder->setParameters([ - ArgumentReader::ENTITY_ID => $customerId, - ArgumentReader::ENTITY_TYPE => 'customer' - ]); + $customerId = (int)$this->customerSession->getCustomerId(); try { - $this->authentication->authenticate($customerId, $this->request->getParam('password')); - $this->action->execute($this->actionContextBuilder->create()); + $this->authentication->authenticate($customerId, (string)$this->request->getParam('password')); + $this->eraseEntityManagement->create($customerId, 'customer'); $this->messageManager->addWarningMessage(new Phrase('Your personal data is being removed soon.')); } catch (InvalidEmailOrPasswordException $e) { $this->messageManager->addErrorMessage($e->getMessage()); diff --git a/Controller/Privacy/Export.php b/Controller/Privacy/Export.php index 0cb591cd..eb5ad6d0 100755 --- a/Controller/Privacy/Export.php +++ b/Controller/Privacy/Export.php @@ -18,18 +18,12 @@ use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Message\ManagerInterface; use Magento\Framework\Phrase; -use Opengento\Gdpr\Api\ActionInterface; +use Opengento\Gdpr\Api\ExportEntityManagementInterface; use Opengento\Gdpr\Controller\AbstractPrivacy; -use Opengento\Gdpr\Model\Action\ArgumentReader; -use Opengento\Gdpr\Model\Action\ContextBuilder; use Opengento\Gdpr\Model\Config; class Export extends AbstractPrivacy implements HttpGetActionInterface { - private ActionInterface $action; - - private ContextBuilder $actionContextBuilder; - public function __construct( RequestInterface $request, ResultFactory $resultFactory, @@ -37,11 +31,8 @@ public function __construct( Config $config, Session $customerSession, Http $response, - ActionInterface $action, - ContextBuilder $actionContextBuilder + private ExportEntityManagementInterface $exportEntityManagement ) { - $this->action = $action; - $this->actionContextBuilder = $actionContextBuilder; parent::__construct($request, $resultFactory, $messageManager, $config, $customerSession, $response); } @@ -56,13 +47,8 @@ protected function executeAction(): Redirect $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $resultRedirect->setRefererOrBaseUrl(); - $this->actionContextBuilder->setParameters([ - ArgumentReader::ENTITY_ID => (int) $this->customerSession->getCustomerId(), - ArgumentReader::ENTITY_TYPE => 'customer' - ]); - try { - $this->action->execute($this->actionContextBuilder->create()); + $this->exportEntityManagement->create((int)$this->customerSession->getCustomerId(), 'customer'); $this->messageManager->addSuccessMessage(new Phrase('You will be notified when the export is ready.')); } catch (AlreadyExistsException $e) { $this->messageManager->addNoticeMessage(new Phrase('A document is already available in your account.')); diff --git a/Controller/Privacy/Settings.php b/Controller/Privacy/Settings.php index 8938c30c..7ccd9678 100755 --- a/Controller/Privacy/Settings.php +++ b/Controller/Privacy/Settings.php @@ -9,11 +9,12 @@ use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\View\Result\Page; use Opengento\Gdpr\Controller\AbstractPrivacy; class Settings extends AbstractPrivacy implements HttpGetActionInterface { - protected function executeAction() + protected function executeAction(): Page { return $this->resultFactory->create(ResultFactory::TYPE_PAGE); } diff --git a/Controller/Privacy/UndoErase.php b/Controller/Privacy/UndoErase.php index ba680c1c..e54e51e6 100755 --- a/Controller/Privacy/UndoErase.php +++ b/Controller/Privacy/UndoErase.php @@ -17,18 +17,12 @@ use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Message\ManagerInterface; use Magento\Framework\Phrase; -use Opengento\Gdpr\Api\ActionInterface; +use Opengento\Gdpr\Api\EraseEntityManagementInterface; use Opengento\Gdpr\Controller\AbstractPrivacy; -use Opengento\Gdpr\Model\Action\ArgumentReader; -use Opengento\Gdpr\Model\Action\ContextBuilder; use Opengento\Gdpr\Model\Config; class UndoErase extends AbstractPrivacy implements HttpPostActionInterface { - private ActionInterface $action; - - private ContextBuilder $actionContextBuilder; - public function __construct( RequestInterface $request, ResultFactory $resultFactory, @@ -36,11 +30,8 @@ public function __construct( Config $config, Session $customerSession, Http $response, - ActionInterface $action, - ContextBuilder $actionContextBuilder + private EraseEntityManagementInterface $eraseEntityManagement ) { - $this->action = $action; - $this->actionContextBuilder = $actionContextBuilder; parent::__construct($request, $resultFactory, $messageManager, $config, $customerSession, $response); } @@ -55,13 +46,8 @@ protected function executeAction(): Redirect $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $resultRedirect->setPath('customer/privacy/settings'); - $this->actionContextBuilder->setParameters([ - ArgumentReader::ENTITY_ID => (int) $this->customerSession->getCustomerId(), - ArgumentReader::ENTITY_TYPE => 'customer' - ]); - try { - $this->action->execute($this->actionContextBuilder->create()); + $this->eraseEntityManagement->cancel((int)$this->customerSession->getCustomerId(), 'customer'); $this->messageManager->addSuccessMessage(new Phrase('You canceled your account deletion.')); } catch (LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); diff --git a/Cron/EraseEntity.php b/Cron/EraseEntity.php index 704d01bb..492e51b0 100755 --- a/Cron/EraseEntity.php +++ b/Cron/EraseEntity.php @@ -23,7 +23,7 @@ /** * Process erase of all scheduled entities */ -final class EraseEntity +class EraseEntity { private LoggerInterface $logger; diff --git a/Cron/EraseEntityScheduler.php b/Cron/EraseEntityScheduler.php index 59bcdfc4..2a4cbefb 100644 --- a/Cron/EraseEntityScheduler.php +++ b/Cron/EraseEntityScheduler.php @@ -22,7 +22,7 @@ /** * Schedule entities to erase */ -final class EraseEntityScheduler +class EraseEntityScheduler { private const CONFIG_PATH_ERASURE_MAX_AGE = 'gdpr/erasure/entity_max_age'; diff --git a/Cron/ExportEntity.php b/Cron/ExportEntity.php index 5d6978e2..0618bb70 100644 --- a/Cron/ExportEntity.php +++ b/Cron/ExportEntity.php @@ -19,7 +19,7 @@ /** * Export all scheduled entities */ -final class ExportEntity +class ExportEntity { private LoggerInterface $logger; diff --git a/Cron/ExportEntityExpired.php b/Cron/ExportEntityExpired.php index 3961bf61..6e0d1a7f 100644 --- a/Cron/ExportEntityExpired.php +++ b/Cron/ExportEntityExpired.php @@ -18,7 +18,7 @@ /** * Delete all expired export entities */ -final class ExportEntityExpired +class ExportEntityExpired { private LoggerInterface $logger; diff --git a/Model/Action/AbstractAction.php b/Model/Action/AbstractAction.php deleted file mode 100644 index eea2a3d2..00000000 --- a/Model/Action/AbstractAction.php +++ /dev/null @@ -1,41 +0,0 @@ -resultBuilder = $resultBuilder; - } - - protected function createActionResult( - array $result = [], - string $message = self::DEFAULT_MESSAGE - ): ActionResultInterface { - $this->resultBuilder->setState(ActionEntityInterface::STATE_SUCCEEDED); - $this->resultBuilder->setPerformedAt(new DateTime()); - $this->resultBuilder->setMessage($message); - $this->resultBuilder->setResult($result); - - return $this->resultBuilder->create(); - } -} diff --git a/Model/Action/ActionComposite.php b/Model/Action/ActionComposite.php deleted file mode 100644 index 017b2773..00000000 --- a/Model/Action/ActionComposite.php +++ /dev/null @@ -1,112 +0,0 @@ -type = $type; - $this->actions = $actions; - $this->contextBuilder = $contextBuilder; - $this->actionEntityBuilder = $actionEntityBuilder; - $this->resultBuilder = $resultBuilder; - $this->actionRepository = $actionRepository; - } - - public function execute(ActionContextInterface $actionContext): ActionResultInterface - { - $this->actionEntityBuilder->setType($this->type); - $this->actionEntityBuilder->setParameters($actionContext->getParameters()); - $this->actionEntityBuilder->setPerformedFrom($actionContext->getPerformedFrom()); - $this->actionEntityBuilder->setPerformedBy($actionContext->getPerformedBy()); - $this->actionEntityBuilder->setPerformedAt(new DateTime()); - - try { - $this->actionEntityBuilder->setState(ActionEntityInterface::STATE_SUCCEEDED); - $this->actionEntityBuilder->setResult($this->process($actionContext)); - } catch (LocalizedException $e) { - $this->actionEntityBuilder->setState(ActionEntityInterface::STATE_FAILED); - $this->actionEntityBuilder->setMessage($e->getMessage()); - } - - $result = $this->result($this->actionRepository->save($this->actionEntityBuilder->create())); - - if (isset($e)) { - throw $e; - } - - return $result; - } - - /** - * @param ActionContextInterface $actionContext - * @return array - * @throws LocalizedException - */ - private function process(ActionContextInterface $actionContext): array - { - foreach ($this->actions as $action) { - $this->contextBuilder->setPerformedFrom($actionContext->getPerformedFrom()); - $this->contextBuilder->setPerformedBy($actionContext->getPerformedBy()); - $this->contextBuilder->setParameters( - array_merge($actionContext->getParameters(), $action->execute($actionContext)->getResult()) - ); - $actionContext = $this->contextBuilder->create(); - } - - return $actionContext->getParameters(); - } - - private function result(ActionEntityInterface $actionEntity): ActionResultInterface - { - $this->resultBuilder->setPerformedAt(new DateTime()); - $this->resultBuilder->setState($actionEntity->getState()); - $this->resultBuilder->setMessage($actionEntity->getMessage()); - $this->resultBuilder->setResult($actionEntity->getResult()); - - return $this->resultBuilder->create(); - } -} diff --git a/Model/Action/ActionFactory.php b/Model/Action/ActionFactory.php deleted file mode 100644 index 90fdb33c..00000000 --- a/Model/Action/ActionFactory.php +++ /dev/null @@ -1,53 +0,0 @@ -actions = $actions; - $this->objectManager = $objectManager; - $this->instances = []; - } - - public function get(string $type): ActionInterface - { - if (!isset($this->instances[$type])) { - if (!isset($this->actions[$type])) { - throw new InvalidArgumentException(sprintf('Unknown action for type "%s".', $type)); - } - - $this->instances[$type] = $this->objectManager->create($this->actions[$type], ['type' => $type]); - } - - return $this->instances[$type]; - } -} diff --git a/Model/Action/ArgumentReader.php b/Model/Action/ArgumentReader.php deleted file mode 100644 index 653a5dbc..00000000 --- a/Model/Action/ArgumentReader.php +++ /dev/null @@ -1,26 +0,0 @@ -getParameters()[self::ENTITY_TYPE] ?? null; - } - - public static function getEntityId(ActionContextInterface $actionContext): ?int - { - return $actionContext->getParameters()[self::ENTITY_ID] ?? null; - } -} diff --git a/Model/Action/Context.php b/Model/Action/Context.php deleted file mode 100644 index 76b4dd83..00000000 --- a/Model/Action/Context.php +++ /dev/null @@ -1,44 +0,0 @@ -performedFrom = $performedFrom; - $this->performedBy = $performedBy; - $this->parameters = $parameters; - } - - public function getPerformedFrom(): string - { - return $this->performedFrom; - } - - public function getPerformedBy(): string - { - return $this->performedBy; - } - - public function getParameters(): array - { - return $this->parameters; - } -} diff --git a/Model/Action/ContextBuilder.php b/Model/Action/ContextBuilder.php deleted file mode 100644 index fd8110f9..00000000 --- a/Model/Action/ContextBuilder.php +++ /dev/null @@ -1,84 +0,0 @@ -actionContextFactory = $actionContextFactory; - $this->stateArea = $stateArea; - $this->performedBy = $performedBy; - $this->data = []; - } - - public function setPerformedFrom(string $performedFrom): ContextBuilder - { - $this->data['performedFrom'] = $performedFrom; - - return $this; - } - - public function setPerformedBy(string $performedBy): ContextBuilder - { - $this->data['performedBy'] = $performedBy; - - return $this; - } - - public function setParameters(array $parameters): ContextBuilder - { - $this->data['parameters'] = $parameters; - - return $this; - } - - /** - * @throws LocalizedException - */ - public function create(): ActionContextInterface - { - if (!isset($this->data['performedFrom'])) { - $this->data['performedFrom'] = $this->stateArea->getAreaCode(); - } - if (!isset($this->data['performedBy'])) { - $this->data['performedBy'] = $this->performedBy->get(); - } - - /** @var ActionContextInterface $context */ - $context = $this->actionContextFactory->create($this->data); - $this->data = []; - - return $context; - } -} diff --git a/Model/Action/Erase/ArgumentReader.php b/Model/Action/Erase/ArgumentReader.php deleted file mode 100644 index 1723d50c..00000000 --- a/Model/Action/Erase/ArgumentReader.php +++ /dev/null @@ -1,21 +0,0 @@ -getParameters()[self::ERASE_ENTITY] ?? null; - } -} diff --git a/Model/Action/Erase/CancelAction.php b/Model/Action/Erase/CancelAction.php deleted file mode 100644 index 6a64ccd5..00000000 --- a/Model/Action/Erase/CancelAction.php +++ /dev/null @@ -1,85 +0,0 @@ -eraseRepository = $eraseRepository; - $this->eraseManagement = $eraseManagement; - parent::__construct($resultBuilder); - } - - public function execute(ActionContextInterface $actionContext): ActionResultInterface - { - $arguments = $this->getArguments($actionContext); - - return $this->createActionResult( - [ - ArgumentReader::ERASE_ENTITY => $this->resolveEntity(...$arguments), - 'canceled' => $this->eraseManagement->cancel(...$arguments), - ] - ); - } - - /** - * @param int $entityId - * @param string $entityType - * @return EraseEntityInterface - * @throws NoSuchEntityException - */ - private function resolveEntity(int $entityId, string $entityType): EraseEntityInterface - { - return clone $this->eraseRepository->getByEntity($entityId, $entityType); - } - - private function getArguments(ActionContextInterface $actionContext): array - { - $entityId = ActionArgumentReader::getEntityId($actionContext); - $entityType = ActionArgumentReader::getEntityType($actionContext); - $errors = []; - - if ($entityId === null) { - $errors[] = InputException::requiredField('entity_id'); - } - if ($entityType === null) { - $errors[] = InputException::requiredField('entity_type'); - } - if (!empty($errors)) { - throw array_reduce( - $errors, - static function (InputException $aggregated, InputException $input): InputException { - return $aggregated->addException($input); - }, - new InputException() - ); - } - - return [$entityId, $entityType]; - } -} diff --git a/Model/Action/Erase/CreateAction.php b/Model/Action/Erase/CreateAction.php deleted file mode 100644 index bb31a652..00000000 --- a/Model/Action/Erase/CreateAction.php +++ /dev/null @@ -1,66 +0,0 @@ -eraseManagement = $eraseManagement; - parent::__construct($resultBuilder); - } - - public function execute(ActionContextInterface $actionContext): ActionResultInterface - { - return $this->createActionResult( - [ - ArgumentReader::ERASE_ENTITY => $this->eraseManagement->create( - ...$this->getArguments($actionContext) - ), - ] - ); - } - - private function getArguments(ActionContextInterface $actionContext): array - { - $entityId = ActionArgumentReader::getEntityId($actionContext); - $entityType = ActionArgumentReader::getEntityType($actionContext); - $errors = []; - - if ($entityId === null) { - $errors[] = InputException::requiredField('entity_id'); - } - if ($entityType === null) { - $errors[] = InputException::requiredField('entity_type'); - } - if (!empty($errors)) { - throw array_reduce( - $errors, - static function (InputException $aggregated, InputException $input): InputException { - return $aggregated->addException($input); - }, - new InputException() - ); - } - - return [$entityId, $entityType]; - } -} diff --git a/Model/Action/Erase/ExecuteAction.php b/Model/Action/Erase/ExecuteAction.php deleted file mode 100644 index f499ebf7..00000000 --- a/Model/Action/Erase/ExecuteAction.php +++ /dev/null @@ -1,41 +0,0 @@ -eraseManagement = $eraseManagement; - parent::__construct($resultBuilder); - } - - public function execute(ActionContextInterface $actionContext): ActionResultInterface - { - $eraseEntity = ArgumentReader::getEntity($actionContext); - - if ($eraseEntity === null) { - throw InputException::requiredField('entity'); - } - - return $this->createActionResult( - [ArgumentReader::ERASE_ENTITY => $this->eraseManagement->process($eraseEntity)] - ); - } -} diff --git a/Model/Action/Erase/NotifierActionBundle.php b/Model/Action/Erase/NotifierActionBundle.php deleted file mode 100644 index 34d081b2..00000000 --- a/Model/Action/Erase/NotifierActionBundle.php +++ /dev/null @@ -1,60 +0,0 @@ -notifiers = $notifiers; - $this->objectManager = $objectManager; - parent::__construct($resultBuilder); - } - - public function execute(ActionContextInterface $actionContext): ActionResultInterface - { - $this->resolveNotifier($actionContext)->notify(ArgumentReader::getEntity($actionContext)); - - return $this->createActionResult(['is_notify' => true]); - } - - /** - * @param ActionContextInterface $actionContext - * @return NotifierInterface - * @throws InputException - */ - private function resolveNotifier(ActionContextInterface $actionContext): NotifierInterface - { - $entityType = ActionArgumentReader::getEntityType($actionContext); - - if (!isset($this->notifiers[$entityType])) { - throw InputException::invalidFieldValue('entity_type', $entityType); - } - - return $this->objectManager->get($this->notifiers[$entityType]); - } -} diff --git a/Model/Action/Export/ArgumentReader.php b/Model/Action/Export/ArgumentReader.php deleted file mode 100644 index 540c56b6..00000000 --- a/Model/Action/Export/ArgumentReader.php +++ /dev/null @@ -1,27 +0,0 @@ -getParameters()[self::EXPORT_ENTITY] ?? null; - } - - public static function getFileName(ActionContextInterface $actionContext): ?string - { - return $actionContext->getParameters()[self::EXPORT_FILE_NAME] ?? null; - } -} diff --git a/Model/Action/Export/CreateAction.php b/Model/Action/Export/CreateAction.php deleted file mode 100644 index 854c650a..00000000 --- a/Model/Action/Export/CreateAction.php +++ /dev/null @@ -1,66 +0,0 @@ -exporter = $exporter; - parent::__construct($resultBuilder); - } - - public function execute(ActionContextInterface $actionContext): ActionResultInterface - { - return $this->createActionResult( - [ - ArgumentReader::EXPORT_ENTITY => $this->exporter->create( - ...$this->getArguments($actionContext) - ), - ] - ); - } - - private function getArguments(ActionContextInterface $actionContext): array - { - $entityId = ActionArgumentReader::getEntityId($actionContext); - $entityType = ActionArgumentReader::getEntityType($actionContext); - $errors = []; - - if ($entityId === null) { - $errors[] = InputException::requiredField('entity_id'); - } - if ($entityType === null) { - $errors[] = InputException::requiredField('entity_type'); - } - if (!empty($errors)) { - throw array_reduce( - $errors, - static function (InputException $aggregated, InputException $input): InputException { - return $aggregated->addException($input); - }, - new InputException() - ); - } - - return [$entityId, $entityType, ArgumentReader::getFileName($actionContext)]; - } -} diff --git a/Model/Action/Export/CreateOrExportAction.php b/Model/Action/Export/CreateOrExportAction.php deleted file mode 100644 index c5bb58c5..00000000 --- a/Model/Action/Export/CreateOrExportAction.php +++ /dev/null @@ -1,70 +0,0 @@ -exportEntityData = $exportEntityData; - parent::__construct($resultBuilder); - } - - public function execute(ActionContextInterface $actionContext): ActionResultInterface - { - return $this->createActionResult( - [ - ExportArgumentReader::EXPORT_ENTITY => $this->exportEntityData->export( - ...$this->getArguments($actionContext) - ), - ] - ); - } - - private function getArguments(ActionContextInterface $actionContext): array - { - $entityId = ArgumentReader::getEntityId($actionContext); - $entityType = ArgumentReader::getEntityType($actionContext); - $errors = []; - - if ($entityId === null) { - $errors[] = InputException::requiredField('entity_id'); - } - if ($entityType === null) { - $errors[] = InputException::requiredField('entity_type'); - } - if (!empty($errors)) { - throw array_reduce( - $errors, - static function (InputException $aggregated, InputException $input): InputException { - return $aggregated->addException($input); - }, - new InputException() - ); - } - - return [$entityId, $entityType]; - } -} diff --git a/Model/Action/Export/ExportAction.php b/Model/Action/Export/ExportAction.php deleted file mode 100644 index 00112bb3..00000000 --- a/Model/Action/Export/ExportAction.php +++ /dev/null @@ -1,56 +0,0 @@ -exportRepository = $exportRepository; - $this->exportManagement = $exportManagement; - parent::__construct($resultBuilder); - } - - public function execute(ActionContextInterface $actionContext): ActionResultInterface - { - $exportEntity = ArgumentReader::getEntity($actionContext); - - if ($exportEntity === null) { - throw InputException::requiredField('entity'); - } - - try { - $exportEntity = $this->exportManagement->export($exportEntity); - } catch (NoSuchEntityException $e) { - $this->exportRepository->delete($exportEntity); - - throw $e; - } - - return $this->createActionResult( - [ExportArgumentReader::EXPORT_ENTITY => $exportEntity] - ); - } -} diff --git a/Model/Action/Export/NotifierActionBundle.php b/Model/Action/Export/NotifierActionBundle.php deleted file mode 100644 index f318e8c5..00000000 --- a/Model/Action/Export/NotifierActionBundle.php +++ /dev/null @@ -1,60 +0,0 @@ -notifiers = $notifiers; - $this->objectManager = $objectManager; - parent::__construct($resultBuilder); - } - - public function execute(ActionContextInterface $actionContext): ActionResultInterface - { - $this->resolveNotifier($actionContext)->notify(ArgumentReader::getEntity($actionContext)); - - return $this->createActionResult(['is_notify' => true]); - } - - /** - * @param ActionContextInterface $actionContext - * @return NotifierInterface - * @throws InputException - */ - private function resolveNotifier(ActionContextInterface $actionContext): NotifierInterface - { - $entityType = ActionArgumentReader::getEntityType($actionContext); - - if (!isset($this->notifiers[$entityType])) { - throw InputException::invalidFieldValue('entity_type', $entityType); - } - - return $this->objectManager->get($this->notifiers[$entityType]); - } -} diff --git a/Model/Action/PerformedBy/AdminUser.php b/Model/Action/PerformedBy/AdminUser.php index 5a466182..a9cf247b 100644 --- a/Model/Action/PerformedBy/AdminUser.php +++ b/Model/Action/PerformedBy/AdminUser.php @@ -10,7 +10,7 @@ use Magento\Backend\Model\Auth\Session; use Opengento\Gdpr\Model\Action\PerformedByInterface; -final class AdminUser implements PerformedByInterface +class AdminUser implements PerformedByInterface { private const PERFORMED_BY = 'Admin: '; diff --git a/Model/Action/PerformedBy/Console.php b/Model/Action/PerformedBy/Console.php index 364b6e50..c40b5f8a 100644 --- a/Model/Action/PerformedBy/Console.php +++ b/Model/Action/PerformedBy/Console.php @@ -9,7 +9,7 @@ use Opengento\Gdpr\Model\Action\PerformedByInterface; -final class Console implements PerformedByInterface +class Console implements PerformedByInterface { private const PERFORMED_BY = 'console'; diff --git a/Model/Action/PerformedBy/Customer.php b/Model/Action/PerformedBy/Customer.php index 03ffda41..f63b31b5 100644 --- a/Model/Action/PerformedBy/Customer.php +++ b/Model/Action/PerformedBy/Customer.php @@ -11,7 +11,7 @@ use Magento\Customer\Model\Session; use Opengento\Gdpr\Model\Action\PerformedByInterface; -final class Customer implements PerformedByInterface +class Customer implements PerformedByInterface { /** * @var Session diff --git a/Model/Action/PerformedBy/Guest.php b/Model/Action/PerformedBy/Guest.php index 65c5c65a..aab938b7 100644 --- a/Model/Action/PerformedBy/Guest.php +++ b/Model/Action/PerformedBy/Guest.php @@ -12,7 +12,7 @@ use Magento\Sales\Model\Order; use Opengento\Gdpr\Model\Action\PerformedByInterface; -final class Guest implements PerformedByInterface +class Guest implements PerformedByInterface { private Registry $coreRegistry; diff --git a/Model/Action/PerformedBy/NotEmptyStrategy.php b/Model/Action/PerformedBy/NotEmptyStrategy.php index 6887ac52..6dce0ffd 100644 --- a/Model/Action/PerformedBy/NotEmptyStrategy.php +++ b/Model/Action/PerformedBy/NotEmptyStrategy.php @@ -9,7 +9,7 @@ use Opengento\Gdpr\Model\Action\PerformedByInterface; -final class NotEmptyStrategy implements PerformedByInterface +class NotEmptyStrategy implements PerformedByInterface { private const PERFORMED_BY = 'Unknown'; diff --git a/Model/Action/Result.php b/Model/Action/Result.php deleted file mode 100644 index b56f5b71..00000000 --- a/Model/Action/Result.php +++ /dev/null @@ -1,57 +0,0 @@ -performedAt = $performedAt; - $this->state = $state; - $this->message = $message; - $this->result = $result; - } - - public function getPerformedAt(): DateTime - { - return $this->performedAt; - } - - public function getState(): string - { - return $this->state; - } - - public function getMessage(): string - { - return $this->message; - } - - public function getResult(): array - { - return $this->result; - } -} diff --git a/Model/Action/ResultBuilder.php b/Model/Action/ResultBuilder.php deleted file mode 100644 index fdf5891f..00000000 --- a/Model/Action/ResultBuilder.php +++ /dev/null @@ -1,69 +0,0 @@ -actionResultFactory = $actionResultFactory; - $this->data = []; - } - - public function setPerformedAt(DateTime $performedAt): ResultBuilder - { - $this->data['performedAt'] = $performedAt; - - return $this; - } - - public function setState(string $state): ResultBuilder - { - $this->data['state'] = $state; - - return $this; - } - - public function setMessage(string $message): ResultBuilder - { - $this->data['message'] = $message; - - return $this; - } - - public function setResult(array $result): ResultBuilder - { - $this->data['result'] = $result; - - return $this; - } - - public function create(): ActionResultInterface - { - /** @var ActionResultInterface $result */ - $result = $this->actionResultFactory->create($this->data); - $this->data = []; - - return $result; - } -} diff --git a/Model/ActionEntity.php b/Model/ActionEntity.php index b3bf37fe..fad60f31 100644 --- a/Model/ActionEntity.php +++ b/Model/ActionEntity.php @@ -12,6 +12,7 @@ use Magento\Framework\Model\AbstractExtensibleModel; use Opengento\Gdpr\Api\Data\ActionEntityInterface; use Opengento\Gdpr\Model\ResourceModel\ActionEntity as ActionEntityResource; + use function is_string; class ActionEntity extends AbstractExtensibleModel implements ActionEntityInterface diff --git a/Model/ActionEntityBuilder.php b/Model/ActionEntityBuilder.php index 680ceffd..af3b182c 100644 --- a/Model/ActionEntityBuilder.php +++ b/Model/ActionEntityBuilder.php @@ -14,7 +14,7 @@ /** * @api */ -final class ActionEntityBuilder +class ActionEntityBuilder { /** * @var ActionEntityInterfaceFactory diff --git a/Model/ActionEntityRepository.php b/Model/ActionEntityRepository.php index b3684c7d..1e0767dd 100644 --- a/Model/ActionEntityRepository.php +++ b/Model/ActionEntityRepository.php @@ -24,7 +24,7 @@ use Opengento\Gdpr\Model\ResourceModel\ActionEntity\Collection; use Opengento\Gdpr\Model\ResourceModel\ActionEntity\CollectionFactory; -final class ActionEntityRepository implements ActionEntityRepositoryInterface +class ActionEntityRepository implements ActionEntityRepositoryInterface { /** * @var ActionEntityResource diff --git a/Model/Archive/ArchiveManager.php b/Model/Archive/ArchiveManager.php index 358d94c1..2f2df505 100644 --- a/Model/Archive/ArchiveManager.php +++ b/Model/Archive/ArchiveManager.php @@ -14,7 +14,7 @@ use Magento\Framework\Filesystem; use Magento\Framework\Phrase; -final class ArchiveManager +class ArchiveManager { private ArchiveInterface $archive; diff --git a/Model/Archive/Zip.php b/Model/Archive/Zip.php index 69b94fdc..38cfcb46 100644 --- a/Model/Archive/Zip.php +++ b/Model/Archive/Zip.php @@ -11,13 +11,14 @@ use Magento\Framework\Archive\Zip as ArchiveZip; use Magento\Framework\Filesystem; use ZipArchive; + use function basename; /** * Zip compressed file archive with local file name. * @api */ -final class Zip implements ArchiveInterface +class Zip implements ArchiveInterface { private Filesystem $filesystem; diff --git a/Model/Config.php b/Model/Config.php index e8471aaa..e8627ea8 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -9,9 +9,10 @@ use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Store\Model\ScopeInterface; + use function explode; -final class Config +class Config { /** * Scope Config: Data Settings Paths diff --git a/Model/Config/PrivacyMessage.php b/Model/Config/PrivacyMessage.php index 65cb1f8e..82c26e4f 100644 --- a/Model/Config/PrivacyMessage.php +++ b/Model/Config/PrivacyMessage.php @@ -13,7 +13,7 @@ use Magento\Framework\View\Element\BlockFactory; use Magento\Store\Model\ScopeInterface; -final class PrivacyMessage +class PrivacyMessage { private const CONFIG_PATH_COOKIE_INFORMATION_ENABLED = 'gdpr/cookie/enabled'; private const CONFIG_PATH_COOKIE_INFORMATION_BLOCK = 'gdpr/cookie/block_id'; diff --git a/Model/Config/Source/ActionStates.php b/Model/Config/Source/ActionStates.php index 45213971..20730ff0 100644 --- a/Model/Config/Source/ActionStates.php +++ b/Model/Config/Source/ActionStates.php @@ -10,10 +10,11 @@ use Magento\Framework\Data\OptionSourceInterface; use Magento\Framework\Phrase; use Opengento\Gdpr\Api\Data\ActionEntityInterface; + use function array_merge; use function compact; -final class ActionStates implements OptionSourceInterface +class ActionStates implements OptionSourceInterface { private array $additionalOptions; diff --git a/Model/Config/Source/EraseComponents.php b/Model/Config/Source/EraseComponents.php index 4236b3f1..b5b0006d 100644 --- a/Model/Config/Source/EraseComponents.php +++ b/Model/Config/Source/EraseComponents.php @@ -10,10 +10,11 @@ use Magento\Framework\Data\OptionSourceInterface; use Magento\Framework\ObjectManager\ConfigInterface; use Magento\Framework\Phrase; + use function array_keys; use function array_merge; -final class EraseComponents implements OptionSourceInterface +class EraseComponents implements OptionSourceInterface { /** * @var ConfigInterface diff --git a/Model/Config/Source/OrderPendingStates.php b/Model/Config/Source/OrderPendingStates.php index 00bc834e..8ed95dd2 100644 --- a/Model/Config/Source/OrderPendingStates.php +++ b/Model/Config/Source/OrderPendingStates.php @@ -10,7 +10,7 @@ use Magento\Framework\Data\OptionSourceInterface; use Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory; -final class OrderPendingStates implements OptionSourceInterface +class OrderPendingStates implements OptionSourceInterface { private CollectionFactory $collectionFactory; diff --git a/Model/Config/Source/VirtualArrayArgumentList.php b/Model/Config/Source/VirtualArrayArgumentList.php index 61893140..13e36688 100644 --- a/Model/Config/Source/VirtualArrayArgumentList.php +++ b/Model/Config/Source/VirtualArrayArgumentList.php @@ -10,9 +10,10 @@ use Magento\Framework\Data\OptionSourceInterface; use Magento\Framework\ObjectManager\ConfigInterface; use Magento\Framework\Phrase; + use function array_keys; -final class VirtualArrayArgumentList implements OptionSourceInterface +class VirtualArrayArgumentList implements OptionSourceInterface { /** * @var ConfigInterface diff --git a/Model/Config/Source/VirtualCustomerAttributes.php b/Model/Config/Source/VirtualCustomerAttributes.php index bbae965e..533a0b3e 100644 --- a/Model/Config/Source/VirtualCustomerAttributes.php +++ b/Model/Config/Source/VirtualCustomerAttributes.php @@ -11,7 +11,7 @@ use Magento\Framework\Data\OptionSourceInterface; use Magento\Framework\Exception\LocalizedException; -final class VirtualCustomerAttributes implements OptionSourceInterface +class VirtualCustomerAttributes implements OptionSourceInterface { private MetadataInterface $metadata; diff --git a/Model/Config/Source/VirtualEntityAttributes.php b/Model/Config/Source/VirtualEntityAttributes.php index ae5b20e2..1b1c9e2f 100644 --- a/Model/Config/Source/VirtualEntityAttributes.php +++ b/Model/Config/Source/VirtualEntityAttributes.php @@ -9,6 +9,7 @@ use Magento\Framework\Data\OptionSourceInterface; use Magento\Framework\Model\EntitySnapshot\AttributeProviderInterface; + use function array_keys; /** @@ -16,7 +17,7 @@ * * Use this virtual type only for registered entities in the metadata pool */ -final class VirtualEntityAttributes implements OptionSourceInterface +class VirtualEntityAttributes implements OptionSourceInterface { /** * @var AttributeProviderInterface diff --git a/Model/Customer/Anonymize/Processor/CustomerAddressDataProcessor.php b/Model/Customer/Anonymize/Processor/CustomerAddressDataProcessor.php index 68db7c3a..22cfc2f6 100644 --- a/Model/Customer/Anonymize/Processor/CustomerAddressDataProcessor.php +++ b/Model/Customer/Anonymize/Processor/CustomerAddressDataProcessor.php @@ -13,7 +13,7 @@ use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -final class CustomerAddressDataProcessor implements ProcessorInterface +class CustomerAddressDataProcessor implements ProcessorInterface { private AnonymizerInterface $anonymizer; diff --git a/Model/Customer/Anonymize/Processor/CustomerDataProcessor.php b/Model/Customer/Anonymize/Processor/CustomerDataProcessor.php index 7bf5b7e3..e07a874c 100644 --- a/Model/Customer/Anonymize/Processor/CustomerDataProcessor.php +++ b/Model/Customer/Anonymize/Processor/CustomerDataProcessor.php @@ -26,12 +26,14 @@ use Opengento\Gdpr\Model\Customer\OrigDataRegistry; use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; + use function mt_rand; use function sha1; use function uniqid; + use const PHP_INT_MAX; -final class CustomerDataProcessor implements ProcessorInterface +class CustomerDataProcessor implements ProcessorInterface { private const CONFIG_PATH_ERASURE_REMOVE_CUSTOMER = 'gdpr/erasure/remove_customer'; diff --git a/Model/Customer/Anonymize/Processor/OrderDataProcessor.php b/Model/Customer/Anonymize/Processor/OrderDataProcessor.php index e07f0776..367d49d1 100644 --- a/Model/Customer/Anonymize/Processor/OrderDataProcessor.php +++ b/Model/Customer/Anonymize/Processor/OrderDataProcessor.php @@ -19,7 +19,7 @@ use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -final class OrderDataProcessor implements ProcessorInterface +class OrderDataProcessor implements ProcessorInterface { private AnonymizerInterface $anonymizer; diff --git a/Model/Customer/Anonymize/Processor/QuoteDataProcessor.php b/Model/Customer/Anonymize/Processor/QuoteDataProcessor.php index d1eebe19..ce0dd358 100644 --- a/Model/Customer/Anonymize/Processor/QuoteDataProcessor.php +++ b/Model/Customer/Anonymize/Processor/QuoteDataProcessor.php @@ -15,7 +15,7 @@ use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -final class QuoteDataProcessor implements ProcessorInterface +class QuoteDataProcessor implements ProcessorInterface { private AnonymizerInterface $anonymizer; diff --git a/Model/Customer/Anonymize/Processor/SubscriberDataProcessor.php b/Model/Customer/Anonymize/Processor/SubscriberDataProcessor.php index 16482033..e3913246 100644 --- a/Model/Customer/Anonymize/Processor/SubscriberDataProcessor.php +++ b/Model/Customer/Anonymize/Processor/SubscriberDataProcessor.php @@ -14,7 +14,7 @@ use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -final class SubscriberDataProcessor implements ProcessorInterface +class SubscriberDataProcessor implements ProcessorInterface { private AnonymizerInterface $anonymizer; diff --git a/Model/Customer/CustomerChecker.php b/Model/Customer/CustomerChecker.php index b2894c75..11c4c970 100644 --- a/Model/Customer/CustomerChecker.php +++ b/Model/Customer/CustomerChecker.php @@ -13,7 +13,7 @@ use Opengento\Gdpr\Model\Config; use Opengento\Gdpr\Model\Entity\EntityCheckerInterface; -final class CustomerChecker implements EntityCheckerInterface +class CustomerChecker implements EntityCheckerInterface { private OrderRepositoryInterface $orderRepository; diff --git a/Model/Customer/Delete/Processor/CustomerAddressDataProcessor.php b/Model/Customer/Delete/Processor/CustomerAddressDataProcessor.php index 927518ff..3cd84a4d 100644 --- a/Model/Customer/Delete/Processor/CustomerAddressDataProcessor.php +++ b/Model/Customer/Delete/Processor/CustomerAddressDataProcessor.php @@ -12,7 +12,7 @@ use Magento\Framework\Exception\LocalizedException; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -final class CustomerAddressDataProcessor implements ProcessorInterface +class CustomerAddressDataProcessor implements ProcessorInterface { /** * @var AddressRepositoryInterface diff --git a/Model/Customer/Delete/Processor/CustomerDataProcessor.php b/Model/Customer/Delete/Processor/CustomerDataProcessor.php index f33714f7..9cab79df 100644 --- a/Model/Customer/Delete/Processor/CustomerDataProcessor.php +++ b/Model/Customer/Delete/Processor/CustomerDataProcessor.php @@ -13,7 +13,7 @@ use Magento\Framework\Exception\NoSuchEntityException; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -final class CustomerDataProcessor implements ProcessorInterface +class CustomerDataProcessor implements ProcessorInterface { /** * @var CustomerRepositoryInterface diff --git a/Model/Customer/Delete/Processor/OrderDataProcessor.php b/Model/Customer/Delete/Processor/OrderDataProcessor.php index e4fa360a..6c8470bc 100644 --- a/Model/Customer/Delete/Processor/OrderDataProcessor.php +++ b/Model/Customer/Delete/Processor/OrderDataProcessor.php @@ -15,7 +15,7 @@ use Opengento\Gdpr\Api\EraseSalesInformationInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -final class OrderDataProcessor implements ProcessorInterface +class OrderDataProcessor implements ProcessorInterface { private OrderRepositoryInterface $orderRepository; diff --git a/Model/Customer/Delete/Processor/QuoteDataProcessor.php b/Model/Customer/Delete/Processor/QuoteDataProcessor.php index 0b19224e..4e925697 100644 --- a/Model/Customer/Delete/Processor/QuoteDataProcessor.php +++ b/Model/Customer/Delete/Processor/QuoteDataProcessor.php @@ -11,7 +11,7 @@ use Magento\Quote\Api\CartRepositoryInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -final class QuoteDataProcessor implements ProcessorInterface +class QuoteDataProcessor implements ProcessorInterface { private CartRepositoryInterface $quoteRepository; diff --git a/Model/Customer/Delete/Processor/SubscriberDataProcessor.php b/Model/Customer/Delete/Processor/SubscriberDataProcessor.php index 8083c8b6..f017042c 100644 --- a/Model/Customer/Delete/Processor/SubscriberDataProcessor.php +++ b/Model/Customer/Delete/Processor/SubscriberDataProcessor.php @@ -13,7 +13,7 @@ use Magento\Newsletter\Model\SubscriberFactory; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -final class SubscriberDataProcessor implements ProcessorInterface +class SubscriberDataProcessor implements ProcessorInterface { private SubscriberFactory $subscriberFactory; diff --git a/Model/Customer/Erase/Notifier.php b/Model/Customer/Erase/Notifier.php index af58e841..b0ce7fae 100644 --- a/Model/Customer/Erase/Notifier.php +++ b/Model/Customer/Erase/Notifier.php @@ -15,7 +15,7 @@ use Opengento\Gdpr\Model\Erase\NotifierInterface; use Psr\Log\LoggerInterface; -final class Notifier implements NotifierInterface +class Notifier implements NotifierInterface { /** @var SenderInterface[] */ private array $senders; diff --git a/Model/Customer/Export/Notifier.php b/Model/Customer/Export/Notifier.php index 07e0671c..d53f4864 100644 --- a/Model/Customer/Export/Notifier.php +++ b/Model/Customer/Export/Notifier.php @@ -14,7 +14,7 @@ use Opengento\Gdpr\Model\Export\NotifierInterface; use Psr\Log\LoggerInterface; -final class Notifier implements NotifierInterface +class Notifier implements NotifierInterface { /** @var SenderInterface[] */ private array $senders; diff --git a/Model/Customer/Export/Processor/CustomerAddressDataProcessor.php b/Model/Customer/Export/Processor/CustomerAddressDataProcessor.php index 18ba7556..7e667bf7 100644 --- a/Model/Customer/Export/Processor/CustomerAddressDataProcessor.php +++ b/Model/Customer/Export/Processor/CustomerAddressDataProcessor.php @@ -14,7 +14,7 @@ use Opengento\Gdpr\Model\Entity\DataCollectorInterface; use Opengento\Gdpr\Service\Export\Processor\AbstractDataProcessor; -final class CustomerAddressDataProcessor extends AbstractDataProcessor +class CustomerAddressDataProcessor extends AbstractDataProcessor { /** * @var AddressRepositoryInterface diff --git a/Model/Customer/Export/Processor/CustomerDataProcessor.php b/Model/Customer/Export/Processor/CustomerDataProcessor.php index 9150ebdc..8be3f931 100644 --- a/Model/Customer/Export/Processor/CustomerDataProcessor.php +++ b/Model/Customer/Export/Processor/CustomerDataProcessor.php @@ -13,7 +13,7 @@ use Opengento\Gdpr\Model\Entity\DataCollectorInterface; use Opengento\Gdpr\Service\Export\Processor\AbstractDataProcessor; -final class CustomerDataProcessor extends AbstractDataProcessor +class CustomerDataProcessor extends AbstractDataProcessor { /** * @var CustomerRepositoryInterface diff --git a/Model/Customer/Export/Processor/OrderDataProcessor.php b/Model/Customer/Export/Processor/OrderDataProcessor.php index bfb3ff38..db33350e 100644 --- a/Model/Customer/Export/Processor/OrderDataProcessor.php +++ b/Model/Customer/Export/Processor/OrderDataProcessor.php @@ -15,7 +15,7 @@ use Opengento\Gdpr\Model\Entity\DataCollectorInterface; use Opengento\Gdpr\Service\Export\Processor\AbstractDataProcessor; -final class OrderDataProcessor extends AbstractDataProcessor +class OrderDataProcessor extends AbstractDataProcessor { private OrderRepositoryInterface $orderRepository; diff --git a/Model/Customer/Export/Processor/QuoteDataProcessor.php b/Model/Customer/Export/Processor/QuoteDataProcessor.php index fb537797..0ead8c04 100644 --- a/Model/Customer/Export/Processor/QuoteDataProcessor.php +++ b/Model/Customer/Export/Processor/QuoteDataProcessor.php @@ -14,7 +14,7 @@ use Opengento\Gdpr\Model\Entity\DataCollectorInterface; use Opengento\Gdpr\Service\Export\Processor\AbstractDataProcessor; -final class QuoteDataProcessor extends AbstractDataProcessor +class QuoteDataProcessor extends AbstractDataProcessor { private CartRepositoryInterface $quoteRepository; diff --git a/Model/Customer/Export/Processor/SubscriberDataProcessor.php b/Model/Customer/Export/Processor/SubscriberDataProcessor.php index 7508924c..05104a21 100644 --- a/Model/Customer/Export/Processor/SubscriberDataProcessor.php +++ b/Model/Customer/Export/Processor/SubscriberDataProcessor.php @@ -12,7 +12,7 @@ use Opengento\Gdpr\Model\Newsletter\SubscriberFactory; use Opengento\Gdpr\Service\Export\Processor\AbstractDataProcessor; -final class SubscriberDataProcessor extends AbstractDataProcessor +class SubscriberDataProcessor extends AbstractDataProcessor { private SubscriberFactory $subscriberFactory; diff --git a/Model/Customer/Notifier/MailSender.php b/Model/Customer/Notifier/MailSender.php index 3fb380d2..b61f764f 100644 --- a/Model/Customer/Notifier/MailSender.php +++ b/Model/Customer/Notifier/MailSender.php @@ -17,7 +17,7 @@ use Magento\Store\Model\StoreManagerInterface; use Opengento\Gdpr\Model\Notifier\AbstractMailSender; -final class MailSender extends AbstractMailSender implements SenderInterface +class MailSender extends AbstractMailSender implements SenderInterface { private View $customerViewHelper; diff --git a/Model/Customer/OrigDataRegistry.php b/Model/Customer/OrigDataRegistry.php index 668c253d..24c43357 100644 --- a/Model/Customer/OrigDataRegistry.php +++ b/Model/Customer/OrigDataRegistry.php @@ -9,7 +9,7 @@ use Magento\Customer\Api\Data\CustomerInterface; -final class OrigDataRegistry +class OrigDataRegistry { /** * @var CustomerInterface[] diff --git a/Model/Customer/SourceProvider/IdleFilterModifier.php b/Model/Customer/SourceProvider/IdleFilterModifier.php index 900a4996..a366e214 100644 --- a/Model/Customer/SourceProvider/IdleFilterModifier.php +++ b/Model/Customer/SourceProvider/IdleFilterModifier.php @@ -11,7 +11,7 @@ use Magento\Framework\Data\Collection; use Opengento\Gdpr\Model\Entity\SourceProvider\ModifierInterface; -final class IdleFilterModifier implements ModifierInterface +class IdleFilterModifier implements ModifierInterface { public function apply(Collection $collection, Filter $filter): void { diff --git a/Model/Entity/DataCollector.php b/Model/Entity/DataCollector.php index f2017d3a..d496cb55 100644 --- a/Model/Entity/DataCollector.php +++ b/Model/Entity/DataCollector.php @@ -7,7 +7,7 @@ namespace Opengento\Gdpr\Model\Entity; -final class DataCollector implements DataCollectorInterface +class DataCollector implements DataCollectorInterface { /** * @var EntityIteratorInterface diff --git a/Model/Entity/DataCollectorGeneric.php b/Model/Entity/DataCollectorGeneric.php index dba4a675..cb7485fe 100644 --- a/Model/Entity/DataCollectorGeneric.php +++ b/Model/Entity/DataCollectorGeneric.php @@ -10,9 +10,10 @@ use Exception; use LogicException; use Magento\Framework\EntityManager\TypeResolver; + use function sprintf; -final class DataCollectorGeneric implements DataCollectorInterface +class DataCollectorGeneric implements DataCollectorInterface { private TypeResolver $typeResolver; diff --git a/Model/Entity/Document.php b/Model/Entity/Document.php index 46f75c30..10ca7c04 100644 --- a/Model/Entity/Document.php +++ b/Model/Entity/Document.php @@ -7,7 +7,7 @@ namespace Opengento\Gdpr\Model\Entity; -final class Document implements DocumentInterface +class Document implements DocumentInterface { private array $data; diff --git a/Model/Entity/EntityCheckerFactory.php b/Model/Entity/EntityCheckerFactory.php index b882345f..8b6053a6 100644 --- a/Model/Entity/EntityCheckerFactory.php +++ b/Model/Entity/EntityCheckerFactory.php @@ -9,12 +9,13 @@ use InvalidArgumentException; use Magento\Framework\ObjectManagerInterface; + use function sprintf; /** * @api */ -final class EntityCheckerFactory +class EntityCheckerFactory { /** * @var string[] diff --git a/Model/Entity/EntityIterator.php b/Model/Entity/EntityIterator.php index 46b3aef2..54671e89 100644 --- a/Model/Entity/EntityIterator.php +++ b/Model/Entity/EntityIterator.php @@ -11,7 +11,7 @@ use Magento\Framework\EntityManager\HydratorPool; use Magento\Framework\EntityManager\TypeResolver; -final class EntityIterator implements EntityIteratorInterface +class EntityIterator implements EntityIteratorInterface { private HydratorPool $hydratorPool; diff --git a/Model/Entity/EntityTypeList.php b/Model/Entity/EntityTypeList.php index 335657ec..026a3f00 100644 --- a/Model/Entity/EntityTypeList.php +++ b/Model/Entity/EntityTypeList.php @@ -13,7 +13,7 @@ /** * @api */ -final class EntityTypeList +class EntityTypeList { /** * @var string[][] diff --git a/Model/Entity/EntityTypeResolver.php b/Model/Entity/EntityTypeResolver.php index 65ee4bc3..02b1f393 100644 --- a/Model/Entity/EntityTypeResolver.php +++ b/Model/Entity/EntityTypeResolver.php @@ -13,7 +13,7 @@ /** * @api */ -final class EntityTypeResolver +class EntityTypeResolver { private TypeResolver $typeResolver; diff --git a/Model/Entity/EntityValue/CustomAttributesProcessor.php b/Model/Entity/EntityValue/CustomAttributesProcessor.php index 02a15b01..7e895c4f 100644 --- a/Model/Entity/EntityValue/CustomAttributesProcessor.php +++ b/Model/Entity/EntityValue/CustomAttributesProcessor.php @@ -9,9 +9,10 @@ use Magento\Framework\Api\CustomAttributesDataInterface; use Opengento\Gdpr\Model\Entity\EntityValueProcessorInterface; + use function is_iterable; -final class CustomAttributesProcessor implements EntityValueProcessorInterface +class CustomAttributesProcessor implements EntityValueProcessorInterface { private EntityValueProcessorInterface $processor; diff --git a/Model/Entity/EntityValue/ExtensibleDataProcessor.php b/Model/Entity/EntityValue/ExtensibleDataProcessor.php index 471f9130..c81234df 100644 --- a/Model/Entity/EntityValue/ExtensibleDataProcessor.php +++ b/Model/Entity/EntityValue/ExtensibleDataProcessor.php @@ -9,9 +9,10 @@ use Magento\Framework\Api\ExtensibleDataInterface; use Opengento\Gdpr\Model\Entity\EntityValueProcessorInterface; + use function is_iterable; -final class ExtensibleDataProcessor implements EntityValueProcessorInterface +class ExtensibleDataProcessor implements EntityValueProcessorInterface { private EntityValueProcessorInterface $processor; diff --git a/Model/Entity/EntityValue/StrategyProcessor.php b/Model/Entity/EntityValue/StrategyProcessor.php index c2782f82..01b1c966 100644 --- a/Model/Entity/EntityValue/StrategyProcessor.php +++ b/Model/Entity/EntityValue/StrategyProcessor.php @@ -9,7 +9,7 @@ use Opengento\Gdpr\Model\Entity\EntityValueProcessorInterface; -final class StrategyProcessor implements EntityValueProcessorInterface +class StrategyProcessor implements EntityValueProcessorInterface { /** * @var EntityValueProcessorInterface[] diff --git a/Model/Entity/Metadata.php b/Model/Entity/Metadata.php index 75689677..5adb7fc4 100644 --- a/Model/Entity/Metadata.php +++ b/Model/Entity/Metadata.php @@ -8,9 +8,10 @@ namespace Opengento\Gdpr\Model\Entity; use Magento\Framework\App\Config\ScopeConfigInterface; + use function explode; -final class Metadata implements MetadataInterface +class Metadata implements MetadataInterface { private ScopeConfigInterface $scopeConfig; diff --git a/Model/Entity/SourceProvider/FilterModifier.php b/Model/Entity/SourceProvider/FilterModifier.php index 826732d3..e9108b48 100644 --- a/Model/Entity/SourceProvider/FilterModifier.php +++ b/Model/Entity/SourceProvider/FilterModifier.php @@ -11,7 +11,7 @@ use Magento\Framework\Data\Collection; use Magento\Framework\Exception\LocalizedException; -final class FilterModifier implements ModifierInterface +class FilterModifier implements ModifierInterface { private string $filterIdentifier; diff --git a/Model/Entity/SourceProvider/ModifierComposite.php b/Model/Entity/SourceProvider/ModifierComposite.php index a6987240..1af430e9 100644 --- a/Model/Entity/SourceProvider/ModifierComposite.php +++ b/Model/Entity/SourceProvider/ModifierComposite.php @@ -13,7 +13,7 @@ /** * @api */ -final class ModifierComposite implements ModifierInterface +class ModifierComposite implements ModifierInterface { /** * @var ModifierInterface[] diff --git a/Model/Entity/SourceProvider/ModifierFactory.php b/Model/Entity/SourceProvider/ModifierFactory.php index c31dfa49..f49c1991 100644 --- a/Model/Entity/SourceProvider/ModifierFactory.php +++ b/Model/Entity/SourceProvider/ModifierFactory.php @@ -12,7 +12,7 @@ /** * @api */ -final class ModifierFactory +class ModifierFactory { /** * @var string[] diff --git a/Model/Entity/SourceProvider/NotErasedFilterModifier.php b/Model/Entity/SourceProvider/NotErasedFilterModifier.php index 8f147535..709f02c4 100644 --- a/Model/Entity/SourceProvider/NotErasedFilterModifier.php +++ b/Model/Entity/SourceProvider/NotErasedFilterModifier.php @@ -10,9 +10,10 @@ use Magento\Framework\Api\Filter; use Magento\Framework\Data\Collection; use Magento\Framework\Data\Collection\AbstractDb; + use function sprintf; -final class NotErasedFilterModifier implements ModifierInterface +class NotErasedFilterModifier implements ModifierInterface { private const DEFAULT_PRIMARY_FIELD = 'entity_id'; diff --git a/Model/Entity/SourceProviderFactory.php b/Model/Entity/SourceProviderFactory.php index f74035b6..7efb324f 100644 --- a/Model/Entity/SourceProviderFactory.php +++ b/Model/Entity/SourceProviderFactory.php @@ -10,12 +10,13 @@ use InvalidArgumentException; use Magento\Framework\Data\Collection; use Magento\Framework\ObjectManagerInterface; + use function sprintf; /** * @api */ -final class SourceProviderFactory +class SourceProviderFactory { /** * @var string[] diff --git a/Model/Erase/EraseEntityScheduler.php b/Model/Erase/EraseEntityScheduler.php index f06bb163..84587d19 100644 --- a/Model/Erase/EraseEntityScheduler.php +++ b/Model/Erase/EraseEntityScheduler.php @@ -15,7 +15,7 @@ use Opengento\Gdpr\Model\Entity\SourceProvider\ModifierFactory; use Opengento\Gdpr\Model\Entity\SourceProviderFactory; -final class EraseEntityScheduler +class EraseEntityScheduler { private SourceProviderFactory $srcProviderFactory; diff --git a/Model/Erase/EraseSalesInformation.php b/Model/Erase/EraseSalesInformation.php index afc69a28..b5090738 100644 --- a/Model/Erase/EraseSalesInformation.php +++ b/Model/Erase/EraseSalesInformation.php @@ -18,7 +18,7 @@ use Opengento\Gdpr\Api\EraseEntityRepositoryInterface; use Opengento\Gdpr\Api\EraseSalesInformationInterface; -final class EraseSalesInformation implements EraseSalesInformationInterface +class EraseSalesInformation implements EraseSalesInformationInterface { private const CONFIG_PATH_ERASURE_SALES_MAX_AGE = 'gdpr/erasure/sales_max_age'; diff --git a/Model/Erase/SecureEraseEntityManagement.php b/Model/Erase/SecureEraseEntityManagement.php index f17dfb0c..34f63bbe 100644 --- a/Model/Erase/SecureEraseEntityManagement.php +++ b/Model/Erase/SecureEraseEntityManagement.php @@ -13,7 +13,7 @@ use Opengento\Gdpr\Api\EraseEntityCheckerInterface; use Opengento\Gdpr\Api\EraseEntityManagementInterface; -final class SecureEraseEntityManagement implements EraseEntityManagementInterface +class SecureEraseEntityManagement implements EraseEntityManagementInterface { private EraseEntityManagementInterface $eraseManagement; diff --git a/Model/EraseEntityChecker.php b/Model/EraseEntityChecker.php index 4f5de130..37a5e8e0 100644 --- a/Model/EraseEntityChecker.php +++ b/Model/EraseEntityChecker.php @@ -13,7 +13,7 @@ use Opengento\Gdpr\Api\EraseEntityRepositoryInterface; use Opengento\Gdpr\Model\Entity\EntityCheckerFactory; -final class EraseEntityChecker implements EraseEntityCheckerInterface +class EraseEntityChecker implements EraseEntityCheckerInterface { private EraseEntityRepositoryInterface $eraseRepository; diff --git a/Model/EraseEntityManagement.php b/Model/EraseEntityManagement.php index 2c4b8526..7809cf53 100644 --- a/Model/EraseEntityManagement.php +++ b/Model/EraseEntityManagement.php @@ -21,7 +21,7 @@ use Opengento\Gdpr\Api\EraseEntityRepositoryInterface; use Opengento\Gdpr\Service\Erase\ProcessorFactory; -final class EraseEntityManagement implements EraseEntityManagementInterface +class EraseEntityManagement implements EraseEntityManagementInterface { private const CONFIG_PATH_ERASURE_DELAY = 'gdpr/erasure/delay'; diff --git a/Model/EraseEntityRepository.php b/Model/EraseEntityRepository.php index a1438bbc..8ae7a30d 100644 --- a/Model/EraseEntityRepository.php +++ b/Model/EraseEntityRepository.php @@ -24,7 +24,7 @@ use Opengento\Gdpr\Model\ResourceModel\EraseEntity\Collection; use Opengento\Gdpr\Model\ResourceModel\EraseEntity\CollectionFactory; -final class EraseEntityRepository implements EraseEntityRepositoryInterface +class EraseEntityRepository implements EraseEntityRepositoryInterface { /** * @var EraseEntityResource diff --git a/Model/Export/ExportEntityData.php b/Model/Export/ExportEntityData.php index 35ae00df..9a382a43 100644 --- a/Model/Export/ExportEntityData.php +++ b/Model/Export/ExportEntityData.php @@ -19,7 +19,7 @@ /** * @api */ -final class ExportEntityData +class ExportEntityData { private ExportEntityRepositoryInterface $exportRepository; diff --git a/Model/Export/ExportToFile.php b/Model/Export/ExportToFile.php index 7e4b8ee6..53ae8124 100644 --- a/Model/Export/ExportToFile.php +++ b/Model/Export/ExportToFile.php @@ -16,11 +16,13 @@ use Opengento\Gdpr\Model\Archive\ArchiveManager; use Opengento\Gdpr\Service\Export\ProcessorFactory; use Opengento\Gdpr\Service\Export\RendererFactory; + use function explode; use function sha1; + use const DIRECTORY_SEPARATOR; -final class ExportToFile +class ExportToFile { private const CONFIG_PATH_EXPORT_RENDERERS = 'gdpr/export/renderers'; diff --git a/Model/ExportEntityChecker.php b/Model/ExportEntityChecker.php index f274160c..6b5e9521 100644 --- a/Model/ExportEntityChecker.php +++ b/Model/ExportEntityChecker.php @@ -11,7 +11,7 @@ use Opengento\Gdpr\Api\ExportEntityCheckerInterface; use Opengento\Gdpr\Api\ExportEntityRepositoryInterface; -final class ExportEntityChecker implements ExportEntityCheckerInterface +class ExportEntityChecker implements ExportEntityCheckerInterface { private ExportEntityRepositoryInterface $exportRepository; diff --git a/Model/ExportEntityManagement.php b/Model/ExportEntityManagement.php index 50739254..9e87dca9 100644 --- a/Model/ExportEntityManagement.php +++ b/Model/ExportEntityManagement.php @@ -21,7 +21,7 @@ use Opengento\Gdpr\Api\ExportEntityRepositoryInterface; use Opengento\Gdpr\Model\Export\ExportToFile; -final class ExportEntityManagement implements ExportEntityManagementInterface +class ExportEntityManagement implements ExportEntityManagementInterface { private const CONFIG_PATH_EXPORT_FILE_NAME = 'gdpr/export/file_name'; private const CONFIG_PATH_EXPORT_LIFE_TIME = 'gdpr/export/life_time'; diff --git a/Model/ExportEntityRepository.php b/Model/ExportEntityRepository.php index f8e37897..cd798436 100644 --- a/Model/ExportEntityRepository.php +++ b/Model/ExportEntityRepository.php @@ -26,7 +26,7 @@ use Opengento\Gdpr\Model\ResourceModel\ExportEntity\Collection; use Opengento\Gdpr\Model\ResourceModel\ExportEntity\CollectionFactory; -final class ExportEntityRepository implements ExportEntityRepositoryInterface +class ExportEntityRepository implements ExportEntityRepositoryInterface { private ExportEntityResource $exportEntityResource; diff --git a/Model/Newsletter/Subscriber.php b/Model/Newsletter/Subscriber.php index a5f82208..cf75368c 100644 --- a/Model/Newsletter/Subscriber.php +++ b/Model/Newsletter/Subscriber.php @@ -11,12 +11,12 @@ use Magento\Newsletter\Model\SubscriberFactory; /** - * `\Opengento\Gdpr\Model\Newsletter\Subscriber` class is the final state of `\Magento\Newsletter\Model\Subscriber`. + * `\Opengento\Gdpr\Model\Newsletter\Subscriber` class is the state of `\Magento\Newsletter\Model\Subscriber`. * * @method SubscriberModel loadByCustomerId(int $customerId) * @method SubscriberModel loadByEmail(string $email) */ -final class Subscriber +class Subscriber { private $subscriber; diff --git a/Model/Notifier/AbstractMailSender.php b/Model/Notifier/AbstractMailSender.php index 3018b0fa..ce0410b0 100644 --- a/Model/Notifier/AbstractMailSender.php +++ b/Model/Notifier/AbstractMailSender.php @@ -13,6 +13,7 @@ use Magento\Framework\Exception\MailException; use Magento\Framework\Mail\Template\TransportBuilder; use Magento\Store\Model\ScopeInterface; + use function explode; abstract class AbstractMailSender diff --git a/Model/Order/Anonymize/Processor/OrderDataProcessor.php b/Model/Order/Anonymize/Processor/OrderDataProcessor.php index 4168772c..b7a1f6de 100644 --- a/Model/Order/Anonymize/Processor/OrderDataProcessor.php +++ b/Model/Order/Anonymize/Processor/OrderDataProcessor.php @@ -17,7 +17,7 @@ use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -final class OrderDataProcessor implements ProcessorInterface +class OrderDataProcessor implements ProcessorInterface { private AnonymizerInterface $anonymizer; diff --git a/Model/Order/Anonymize/Processor/QuoteDataProcessor.php b/Model/Order/Anonymize/Processor/QuoteDataProcessor.php index 492433b1..ea519804 100644 --- a/Model/Order/Anonymize/Processor/QuoteDataProcessor.php +++ b/Model/Order/Anonymize/Processor/QuoteDataProcessor.php @@ -17,7 +17,7 @@ use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -final class QuoteDataProcessor implements ProcessorInterface +class QuoteDataProcessor implements ProcessorInterface { private AnonymizerInterface $anonymizer; diff --git a/Model/Order/Anonymize/Processor/SubscriberDataProcessor.php b/Model/Order/Anonymize/Processor/SubscriberDataProcessor.php index fd3a071a..1ae870ef 100644 --- a/Model/Order/Anonymize/Processor/SubscriberDataProcessor.php +++ b/Model/Order/Anonymize/Processor/SubscriberDataProcessor.php @@ -15,7 +15,7 @@ use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -final class SubscriberDataProcessor implements ProcessorInterface +class SubscriberDataProcessor implements ProcessorInterface { private AnonymizerInterface $anonymizer; diff --git a/Model/Order/Delete/Processor/OrderDataProcessor.php b/Model/Order/Delete/Processor/OrderDataProcessor.php index 1bb0942e..322ec9f1 100644 --- a/Model/Order/Delete/Processor/OrderDataProcessor.php +++ b/Model/Order/Delete/Processor/OrderDataProcessor.php @@ -13,7 +13,7 @@ use Opengento\Gdpr\Api\EraseSalesInformationInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -final class OrderDataProcessor implements ProcessorInterface +class OrderDataProcessor implements ProcessorInterface { private OrderRepositoryInterface $orderRepository; diff --git a/Model/Order/Delete/Processor/QuoteDataProcessor.php b/Model/Order/Delete/Processor/QuoteDataProcessor.php index 08a9fb68..a8793f32 100644 --- a/Model/Order/Delete/Processor/QuoteDataProcessor.php +++ b/Model/Order/Delete/Processor/QuoteDataProcessor.php @@ -12,7 +12,7 @@ use Magento\Sales\Api\OrderRepositoryInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -final class QuoteDataProcessor implements ProcessorInterface +class QuoteDataProcessor implements ProcessorInterface { private OrderRepositoryInterface $orderRepository; diff --git a/Model/Order/Delete/Processor/SubscriberDataProcessor.php b/Model/Order/Delete/Processor/SubscriberDataProcessor.php index d7919ccd..43c1c4d5 100644 --- a/Model/Order/Delete/Processor/SubscriberDataProcessor.php +++ b/Model/Order/Delete/Processor/SubscriberDataProcessor.php @@ -15,7 +15,7 @@ use Magento\Store\Model\StoreManagerInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -final class SubscriberDataProcessor implements ProcessorInterface +class SubscriberDataProcessor implements ProcessorInterface { private OrderRepositoryInterface $orderRepository; diff --git a/Model/Order/Erase/Notifier.php b/Model/Order/Erase/Notifier.php index 497e0393..3976753f 100644 --- a/Model/Order/Erase/Notifier.php +++ b/Model/Order/Erase/Notifier.php @@ -14,7 +14,7 @@ use Opengento\Gdpr\Model\Order\Notifier\SenderInterface; use Psr\Log\LoggerInterface; -final class Notifier implements NotifierInterface +class Notifier implements NotifierInterface { /** @var SenderInterface[] */ private array $senders; diff --git a/Model/Order/Export/Notifier.php b/Model/Order/Export/Notifier.php index 584dad66..f1be5a36 100644 --- a/Model/Order/Export/Notifier.php +++ b/Model/Order/Export/Notifier.php @@ -14,7 +14,7 @@ use Opengento\Gdpr\Model\Order\Notifier\SenderInterface; use Psr\Log\LoggerInterface; -final class Notifier implements NotifierInterface +class Notifier implements NotifierInterface { /** @var SenderInterface[] */ private array $senders; diff --git a/Model/Order/Export/Processor/OrderDataProcessor.php b/Model/Order/Export/Processor/OrderDataProcessor.php index ed51842a..18d7a5ac 100644 --- a/Model/Order/Export/Processor/OrderDataProcessor.php +++ b/Model/Order/Export/Processor/OrderDataProcessor.php @@ -11,7 +11,7 @@ use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Model\Order; -final class OrderDataProcessor extends AbstractDataProcessor +class OrderDataProcessor extends AbstractDataProcessor { protected function export(OrderInterface $order, array $data): array { diff --git a/Model/Order/Export/Processor/QuoteDataProcessor.php b/Model/Order/Export/Processor/QuoteDataProcessor.php index 99bf3984..b6cbf01d 100644 --- a/Model/Order/Export/Processor/QuoteDataProcessor.php +++ b/Model/Order/Export/Processor/QuoteDataProcessor.php @@ -15,7 +15,7 @@ use Magento\Sales\Api\OrderRepositoryInterface; use Opengento\Gdpr\Model\Entity\DataCollectorInterface; -final class QuoteDataProcessor extends AbstractDataProcessor +class QuoteDataProcessor extends AbstractDataProcessor { private CartRepositoryInterface $quoteRepository; diff --git a/Model/Order/Export/Processor/SubscriberDataProcessor.php b/Model/Order/Export/Processor/SubscriberDataProcessor.php index d9846da0..66f01db7 100644 --- a/Model/Order/Export/Processor/SubscriberDataProcessor.php +++ b/Model/Order/Export/Processor/SubscriberDataProcessor.php @@ -13,7 +13,7 @@ use Opengento\Gdpr\Model\Newsletter\Subscriber; use Opengento\Gdpr\Model\Newsletter\SubscriberFactory; -final class SubscriberDataProcessor extends AbstractDataProcessor +class SubscriberDataProcessor extends AbstractDataProcessor { private SubscriberFactory $subscriberFactory; diff --git a/Model/Order/Notifier/MailSender.php b/Model/Order/Notifier/MailSender.php index ca3c94df..74a2532a 100644 --- a/Model/Order/Notifier/MailSender.php +++ b/Model/Order/Notifier/MailSender.php @@ -16,7 +16,7 @@ use Opengento\Gdpr\Model\Notifier\AbstractMailSender; use Psr\Log\LoggerInterface; -final class MailSender extends AbstractMailSender implements SenderInterface +class MailSender extends AbstractMailSender implements SenderInterface { /** * @var LoggerInterface @@ -63,6 +63,6 @@ public function send(OrderInterface $order): void } catch (MailException $exc) { $this->logger->error(__('GDPR Email Error: %1', $exc->getMessage())); } - + } } diff --git a/Model/Order/OrderChecker.php b/Model/Order/OrderChecker.php index f021bae6..a9d3ddac 100644 --- a/Model/Order/OrderChecker.php +++ b/Model/Order/OrderChecker.php @@ -10,9 +10,10 @@ use Magento\Sales\Api\OrderRepositoryInterface; use Opengento\Gdpr\Model\Config; use Opengento\Gdpr\Model\Entity\EntityCheckerInterface; + use function in_array; -final class OrderChecker implements EntityCheckerInterface +class OrderChecker implements EntityCheckerInterface { private OrderRepositoryInterface $orderRepository; diff --git a/Model/Order/SourceProvider/GuestFilterModifier.php b/Model/Order/SourceProvider/GuestFilterModifier.php index 43ddbe75..a669de0f 100644 --- a/Model/Order/SourceProvider/GuestFilterModifier.php +++ b/Model/Order/SourceProvider/GuestFilterModifier.php @@ -14,7 +14,7 @@ use Opengento\Gdpr\Model\Config; use Opengento\Gdpr\Model\Entity\SourceProvider\ModifierInterface; -final class GuestFilterModifier implements ModifierInterface +class GuestFilterModifier implements ModifierInterface { private Config $config; diff --git a/Model/ResourceModel/ActionEntity/Validator.php b/Model/ResourceModel/ActionEntity/Validator.php index 0f6dd1f0..6d5473d3 100644 --- a/Model/ResourceModel/ActionEntity/Validator.php +++ b/Model/ResourceModel/ActionEntity/Validator.php @@ -10,7 +10,7 @@ use Magento\Framework\Validator\AbstractValidator; use Magento\Framework\Validator\ValidatorInterface; -final class Validator extends AbstractValidator +class Validator extends AbstractValidator { /** * @var ValidatorInterface[] diff --git a/Model/ResourceModel/ActionEntity/Validator/StateValidator.php b/Model/ResourceModel/ActionEntity/Validator/StateValidator.php index f80341fb..23d529bf 100644 --- a/Model/ResourceModel/ActionEntity/Validator/StateValidator.php +++ b/Model/ResourceModel/ActionEntity/Validator/StateValidator.php @@ -11,10 +11,11 @@ use Magento\Framework\Validator\AbstractValidator; use Opengento\Gdpr\Api\Data\ActionEntityInterface; use Opengento\Gdpr\Model\Config\Source\ActionStates; + use function array_column; use function in_array; -final class StateValidator extends AbstractValidator +class StateValidator extends AbstractValidator { private ActionStates $actionStates; diff --git a/Model/ResourceModel/EraseEntity.php b/Model/ResourceModel/EraseEntity.php index 993b7e0b..de5c3104 100755 --- a/Model/ResourceModel/EraseEntity.php +++ b/Model/ResourceModel/EraseEntity.php @@ -12,6 +12,7 @@ use Magento\Framework\Model\AbstractModel; use Magento\Framework\Model\ResourceModel\Db\VersionControl\AbstractDb; use Opengento\Gdpr\Api\Data\EraseEntityInterface; + use function is_array; use function sprintf; diff --git a/Model/ResourceModel/ExportEntity.php b/Model/ResourceModel/ExportEntity.php index b011579c..4530d3ea 100755 --- a/Model/ResourceModel/ExportEntity.php +++ b/Model/ResourceModel/ExportEntity.php @@ -12,6 +12,7 @@ use Magento\Framework\Model\AbstractModel; use Magento\Framework\Model\ResourceModel\Db\VersionControl\AbstractDb; use Opengento\Gdpr\Api\Data\ExportEntityInterface; + use function is_array; use function sprintf; diff --git a/Observer/DeleteExport.php b/Observer/DeleteExport.php index e5892bc1..efd945e1 100644 --- a/Observer/DeleteExport.php +++ b/Observer/DeleteExport.php @@ -22,7 +22,7 @@ use Opengento\Gdpr\Model\Entity\EntityTypeResolver; use Psr\Log\LoggerInterface; -final class DeleteExport implements ObserverInterface +class DeleteExport implements ObserverInterface { private ExportEntityRepositoryInterface $exportRepository; diff --git a/Observer/InvalidateExport.php b/Observer/InvalidateExport.php index fd32f250..1b7243fc 100644 --- a/Observer/InvalidateExport.php +++ b/Observer/InvalidateExport.php @@ -23,7 +23,7 @@ use Opengento\Gdpr\Model\Entity\EntityTypeResolver; use Psr\Log\LoggerInterface; -final class InvalidateExport implements ObserverInterface +class InvalidateExport implements ObserverInterface { private ExportEntityRepositoryInterface $exportRepository; diff --git a/Service/Anonymize/Anonymizer/AlphaLower.php b/Service/Anonymize/Anonymizer/AlphaLower.php index 3a0d3ac9..5ae87c29 100644 --- a/Service/Anonymize/Anonymizer/AlphaLower.php +++ b/Service/Anonymize/Anonymizer/AlphaLower.php @@ -11,7 +11,7 @@ use Magento\Framework\Math\Random; use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; -final class AlphaLower implements AnonymizerInterface +class AlphaLower implements AnonymizerInterface { private const DEFAULT_LENGTH = 5; diff --git a/Service/Anonymize/Anonymizer/AlphaNum.php b/Service/Anonymize/Anonymizer/AlphaNum.php index 7181d622..abcf8c0f 100644 --- a/Service/Anonymize/Anonymizer/AlphaNum.php +++ b/Service/Anonymize/Anonymizer/AlphaNum.php @@ -11,7 +11,7 @@ use Magento\Framework\Math\Random; use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; -final class AlphaNum implements AnonymizerInterface +class AlphaNum implements AnonymizerInterface { private const DEFAULT_LENGTH = 5; diff --git a/Service/Anonymize/Anonymizer/AlphaUpper.php b/Service/Anonymize/Anonymizer/AlphaUpper.php index 18a6c032..e3674f5e 100644 --- a/Service/Anonymize/Anonymizer/AlphaUpper.php +++ b/Service/Anonymize/Anonymizer/AlphaUpper.php @@ -11,7 +11,7 @@ use Magento\Framework\Math\Random; use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; -final class AlphaUpper implements AnonymizerInterface +class AlphaUpper implements AnonymizerInterface { private const DEFAULT_LENGTH = 5; diff --git a/Service/Anonymize/Anonymizer/Anonymous.php b/Service/Anonymize/Anonymizer/Anonymous.php index 32b0a1e6..a0a9bbe0 100644 --- a/Service/Anonymize/Anonymizer/Anonymous.php +++ b/Service/Anonymize/Anonymizer/Anonymous.php @@ -12,7 +12,7 @@ use Magento\Framework\Phrase; use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; -final class Anonymous implements AnonymizerInterface +class Anonymous implements AnonymizerInterface { private const PHRASE = '%1Anonymous%2'; private const PREFIX_LENGTH = 3; diff --git a/Service/Anonymize/Anonymizer/Date.php b/Service/Anonymize/Anonymizer/Date.php index c8a947e5..17f88188 100644 --- a/Service/Anonymize/Anonymizer/Date.php +++ b/Service/Anonymize/Anonymizer/Date.php @@ -13,7 +13,7 @@ use Magento\Framework\Stdlib\DateTime as StdlibDateTime; use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; -final class Date implements AnonymizerInterface +class Date implements AnonymizerInterface { private const MIN_TIMESTAMP = 0; private const MAX_TIMESTAMP = 1557480188; diff --git a/Service/Anonymize/Anonymizer/Email.php b/Service/Anonymize/Anonymizer/Email.php index 4c09bb62..35d7b6f1 100644 --- a/Service/Anonymize/Anonymizer/Email.php +++ b/Service/Anonymize/Anonymizer/Email.php @@ -12,7 +12,7 @@ use Magento\Framework\Phrase; use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; -final class Email implements AnonymizerInterface +class Email implements AnonymizerInterface { private const PHRASE = '%1-anonymous-%2@gdpr.org'; private const PREFIX_LENGTH = 3; diff --git a/Service/Anonymize/Anonymizer/Entity.php b/Service/Anonymize/Anonymizer/Entity.php index d5007374..741bc421 100644 --- a/Service/Anonymize/Anonymizer/Entity.php +++ b/Service/Anonymize/Anonymizer/Entity.php @@ -13,11 +13,12 @@ use Magento\Framework\EntityManager\TypeResolver; use Opengento\Gdpr\Model\Entity\DataCollectorInterface; use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; + use function gettype; use function is_object; use function sprintf; -final class Entity implements AnonymizerInterface +class Entity implements AnonymizerInterface { private DataCollectorInterface $dataCollector; diff --git a/Service/Anonymize/Anonymizer/NullValue.php b/Service/Anonymize/Anonymizer/NullValue.php index 881cf83c..3a595f9c 100644 --- a/Service/Anonymize/Anonymizer/NullValue.php +++ b/Service/Anonymize/Anonymizer/NullValue.php @@ -9,7 +9,7 @@ use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; -final class NullValue implements AnonymizerInterface +class NullValue implements AnonymizerInterface { public function anonymize($value) { diff --git a/Service/Anonymize/Anonymizer/Number.php b/Service/Anonymize/Anonymizer/Number.php index 960cbf50..1caca0f8 100644 --- a/Service/Anonymize/Anonymizer/Number.php +++ b/Service/Anonymize/Anonymizer/Number.php @@ -10,10 +10,11 @@ use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Math\Random; use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; + use const PHP_INT_MAX; use const PHP_INT_MIN; -final class Number implements AnonymizerInterface +class Number implements AnonymizerInterface { /** * @var int|null diff --git a/Service/Anonymize/Anonymizer/Phone.php b/Service/Anonymize/Anonymizer/Phone.php index 34410948..05a85942 100644 --- a/Service/Anonymize/Anonymizer/Phone.php +++ b/Service/Anonymize/Anonymizer/Phone.php @@ -9,7 +9,7 @@ use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; -final class Phone implements AnonymizerInterface +class Phone implements AnonymizerInterface { private const PHONE_NUMBER = '9999999999'; diff --git a/Service/Anonymize/Anonymizer/Street.php b/Service/Anonymize/Anonymizer/Street.php index bdb6bcaf..baf91e8b 100644 --- a/Service/Anonymize/Anonymizer/Street.php +++ b/Service/Anonymize/Anonymizer/Street.php @@ -10,9 +10,10 @@ use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Math\Random; use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; + use function sprintf; -final class Street implements AnonymizerInterface +class Street implements AnonymizerInterface { private const STREET_LENGTH = 5; private const MIN_NUM = 0; diff --git a/Service/Anonymize/AnonymizerFactory.php b/Service/Anonymize/AnonymizerFactory.php index 803c2569..a0a9da98 100644 --- a/Service/Anonymize/AnonymizerFactory.php +++ b/Service/Anonymize/AnonymizerFactory.php @@ -9,9 +9,10 @@ use InvalidArgumentException; use Magento\Framework\ObjectManagerInterface; + use function sprintf; -final class AnonymizerFactory +class AnonymizerFactory { public const DEFAULT_KEY = 'default'; diff --git a/Service/Anonymize/Metadata.php b/Service/Anonymize/Metadata.php index 2d1d4a99..aeaba703 100644 --- a/Service/Anonymize/Metadata.php +++ b/Service/Anonymize/Metadata.php @@ -9,11 +9,12 @@ use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\Serialize\SerializerInterface; + use function array_column; use function array_combine; use function array_keys; -final class Metadata implements MetadataInterface +class Metadata implements MetadataInterface { private ScopeConfigInterface $scopeConfig; diff --git a/Service/Anonymize/Processor/Entity/EntityValue/Processor.php b/Service/Anonymize/Processor/Entity/EntityValue/Processor.php index 26ea70ed..a3969c82 100644 --- a/Service/Anonymize/Processor/Entity/EntityValue/Processor.php +++ b/Service/Anonymize/Processor/Entity/EntityValue/Processor.php @@ -11,9 +11,10 @@ use Opengento\Gdpr\Model\Entity\EntityValueProcessorInterface; use Opengento\Gdpr\Model\Entity\MetadataInterface; use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; + use function in_array; -final class Processor implements EntityValueProcessorInterface +class Processor implements EntityValueProcessorInterface { /** * @var DocumentInterface diff --git a/Service/Anonymize/Processor/Entity/EntityValue/SmartProcessor.php b/Service/Anonymize/Processor/Entity/EntityValue/SmartProcessor.php index b2abd4ca..56d60ed8 100644 --- a/Service/Anonymize/Processor/Entity/EntityValue/SmartProcessor.php +++ b/Service/Anonymize/Processor/Entity/EntityValue/SmartProcessor.php @@ -11,9 +11,10 @@ use Opengento\Gdpr\Model\Entity\EntityValueProcessorInterface; use Opengento\Gdpr\Service\Anonymize\AnonymizerFactory; use Opengento\Gdpr\Service\Anonymize\MetadataInterface; + use function in_array; -final class SmartProcessor implements EntityValueProcessorInterface +class SmartProcessor implements EntityValueProcessorInterface { /** * @var DocumentInterface diff --git a/Service/Erase/Metadata.php b/Service/Erase/Metadata.php index 231fd68d..e0643581 100644 --- a/Service/Erase/Metadata.php +++ b/Service/Erase/Metadata.php @@ -10,11 +10,12 @@ use InvalidArgumentException; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\Serialize\SerializerInterface; + use function array_column; use function array_combine; use function sprintf; -final class Metadata implements MetadataInterface +class Metadata implements MetadataInterface { private ScopeConfigInterface $scopeConfig; diff --git a/Service/Erase/Processor/EraseProcessor.php b/Service/Erase/Processor/EraseProcessor.php index 860398d3..f7e2c448 100644 --- a/Service/Erase/Processor/EraseProcessor.php +++ b/Service/Erase/Processor/EraseProcessor.php @@ -10,9 +10,10 @@ use Opengento\Gdpr\Model\Config\Source\EraseComponents; use Opengento\Gdpr\Service\Erase\ProcessorInterface; use Opengento\Gdpr\Service\Erase\ProcessorResolverInterface; + use function array_column; -final class EraseProcessor implements ProcessorInterface +class EraseProcessor implements ProcessorInterface { /** * @var ProcessorResolverInterface diff --git a/Service/Erase/ProcessorFactory.php b/Service/Erase/ProcessorFactory.php index bf425260..a548bdb4 100644 --- a/Service/Erase/ProcessorFactory.php +++ b/Service/Erase/ProcessorFactory.php @@ -9,12 +9,13 @@ use InvalidArgumentException; use Magento\Framework\ObjectManagerInterface; + use function sprintf; /** * @api */ -final class ProcessorFactory +class ProcessorFactory { /** * @var string[] diff --git a/Service/Erase/ProcessorResolver/ProcessorResolver.php b/Service/Erase/ProcessorResolver/ProcessorResolver.php index dfb6be1e..f787da43 100644 --- a/Service/Erase/ProcessorResolver/ProcessorResolver.php +++ b/Service/Erase/ProcessorResolver/ProcessorResolver.php @@ -11,9 +11,10 @@ use Magento\Framework\ObjectManagerInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; use Opengento\Gdpr\Service\Erase\ProcessorResolverInterface; + use function sprintf; -final class ProcessorResolver implements ProcessorResolverInterface +class ProcessorResolver implements ProcessorResolverInterface { /** * @var ProcessorInterface[] diff --git a/Service/Erase/ProcessorResolver/ProcessorResolverStrategy.php b/Service/Erase/ProcessorResolver/ProcessorResolverStrategy.php index 7c3c205d..010f24a2 100644 --- a/Service/Erase/ProcessorResolver/ProcessorResolverStrategy.php +++ b/Service/Erase/ProcessorResolver/ProcessorResolverStrategy.php @@ -12,7 +12,7 @@ use Opengento\Gdpr\Service\Erase\ProcessorResolverFactory; use Opengento\Gdpr\Service\Erase\ProcessorResolverInterface; -final class ProcessorResolverStrategy implements ProcessorResolverInterface +class ProcessorResolverStrategy implements ProcessorResolverInterface { /** * @var ProcessorResolverFactory diff --git a/Service/Erase/ProcessorResolverFactory.php b/Service/Erase/ProcessorResolverFactory.php index d8e37821..2f76fc0c 100644 --- a/Service/Erase/ProcessorResolverFactory.php +++ b/Service/Erase/ProcessorResolverFactory.php @@ -9,12 +9,13 @@ use InvalidArgumentException; use Magento\Framework\ObjectManagerInterface; + use function sprintf; /** * @api */ -final class ProcessorResolverFactory +class ProcessorResolverFactory { /** * @var string[] diff --git a/Service/Export/Processor/CompositeProcessor.php b/Service/Export/Processor/CompositeProcessor.php index edff6d42..13120286 100644 --- a/Service/Export/Processor/CompositeProcessor.php +++ b/Service/Export/Processor/CompositeProcessor.php @@ -8,9 +8,10 @@ namespace Opengento\Gdpr\Service\Export\Processor; use Opengento\Gdpr\Service\Export\ProcessorInterface; + use function array_reduce; -final class CompositeProcessor implements ProcessorInterface +class CompositeProcessor implements ProcessorInterface { /** * @var ProcessorInterface[] diff --git a/Service/Export/Processor/Entity/EntityValue/DataProcessor.php b/Service/Export/Processor/Entity/EntityValue/DataProcessor.php index 3ca529e2..fb747eba 100644 --- a/Service/Export/Processor/Entity/EntityValue/DataProcessor.php +++ b/Service/Export/Processor/Entity/EntityValue/DataProcessor.php @@ -10,9 +10,10 @@ use Opengento\Gdpr\Model\Entity\DocumentInterface; use Opengento\Gdpr\Model\Entity\EntityValueProcessorInterface; use Opengento\Gdpr\Model\Entity\MetadataInterface; + use function in_array; -final class DataProcessor implements EntityValueProcessorInterface +class DataProcessor implements EntityValueProcessorInterface { /** * @var DocumentInterface diff --git a/Service/Export/Processor/Entity/EntityValue/EntityProcessor.php b/Service/Export/Processor/Entity/EntityValue/EntityProcessor.php index a7a34985..00043a8f 100644 --- a/Service/Export/Processor/Entity/EntityValue/EntityProcessor.php +++ b/Service/Export/Processor/Entity/EntityValue/EntityProcessor.php @@ -11,9 +11,10 @@ use Opengento\Gdpr\Model\Entity\DocumentInterface; use Opengento\Gdpr\Model\Entity\EntityValueProcessorInterface; use Opengento\Gdpr\Model\Entity\MetadataInterface; + use function in_array; -final class EntityProcessor implements EntityValueProcessorInterface +class EntityProcessor implements EntityValueProcessorInterface { /** * @var DocumentInterface diff --git a/Service/Export/ProcessorFactory.php b/Service/Export/ProcessorFactory.php index b0321430..8dc548ed 100644 --- a/Service/Export/ProcessorFactory.php +++ b/Service/Export/ProcessorFactory.php @@ -9,12 +9,13 @@ use InvalidArgumentException; use Magento\Framework\ObjectManagerInterface; + use function sprintf; /** * @api */ -final class ProcessorFactory +class ProcessorFactory { /** * @var string[] diff --git a/Service/Export/Renderer/CsvRenderer.php b/Service/Export/Renderer/CsvRenderer.php index 35dd8ccc..507eccfd 100644 --- a/Service/Export/Renderer/CsvRenderer.php +++ b/Service/Export/Renderer/CsvRenderer.php @@ -8,12 +8,14 @@ namespace Opengento\Gdpr\Service\Export\Renderer; use Magento\Framework\Filesystem; + use function is_array; use function rtrim; use function str_replace; + use const PHP_EOL; -final class CsvRenderer extends AbstractRenderer +class CsvRenderer extends AbstractRenderer { public function __construct( Filesystem $filesystem diff --git a/Service/Export/Renderer/HtmlRenderer.php b/Service/Export/Renderer/HtmlRenderer.php index 57c540f7..efa68031 100644 --- a/Service/Export/Renderer/HtmlRenderer.php +++ b/Service/Export/Renderer/HtmlRenderer.php @@ -20,12 +20,13 @@ use Magento\Framework\View\Page\Config; use Opengento\Gdpr\Service\Export\Renderer\HtmlRenderer\LayoutInitiatorInterface; use Opengento\Gdpr\Service\Export\Renderer\HtmlRenderer\View\RendererFactory; + use function extract; use function ob_end_clean; use function ob_get_clean; use function ob_start; -final class HtmlRenderer extends AbstractRenderer +class HtmlRenderer extends AbstractRenderer { private State $appState; diff --git a/Service/Export/Renderer/HtmlRenderer/LayoutInitiator.php b/Service/Export/Renderer/HtmlRenderer/LayoutInitiator.php index 679d4d5e..8f101265 100644 --- a/Service/Export/Renderer/HtmlRenderer/LayoutInitiator.php +++ b/Service/Export/Renderer/HtmlRenderer/LayoutInitiator.php @@ -16,9 +16,10 @@ use Magento\Framework\View\Model\Layout\Merge; use Magento\Framework\View\Page\Config; use Magento\Framework\View\Page\Layout\Reader; + use function str_replace; -final class LayoutInitiator implements LayoutInitiatorInterface +class LayoutInitiator implements LayoutInitiatorInterface { private LayoutFactory $layoutFactory; diff --git a/Service/Export/Renderer/HtmlRenderer/View/Renderer.php b/Service/Export/Renderer/HtmlRenderer/View/Renderer.php index 6ec54a30..ac7eb146 100644 --- a/Service/Export/Renderer/HtmlRenderer/View/Renderer.php +++ b/Service/Export/Renderer/HtmlRenderer/View/Renderer.php @@ -12,7 +12,9 @@ use Magento\Framework\View\Asset\GroupedCollection; use Magento\Framework\View\Asset\PropertyGroup; use Magento\Framework\View\Page\Config\Renderer as ViewRenderer; + use function sprintf; + use const PHP_EOL; class Renderer extends ViewRenderer @@ -42,7 +44,7 @@ private function inlineAsset(string $contentType, File $asset, ?string $attribut $this->addDefaultAttributes($this->getAssetContentType($asset), $attributes) ); } - + private function inlineHtml(string $contentType, File $asset, ?string $attributes): string { switch ($contentType) { diff --git a/Service/Export/Renderer/JsonRenderer.php b/Service/Export/Renderer/JsonRenderer.php index b43fde41..fd064f62 100644 --- a/Service/Export/Renderer/JsonRenderer.php +++ b/Service/Export/Renderer/JsonRenderer.php @@ -10,7 +10,7 @@ use Magento\Framework\Filesystem; use Magento\Framework\Serialize\Serializer\Json; -final class JsonRenderer extends AbstractRenderer +class JsonRenderer extends AbstractRenderer { private Json $jsonSerializer; diff --git a/Service/Export/Renderer/PdfRenderer.php b/Service/Export/Renderer/PdfRenderer.php index 1df6f631..b952d154 100644 --- a/Service/Export/Renderer/PdfRenderer.php +++ b/Service/Export/Renderer/PdfRenderer.php @@ -11,7 +11,7 @@ use Magento\Framework\Filesystem; use TCPDF; -final class PdfRenderer extends AbstractRenderer +class PdfRenderer extends AbstractRenderer { private HtmlRenderer $htmlRenderer; diff --git a/Service/Export/Renderer/XmlRenderer.php b/Service/Export/Renderer/XmlRenderer.php index cbfbd9db..855b8e7b 100644 --- a/Service/Export/Renderer/XmlRenderer.php +++ b/Service/Export/Renderer/XmlRenderer.php @@ -11,7 +11,7 @@ use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Filesystem; -final class XmlRenderer extends AbstractRenderer +class XmlRenderer extends AbstractRenderer { private const ROOT_NAME = 'data'; diff --git a/Service/Export/RendererFactory.php b/Service/Export/RendererFactory.php index a0cfaccc..ebee203d 100644 --- a/Service/Export/RendererFactory.php +++ b/Service/Export/RendererFactory.php @@ -9,12 +9,13 @@ use InvalidArgumentException; use Magento\Framework\ObjectManagerInterface; + use function sprintf; /** * @api */ -final class RendererFactory +class RendererFactory { /** * @var string[] diff --git a/ViewModel/Cookie/NoticeDataProvider.php b/ViewModel/Cookie/NoticeDataProvider.php index 5dfdb397..2994d400 100644 --- a/ViewModel/Cookie/NoticeDataProvider.php +++ b/ViewModel/Cookie/NoticeDataProvider.php @@ -10,7 +10,7 @@ use Magento\Framework\View\Element\Block\ArgumentInterface; use Opengento\Gdpr\Model\Config\PrivacyMessage; -final class NoticeDataProvider implements ArgumentInterface +class NoticeDataProvider implements ArgumentInterface { private PrivacyMessage $privacyMessage; diff --git a/ViewModel/Customer/Guest/EraseDataProvider.php b/ViewModel/Customer/Guest/EraseDataProvider.php index f15efbbd..697496de 100644 --- a/ViewModel/Customer/Guest/EraseDataProvider.php +++ b/ViewModel/Customer/Guest/EraseDataProvider.php @@ -12,7 +12,7 @@ use Magento\Sales\Api\Data\OrderInterface; use Opengento\Gdpr\Api\EraseEntityCheckerInterface; -final class EraseDataProvider implements ArgumentInterface +class EraseDataProvider implements ArgumentInterface { private EraseEntityCheckerInterface $eraseEntityChecker; diff --git a/ViewModel/Customer/Guest/ExportDataProvider.php b/ViewModel/Customer/Guest/ExportDataProvider.php index 8aa04ed5..a713a356 100644 --- a/ViewModel/Customer/Guest/ExportDataProvider.php +++ b/ViewModel/Customer/Guest/ExportDataProvider.php @@ -12,7 +12,7 @@ use Magento\Sales\Api\Data\OrderInterface; use Opengento\Gdpr\Api\ExportEntityCheckerInterface; -final class ExportDataProvider implements ArgumentInterface +class ExportDataProvider implements ArgumentInterface { private ExportEntityCheckerInterface $exportEntityChecker; diff --git a/ViewModel/Customer/Privacy/EraseCustomerDataProvider.php b/ViewModel/Customer/Privacy/EraseCustomerDataProvider.php index b6a77900..3dcb5f71 100644 --- a/ViewModel/Customer/Privacy/EraseCustomerDataProvider.php +++ b/ViewModel/Customer/Privacy/EraseCustomerDataProvider.php @@ -11,7 +11,7 @@ use Magento\Framework\View\Element\Block\ArgumentInterface; use Opengento\Gdpr\Api\EraseEntityCheckerInterface; -final class EraseCustomerDataProvider implements ArgumentInterface +class EraseCustomerDataProvider implements ArgumentInterface { private EraseEntityCheckerInterface $eraseEntityChecker; diff --git a/ViewModel/Customer/Privacy/EraseDataProvider.php b/ViewModel/Customer/Privacy/EraseDataProvider.php index 1bdcc634..e94db74e 100644 --- a/ViewModel/Customer/Privacy/EraseDataProvider.php +++ b/ViewModel/Customer/Privacy/EraseDataProvider.php @@ -13,7 +13,7 @@ use Magento\Framework\View\Element\BlockFactory; use Magento\Store\Model\ScopeInterface; -final class EraseDataProvider implements ArgumentInterface +class EraseDataProvider implements ArgumentInterface { private const CONFIG_PATH_ERASURE_INFORMATION_BLOCK = 'gdpr/erasure/block_id'; private const CONFIG_PATH_ANONYMIZE_INFORMATION_BLOCK = 'gdpr/anonymize/block_id'; diff --git a/ViewModel/Customer/Privacy/ExportCustomerDataProvider.php b/ViewModel/Customer/Privacy/ExportCustomerDataProvider.php index 4d55f526..d404e4c7 100644 --- a/ViewModel/Customer/Privacy/ExportCustomerDataProvider.php +++ b/ViewModel/Customer/Privacy/ExportCustomerDataProvider.php @@ -11,7 +11,7 @@ use Magento\Framework\View\Element\Block\ArgumentInterface; use Opengento\Gdpr\Api\ExportEntityCheckerInterface; -final class ExportCustomerDataProvider implements ArgumentInterface +class ExportCustomerDataProvider implements ArgumentInterface { private ExportEntityCheckerInterface $exportEntityChecker; diff --git a/ViewModel/Customer/Privacy/ExportDataProvider.php b/ViewModel/Customer/Privacy/ExportDataProvider.php index 37aef3f6..6bc385f7 100644 --- a/ViewModel/Customer/Privacy/ExportDataProvider.php +++ b/ViewModel/Customer/Privacy/ExportDataProvider.php @@ -13,7 +13,7 @@ use Magento\Framework\View\Element\BlockFactory; use Magento\Store\Model\ScopeInterface; -final class ExportDataProvider implements ArgumentInterface +class ExportDataProvider implements ArgumentInterface { private const CONFIG_PATH_EXPORT_INFORMATION_BLOCK = 'gdpr/export/block_id'; diff --git a/ViewModel/Customer/Privacy/SettingsDataProvider.php b/ViewModel/Customer/Privacy/SettingsDataProvider.php index eb688b77..f47b0d03 100644 --- a/ViewModel/Customer/Privacy/SettingsDataProvider.php +++ b/ViewModel/Customer/Privacy/SettingsDataProvider.php @@ -13,7 +13,7 @@ use Magento\Framework\View\Element\BlockFactory; use Magento\Store\Model\ScopeInterface; -final class SettingsDataProvider implements ArgumentInterface +class SettingsDataProvider implements ArgumentInterface { private const CONFIG_PATH_GENERAL_INFORMATION_BLOCK = 'gdpr/general/block_id'; diff --git a/etc/acl.xml b/etc/acl.xml index 48270a77..5148a191 100755 --- a/etc/acl.xml +++ b/etc/acl.xml @@ -29,11 +29,7 @@ - - - - - + diff --git a/etc/adminhtml/di.xml b/etc/adminhtml/di.xml index d6ce69ab..3a8ff3b5 100644 --- a/etc/adminhtml/di.xml +++ b/etc/adminhtml/di.xml @@ -7,46 +7,6 @@ --> - - - - - Opengento\Gdpr\Api\Data\ActionEntityInterface::MESSAGE - - - - - - - Opengento\Gdpr\Model\Action\EraseCreateExecuteAction - - - - - Opengento\Gdpr\Model\Action\EraseCreateExecuteAction - - - - - Opengento\Gdpr\Model\Action\EraseCreateExecuteAction - - - - - Opengento\Gdpr\Model\Action\ExportCreateOrExecuteAction - - - - - Opengento\Gdpr\Model\Action\ExportCreateOrExecuteAction - - - - - Opengento\Gdpr\Model\Action\ExportCreateOrExecuteAction - Opengento\Gdpr\Model\Archive\MoveToZip - - diff --git a/etc/di.xml b/etc/di.xml index 7e1a1864..78e82abe 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -1753,13 +1753,11 @@ Magento\Framework\App\State\Proxy Magento\Framework\Registry\Proxy - Opengento\Gdpr\Model\Action\EraseCreateExecuteAction Magento\Framework\App\State\Proxy - Opengento\Gdpr\Model\Action\ExportCreateOrExecuteAction diff --git a/view/adminhtml/layout/gdpr_action_new.xml b/view/adminhtml/layout/gdpr_action_new.xml deleted file mode 100644 index 99e6e74c..00000000 --- a/view/adminhtml/layout/gdpr_action_new.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - diff --git a/view/adminhtml/ui_component/gdpr_action_form.xml b/view/adminhtml/ui_component/gdpr_action_form.xml deleted file mode 100644 index 9a85c327..00000000 --- a/view/adminhtml/ui_component/gdpr_action_form.xml +++ /dev/null @@ -1,113 +0,0 @@ - - -
- - - gdpr_action_form.gdpr_action_form_data_source - - New Action - templates/form/collapsible - - - - - gdpr_action_columns gdpr_action_listing.gdpr_action_listing_data_source @@ -48,53 +41,9 @@ - - - - - editSelected - gdpr_action_listing.gdpr_action_listing.gdpr_action_columns_editor - - edit - - - - - - - Are you sure you want to delete the action log? - Delete items - - - delete - - - - - - - - - false - - action_id - true - gdpr_action_listing.gdpr_action_listing.gdpr_action_columns.ids - - - - gdpr_action_listing.gdpr_action_listing.gdpr_action_columns_editor - startEdit - - ${ $.$data.rowIndex } - true - - - - action_id @@ -157,9 +106,6 @@ text - - text - true From 3382ac9c966ac320d3a39ef9d4296d7d9a79b229 Mon Sep 17 00:00:00 2001 From: Thomas Klein Date: Thu, 27 Jun 2024 22:24:28 +0200 Subject: [PATCH 03/31] Remove abstract layer for entity actions --- Api/ActionEntityRepositoryInterface.php | 59 ------- Api/ActionInterface.php | 26 ---- Api/Data/ActionContextInterface.php | 17 -- Api/Data/ActionEntityInterface.php | 59 ------- .../ActionEntitySearchResultsInterface.php | 31 ---- Api/Data/ActionResultInterface.php | 21 --- Api/EraseSalesInformationInterface.php | 6 +- Controller/Adminhtml/Action/Index.php | 31 ---- Model/ActionEntity.php | 121 -------------- Model/ActionEntityBuilder.php | 97 ------------ Model/ActionEntityRepository.php | 126 --------------- Model/Config/PrivacyMessage.php | 72 --------- Model/Config/Source/ActionStates.php | 63 -------- .../Config/Source/VirtualEntityAttributes.php | 21 +-- Model/Erase/EraseSalesInformation.php | 27 ++-- Model/ResourceModel/ActionEntity.php | 45 ------ .../ResourceModel/ActionEntity/Collection.php | 22 --- .../ResourceModel/ActionEntity/Validator.php | 38 ----- .../ActionEntity/Validator/StateValidator.php | 49 ------ Service/Anonymize/Metadata.php | 34 ++-- Service/Erase/Metadata.php | 42 ++--- ViewModel/Cookie/NoticeDataProvider.php | 36 ----- composer.json | 5 +- etc/acl.xml | 3 - etc/adminhtml/di.xml | 7 - etc/adminhtml/menu.xml | 13 -- etc/adminhtml/routes.xml | 3 - etc/adminhtml/system.xml | 4 - etc/adminhtml/system/action.xml | 18 --- etc/adminhtml/system/cookie.xml | 40 ----- etc/config.xml | 121 +++++++++----- etc/db_schema.xml | 1 + etc/di.xml | 147 ------------------ etc/frontend/di.xml | 63 -------- view/adminhtml/layout/gdpr_action_index.xml | 15 -- .../ui_component/gdpr_action_listing.xml | 114 -------------- view/frontend/layout/default.xml | 20 --- view/frontend/templates/cookie/notices.phtml | 59 ------- 38 files changed, 123 insertions(+), 1553 deletions(-) delete mode 100644 Api/ActionEntityRepositoryInterface.php delete mode 100644 Api/ActionInterface.php delete mode 100644 Api/Data/ActionContextInterface.php delete mode 100644 Api/Data/ActionEntityInterface.php delete mode 100644 Api/Data/ActionEntitySearchResultsInterface.php delete mode 100644 Api/Data/ActionResultInterface.php delete mode 100644 Controller/Adminhtml/Action/Index.php delete mode 100644 Model/ActionEntity.php delete mode 100644 Model/ActionEntityBuilder.php delete mode 100644 Model/ActionEntityRepository.php delete mode 100644 Model/Config/PrivacyMessage.php delete mode 100644 Model/Config/Source/ActionStates.php delete mode 100755 Model/ResourceModel/ActionEntity.php delete mode 100755 Model/ResourceModel/ActionEntity/Collection.php delete mode 100644 Model/ResourceModel/ActionEntity/Validator.php delete mode 100644 Model/ResourceModel/ActionEntity/Validator/StateValidator.php delete mode 100644 ViewModel/Cookie/NoticeDataProvider.php delete mode 100644 etc/adminhtml/menu.xml delete mode 100644 etc/adminhtml/system/action.xml delete mode 100644 etc/adminhtml/system/cookie.xml delete mode 100644 view/adminhtml/layout/gdpr_action_index.xml delete mode 100644 view/adminhtml/ui_component/gdpr_action_listing.xml delete mode 100644 view/frontend/layout/default.xml delete mode 100644 view/frontend/templates/cookie/notices.phtml diff --git a/Api/ActionEntityRepositoryInterface.php b/Api/ActionEntityRepositoryInterface.php deleted file mode 100644 index 09f45125..00000000 --- a/Api/ActionEntityRepositoryInterface.php +++ /dev/null @@ -1,59 +0,0 @@ -resultFactory->create(ResultFactory::TYPE_PAGE); - $resultPage->setActiveMenu('Opengento_Gdpr::gdpr_actions'); - $resultPage->getConfig()->getTitle()->set(new Phrase('View Actions')); - $resultPage->addBreadcrumb(new Phrase('GDPR'), new Phrase('GDPR')); - $resultPage->addBreadcrumb(new Phrase('View Actions'), new Phrase('View Actions')); - - return $resultPage; - } -} diff --git a/Model/ActionEntity.php b/Model/ActionEntity.php deleted file mode 100644 index fad60f31..00000000 --- a/Model/ActionEntity.php +++ /dev/null @@ -1,121 +0,0 @@ -_eventPrefix = 'opengento_gdpr_action_entity'; - $this->_eventObject = 'action_entity'; - $this->_init(ActionEntityResource::class); - } - - public function getActionId(): int - { - return (int) $this->_getData(self::ID); - } - - public function setActionId(int $actionId): ActionEntityInterface - { - return $this->setData(self::ID, $actionId); - } - - public function getType(): string - { - return (string) $this->_getData(self::TYPE); - } - - public function setType(string $type): ActionEntityInterface - { - return $this->setData(self::TYPE, $type); - } - - public function getPerformedFrom(): string - { - return (string) $this->_getData(self::PERFORMED_FROM); - } - - public function setPerformedFrom(?string $performedFrom): ActionEntityInterface - { - return $this->setData(self::PERFORMED_FROM, $performedFrom); - } - - public function getPerformedBy(): string - { - return (string) $this->_getData(self::PERFORMED_BY); - } - - public function setPerformedBy(?string $performedBy): ActionEntityInterface - { - return $this->setData(self::PERFORMED_BY, $performedBy); - } - - /** - * @throws Exception - */ - public function getPerformedAt(): DateTime - { - return is_string($this->_getData(self::PERFORMED_AT)) - ? new DateTime($this->_getData(self::PERFORMED_AT)) - : $this->_getData(self::PERFORMED_AT); - } - - public function setPerformedAt(string $performedAt): ActionEntityInterface - { - return $this->setData(self::PERFORMED_AT, $performedAt); - } - - public function getState(): string - { - return (string) $this->_getData(self::STATE); - } - - public function setState(string $state): ActionEntityInterface - { - return $this->setData(self::STATE, $state); - } - - public function getMessage(): string - { - return (string) $this->_getData(self::MESSAGE); - } - - public function setMessage(string $message): ActionEntityInterface - { - return $this->setData(self::MESSAGE, $message); - } - - public function getParameters(): array - { - return (array) $this->_getData(self::PARAMETERS); - } - - public function setParameters(array $parameters): ActionEntityInterface - { - return $this->setData(self::PARAMETERS, $parameters); - } - - public function getResult(): array - { - return $this->_getData(self::RESULT) ?? []; - } - - public function setResult(array $result): ActionEntityInterface - { - return $this->setData(self::RESULT, $result); - } -} diff --git a/Model/ActionEntityBuilder.php b/Model/ActionEntityBuilder.php deleted file mode 100644 index af3b182c..00000000 --- a/Model/ActionEntityBuilder.php +++ /dev/null @@ -1,97 +0,0 @@ -actionEntityFactory = $actionEntityFactory; - $this->data = []; - } - - public function setType(string $type): ActionEntityBuilder - { - $this->data[ActionEntityInterface::TYPE] = $type; - - return $this; - } - - public function setPerformedFrom(string $performedFrom): ActionEntityBuilder - { - $this->data[ActionEntityInterface::PERFORMED_FROM] = $performedFrom; - - return $this; - } - - public function setPerformedBy(string $performedBy): ActionEntityBuilder - { - $this->data[ActionEntityInterface::PERFORMED_BY] = $performedBy; - - return $this; - } - - public function setPerformedAt(DateTime $performedAt): ActionEntityBuilder - { - $this->data[ActionEntityInterface::PERFORMED_AT] = $performedAt; - - return $this; - } - - public function setState(string $state): ActionEntityBuilder - { - $this->data[ActionEntityInterface::STATE] = $state; - - return $this; - } - - public function setMessage(string $message): ActionEntityBuilder - { - $this->data[ActionEntityInterface::MESSAGE] = $message; - - return $this; - } - - public function setParameters(array $parameters): ActionEntityBuilder - { - $this->data[ActionEntityInterface::PARAMETERS] = $parameters; - - return $this; - } - - public function setResult(array $result): ActionEntityBuilder - { - $this->data[ActionEntityInterface::RESULT] = $result; - - return $this; - } - - public function create(): ActionEntityInterface - { - /** @var ActionEntityInterface $actionEntity */ - $actionEntity = $this->actionEntityFactory->create(['data' => $this->data]); - $this->data = []; - - return $actionEntity; - } -} diff --git a/Model/ActionEntityRepository.php b/Model/ActionEntityRepository.php deleted file mode 100644 index 1e0767dd..00000000 --- a/Model/ActionEntityRepository.php +++ /dev/null @@ -1,126 +0,0 @@ -actionEntityResource = $actionEntityResource; - $this->actionFactory = $actionFactory; - $this->collectionFactory = $collectionFactory; - $this->collectionProcessor = $collectionProcessor; - $this->searchResultsFactory = $searchResultsFactory; - } - - public function save(ActionEntityInterface $actionEntity): ActionEntityInterface - { - try { - $this->actionEntityResource->save($actionEntity); - $this->instances[$actionEntity->getActionId()] = $actionEntity; - } catch (Exception $e) { - throw new CouldNotSaveException(new Phrase('Could not save the entity.'), $e); - } - - return $actionEntity; - } - - public function getById(int $actionId): ActionEntityInterface - { - if (!isset($this->instances[$actionId])) { - /** @var ActionEntityInterface $actionEntity */ - $actionEntity = $this->actionFactory->create(); - $this->actionEntityResource->load($actionEntity, $actionId, ActionEntityInterface::ID); - - if (!$actionEntity->getActionId()) { - throw NoSuchEntityException::singleField(ActionEntityInterface::ID, $actionId); - } - - $this->instances[$actionId] = $actionEntity; - } - - return $this->instances[$actionId]; - } - - public function getList(SearchCriteriaInterface $searchCriteria): SearchResultsInterface - { - /** @var Collection $collection */ - $collection = $this->collectionFactory->create(); - - $this->collectionProcessor->process($searchCriteria, $collection); - - /** @var ActionEntitySearchResultsInterface $searchResults */ - $searchResults = $this->searchResultsFactory->create(); - $searchResults->setSearchCriteria($searchCriteria); - $searchResults->setItems($collection->getItems()); - $searchResults->setTotalCount($collection->getSize()); - - return $searchResults; - } - - public function delete(ActionEntityInterface $actionEntity): bool - { - try { - unset($this->instances[$actionEntity->getActionId()]); - $this->actionEntityResource->delete($actionEntity); - } catch (Exception $e) { - throw new CouldNotDeleteException( - new Phrase('Could not delete entity with id "%1".', [$actionEntity->getActionId()]), - $e - ); - } - - return true; - } -} diff --git a/Model/Config/PrivacyMessage.php b/Model/Config/PrivacyMessage.php deleted file mode 100644 index 82c26e4f..00000000 --- a/Model/Config/PrivacyMessage.php +++ /dev/null @@ -1,72 +0,0 @@ -scopeConfig = $scopeConfig; - $this->blockFactory = $blockFactory; - $this->helperPage = $helperPage; - } - - public function isEnabled(): bool - { - return $this->scopeConfig->isSetFlag(self::CONFIG_PATH_COOKIE_INFORMATION_ENABLED, ScopeInterface::SCOPE_STORE); - } - - public function getDisclosureInformationHtml(): string - { - return $this->blockHtml ??= $this->createDisclosureInformationBlockHtml(); - } - - public function getLearnMoreUrl(): ?string - { - return $this->helperPage->getPageUrl((string) $this->scopeConfig->getValue( - self::CONFIG_PATH_COOKIE_INFORMATION_PAGE, - ScopeInterface::SCOPE_STORE - )); - } - - private function createDisclosureInformationBlockHtml(): string - { - return $this->blockFactory->createBlock( - BlockByIdentifier::class, - [ - 'data' => [ - 'identifier' => (string) $this->scopeConfig->getValue( - self::CONFIG_PATH_COOKIE_INFORMATION_BLOCK, - ScopeInterface::SCOPE_STORE - ), - ], - ] - )->toHtml(); - } -} diff --git a/Model/Config/Source/ActionStates.php b/Model/Config/Source/ActionStates.php deleted file mode 100644 index 20730ff0..00000000 --- a/Model/Config/Source/ActionStates.php +++ /dev/null @@ -1,63 +0,0 @@ -additionalOptions = $additionalOptions; - $this->options = []; - $this->optionArray = []; - } - - public function toOptionArray(): array - { - if (!$this->optionArray) { - foreach ($this->loadOptions() as $value => $label) { - $this->optionArray[] = compact('value', 'label'); - } - } - - return $this->optionArray; - } - - public function getOptionText(string $state): ?string - { - return isset($this->loadOptions()[$state]) ? (string) $this->loadOptions()[$state] : null; - } - - private function loadOptions(): array - { - if (!$this->options) { - $this->options = array_merge( - [ - ActionEntityInterface::STATE_SUCCEEDED => new Phrase('Succeeded'), - ActionEntityInterface::STATE_FAILED => new Phrase('Failed'), - ], - $this->additionalOptions - ); - } - - return $this->options; - } -} diff --git a/Model/Config/Source/VirtualEntityAttributes.php b/Model/Config/Source/VirtualEntityAttributes.php index 1b1c9e2f..de584f7d 100644 --- a/Model/Config/Source/VirtualEntityAttributes.php +++ b/Model/Config/Source/VirtualEntityAttributes.php @@ -19,27 +19,16 @@ */ class VirtualEntityAttributes implements OptionSourceInterface { - /** - * @var AttributeProviderInterface - */ - private AttributeProviderInterface $attributeProvider; - - private string $entityType; - - private array $options; + private ?array $options = null; public function __construct( - AttributeProviderInterface $attributeProvider, - string $entityType - ) { - $this->attributeProvider = $attributeProvider; - $this->entityType = $entityType; - $this->options = []; - } + private AttributeProviderInterface $attributeProvider, + private string $entityType + ) {} public function toOptionArray(): array { - if (!$this->options) { + if ($this->options === null) { foreach (array_keys($this->attributeProvider->getAttributes($this->entityType)) as $attribute) { $this->options[] = ['value' => $attribute, 'label' => $attribute]; } diff --git a/Model/Erase/EraseSalesInformation.php b/Model/Erase/EraseSalesInformation.php index b5090738..dd2b1d53 100644 --- a/Model/Erase/EraseSalesInformation.php +++ b/Model/Erase/EraseSalesInformation.php @@ -8,6 +8,7 @@ namespace Opengento\Gdpr\Model\Erase; use DateTimeImmutable; +use DateTimeInterface; use Exception; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\Exception\CouldNotSaveException; @@ -22,29 +23,19 @@ class EraseSalesInformation implements EraseSalesInformationInterface { private const CONFIG_PATH_ERASURE_SALES_MAX_AGE = 'gdpr/erasure/sales_max_age'; - private EraseEntityInterfaceFactory $eraseEntityFactory; - - private EraseEntityRepositoryInterface $eraseRepository; - - private ScopeConfigInterface $scopeConfig; - public function __construct( - EraseEntityInterfaceFactory $eraseEntityFactory, - EraseEntityRepositoryInterface $eraseRepository, - ScopeConfigInterface $scopeConfig - ) { - $this->eraseEntityFactory = $eraseEntityFactory; - $this->eraseRepository = $eraseRepository; - $this->scopeConfig = $scopeConfig; - } + private EraseEntityInterfaceFactory $eraseEntityFactory, + private EraseEntityRepositoryInterface $eraseRepository, + private ScopeConfigInterface $scopeConfig + ) {} /** * @inheritdoc * @throws CouldNotSaveException */ - public function scheduleEraseEntity(int $entityId, string $entityType, \DateTime $lastActive): EraseEntityInterface + public function scheduleEraseEntity(int $entityId, string $entityType, DateTimeInterface $lastActive): EraseEntityInterface { - $dateTime = DateTimeImmutable::createFromMutable($lastActive); + $dateTime = DateTimeImmutable::createFromInterface($lastActive); $scheduleAt = $dateTime->modify('+' . $this->resolveErasureSalesMaxAge() . ' days'); /** @var EraseEntityInterface $eraseEntity */ @@ -64,9 +55,9 @@ public function scheduleEraseEntity(int $entityId, string $entityType, \DateTime * @inheritdoc * @throws Exception */ - public function isAlive(\DateTime $dateTime): bool + public function isAlive(DateTimeInterface $lastActive): bool { - return $dateTime > new \DateTime('-' . $this->resolveErasureSalesMaxAge() . 'days'); + return $lastActive > new \DateTime('-' . $this->resolveErasureSalesMaxAge() . 'days'); } private function resolveErasureSalesMaxAge(): int diff --git a/Model/ResourceModel/ActionEntity.php b/Model/ResourceModel/ActionEntity.php deleted file mode 100755 index 647893a1..00000000 --- a/Model/ResourceModel/ActionEntity.php +++ /dev/null @@ -1,45 +0,0 @@ -validator = $validator; - parent::__construct($context, $entitySnapshot, $relationComposite, $connectionName); - } - - protected function _construct(): void - { - $this->_init(self::TABLE, ActionEntityInterface::ID); - $this->_serializableFields = [ActionEntityInterface::PARAMETERS => [[], []]]; - } - - public function getValidationRulesBeforeSave(): ValidatorInterface - { - return $this->validator; - } -} diff --git a/Model/ResourceModel/ActionEntity/Collection.php b/Model/ResourceModel/ActionEntity/Collection.php deleted file mode 100755 index 5e118b0d..00000000 --- a/Model/ResourceModel/ActionEntity/Collection.php +++ /dev/null @@ -1,22 +0,0 @@ -_init(ActionEntity::class, ActionEntityResourceModel::class); - $this->_setIdFieldName(ActionEntityInterface::ID); - } -} diff --git a/Model/ResourceModel/ActionEntity/Validator.php b/Model/ResourceModel/ActionEntity/Validator.php deleted file mode 100644 index 6d5473d3..00000000 --- a/Model/ResourceModel/ActionEntity/Validator.php +++ /dev/null @@ -1,38 +0,0 @@ -validators = $validators; - } - - public function isValid($value): bool - { - $this->_clearMessages(); - - foreach ($this->validators as $validator) { - if (!$validator->isValid($value)) { - $this->_addMessages($validator->getMessages()); - } - } - - return !$this->hasMessages(); - } -} diff --git a/Model/ResourceModel/ActionEntity/Validator/StateValidator.php b/Model/ResourceModel/ActionEntity/Validator/StateValidator.php deleted file mode 100644 index 23d529bf..00000000 --- a/Model/ResourceModel/ActionEntity/Validator/StateValidator.php +++ /dev/null @@ -1,49 +0,0 @@ -actionStates = $actionStates; - } - - /** - * @param ActionEntityInterface $actionEntity - * @return bool - */ - public function isValid($actionEntity): bool - { - $this->_clearMessages(); - $isValid = in_array( - $actionEntity->getState(), - array_column($this->actionStates->toOptionArray(), 'value'), - true - ); - - if (!$isValid) { - $this->_addMessages([ - 'state' => new Phrase('State "%1" does not exists.', [$actionEntity->getState()]) - ]); - } - - return $isValid; - } -} diff --git a/Service/Anonymize/Metadata.php b/Service/Anonymize/Metadata.php index aeaba703..4720a1ea 100644 --- a/Service/Anonymize/Metadata.php +++ b/Service/Anonymize/Metadata.php @@ -13,45 +13,31 @@ use function array_column; use function array_combine; use function array_keys; +use function is_array; class Metadata implements MetadataInterface { - private ScopeConfigInterface $scopeConfig; - - /** - * @var SerializerInterface - */ - private SerializerInterface $serializer; - - private string $configPath; - - private string $scopeType; - /** * @var string[][] */ private array $cache; public function __construct( - ScopeConfigInterface $scopeConfig, - SerializerInterface $serializer, - string $configPath, - string $scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT - ) { - $this->scopeConfig = $scopeConfig; - $this->serializer = $serializer; - $this->configPath = $configPath; - $this->scopeType = $scopeType; - } + private ScopeConfigInterface $scopeConfig, + private SerializerInterface $serializer, + private string $configPath, + private string $scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT + ) {} public function getAnonymizerStrategiesByAttributes(?string $scopeCode = null): array { $scope = $scopeCode ?? 'current_scope'; if (!isset($this->cache[$scope])) { - $metadata = $this->serializer->unserialize( - $this->scopeConfig->getValue($this->configPath, $this->scopeType, $scopeCode) ?? '{}' - ); + $metadata = $this->scopeConfig->getValue($this->configPath, $this->scopeType, $scopeCode); + if (!is_array($metadata)) { + $metadata = $this->serializer->unserialize($metadata ?? '{}'); + } $this->cache[$scope] = array_combine( array_column($metadata, 'attribute'), diff --git a/Service/Erase/Metadata.php b/Service/Erase/Metadata.php index e0643581..44c833a1 100644 --- a/Service/Erase/Metadata.php +++ b/Service/Erase/Metadata.php @@ -17,42 +17,27 @@ class Metadata implements MetadataInterface { - private ScopeConfigInterface $scopeConfig; - - /** - * @var SerializerInterface - */ - private SerializerInterface $serializer; - - private string $configPath; - - private string $scopeType; - /** * @var string[][] */ private array $cache; public function __construct( - ScopeConfigInterface $scopeConfig, - SerializerInterface $serializer, - string $configPath, - string $scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT - ) { - $this->scopeConfig = $scopeConfig; - $this->serializer = $serializer; - $this->configPath = $configPath; - $this->scopeType = $scopeType; - } + private ScopeConfigInterface $scopeConfig, + private SerializerInterface $serializer, + private string $configPath, + private string $scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT + ) {} public function getComponentsProcessors(?string $scopeCode = null): array { $scope = $scopeCode ?? 'current_scope'; if (!isset($this->cache[$scope])) { - $metadata = $this->serializer->unserialize( - $this->scopeConfig->getValue($this->configPath, $this->scopeType, $scopeCode) ?? '{}' - ); + $metadata = $this->scopeConfig->getValue($this->configPath, $this->scopeType, $scopeCode); + if (!is_array($metadata)) { + $metadata = $this->serializer->unserialize($metadata ?? '{}'); + } $this->cache[$scope] = array_combine( array_column($metadata, 'component'), @@ -68,14 +53,9 @@ public function getComponentsProcessors(?string $scopeCode = null): array */ public function getComponentProcessor(string $component, ?string $scopeCode = null): string { - $componentsProcessors = $this->getComponentsProcessors($scopeCode); - - if (!isset($componentsProcessors[$component])) { - throw new InvalidArgumentException( + return $this->getComponentsProcessors($scopeCode)[$component] + ?? throw new InvalidArgumentException( sprintf('There is no erasure processor registered for the component "%s".', $component) ); - } - - return $componentsProcessors[$component]; } } diff --git a/ViewModel/Cookie/NoticeDataProvider.php b/ViewModel/Cookie/NoticeDataProvider.php deleted file mode 100644 index 2994d400..00000000 --- a/ViewModel/Cookie/NoticeDataProvider.php +++ /dev/null @@ -1,36 +0,0 @@ -privacyMessage = $privacyMessage; - } - - public function getTemplate(string $defaultTemplate, string $customTemplate): string - { - return $this->privacyMessage->isEnabled() ? $customTemplate : $defaultTemplate; - } - - public function getLearnMoreUrl(): ?string - { - return $this->privacyMessage->getLearnMoreUrl(); - } - - public function getNoticeHtml(): string - { - return $this->privacyMessage->getDisclosureInformationHtml(); - } -} diff --git a/composer.json b/composer.json index 87113612..f3dd66f8 100755 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "privacy" ], "require": { - "php": "^7.4||^8.0", + "php": "^8.2", "ext-zip": "*", "tecnickcom/tcpdf": "^6.4", "magento/framework": "^103.0", @@ -28,8 +28,7 @@ }, "require-dev": { "magento/magento-coding-standard": "^5", - "magento/marketplace-eqp": "^4.0", - "roave/security-advisories": "dev-master" + "magento/marketplace-eqp": "^4.0" }, "type": "magento2-module", "license": [ diff --git a/etc/acl.xml b/etc/acl.xml index 5148a191..d657f60c 100755 --- a/etc/acl.xml +++ b/etc/acl.xml @@ -28,9 +28,6 @@
- - - diff --git a/etc/adminhtml/di.xml b/etc/adminhtml/di.xml index 3a8ff3b5..6f51b268 100644 --- a/etc/adminhtml/di.xml +++ b/etc/adminhtml/di.xml @@ -6,14 +6,7 @@ */ --> - - - - Opengento\Gdpr\Model\Action\ActionFactory - actions - - Magento\Framework\Model\EntitySnapshot\AttributeProvider diff --git a/etc/adminhtml/menu.xml b/etc/adminhtml/menu.xml deleted file mode 100644 index 5ae370ed..00000000 --- a/etc/adminhtml/menu.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - diff --git a/etc/adminhtml/routes.xml b/etc/adminhtml/routes.xml index f8bb8ba8..81c6c761 100644 --- a/etc/adminhtml/routes.xml +++ b/etc/adminhtml/routes.xml @@ -7,9 +7,6 @@ --> - - - diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 0f697234..e40310e8 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -12,15 +12,11 @@ - - - - diff --git a/etc/adminhtml/system/action.xml b/etc/adminhtml/system/action.xml deleted file mode 100644 index 4a847710..00000000 --- a/etc/adminhtml/system/action.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - -
- separator-top - - opengento_gdpr - Opengento_Gdpr::config - - - -
-
diff --git a/etc/adminhtml/system/cookie.xml b/etc/adminhtml/system/cookie.xml deleted file mode 100644 index 0e2b4065..00000000 --- a/etc/adminhtml/system/cookie.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - diff --git a/etc/config.xml b/etc/config.xml index b03705ce..66748f15 100755 --- a/etc/config.xml +++ b/etc/config.xml @@ -16,17 +16,42 @@ - + + email + email + + + prefix + alphaUpper + + + firstname + anonymous + + + middlename + anonymous + + + lastname + anonymous + + + suffix + alphaUpper + + + dob + date + + + gender + number + + + taxvat + alphaUpper + - + + email + email + @@ -129,20 +155,40 @@ canceled,closed,complete 1 - + + customer + anonymize + + + customer_address + anonymize + + + quote + delete + + + order + anonymize + + + subscriber + delete + - + + quote + delete + + + order + anonymize + + + subscriber + delete + @@ -167,13 +213,13 @@ - 0 + 1 general bcc - 0 + 1 general bcc @@ -181,13 +227,13 @@ - 0 + 1 general bcc - 0 + 1 general bcc @@ -195,13 +241,13 @@ - 0 + 1 general bcc - 0 + 1 general bcc @@ -211,13 +257,13 @@ - 0 + 1 general bcc - 0 + 1 general bcc @@ -225,13 +271,13 @@ - 0 + 1 general bcc - 0 + 1 general bcc @@ -239,9 +285,6 @@ - - 0 -
diff --git a/etc/db_schema.xml b/etc/db_schema.xml index b2c891ad..b80e24a5 100644 --- a/etc/db_schema.xml +++ b/etc/db_schema.xml @@ -6,6 +6,7 @@ */ --> + diff --git a/etc/di.xml b/etc/di.xml index 78e82abe..9ed029b7 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -6,20 +6,6 @@ */ --> - - - - - - - - - - - Opengento\Gdpr\Model\ResourceModel\ActionEntity\Validator\StateValidator - - - @@ -42,7 +28,6 @@ - Opengento\Gdpr\Api\ActionEntityRepositoryInterface Opengento\Gdpr\Api\EraseEntityRepositoryInterface Opengento\Gdpr\Api\ExportEntityRepositoryInterface @@ -51,7 +36,6 @@ - Magento\Framework\EntityManager\AbstractModelHydrator Magento\Framework\EntityManager\AbstractModelHydrator Magento\Framework\EntityManager\AbstractModelHydrator Magento\Framework\EntityManager\AbstractModelHydrator @@ -63,122 +47,6 @@ - - - - - Opengento\Gdpr\Model\Customer\Erase\Notifier\Pending - Opengento\Gdpr\Model\Order\Erase\Notifier\Pending - - - - - - - Opengento\Gdpr\Model\Customer\Erase\Notifier\Succeeded - Opengento\Gdpr\Model\Order\Erase\Notifier\Succeeded - - - - - - - Opengento\Gdpr\Model\Customer\Erase\Notifier\Canceled - Opengento\Gdpr\Model\Order\Erase\Notifier\Canceled - - - - - - - - Opengento\Gdpr\Model\Customer\Export\Notifier\Pending - Opengento\Gdpr\Model\Order\Export\Notifier\Pending - - - - - - - Opengento\Gdpr\Model\Customer\Export\Notifier\Ready - Opengento\Gdpr\Model\Order\Export\Notifier\Ready - - - - - - - - Opengento\Gdpr\Model\Action\EraseCreateAction - Opengento\Gdpr\Model\Action\EraseExecuteAction - Opengento\Gdpr\Model\Action\EraseCancelAction - Opengento\Gdpr\Model\Action\EraseCreateExecuteAction - Opengento\Gdpr\Model\Action\ExportCreateAction - Opengento\Gdpr\Model\Action\ExportExecuteAction - Opengento\Gdpr\Model\Action\ExportCreateOrExecuteAction - - - - - - erase_create - - Opengento\Gdpr\Model\Action\Erase\CreateAction - Opengento\Gdpr\Model\Action\Erase\CreateNotifier - - - - - - erase_execute - - Opengento\Gdpr\Model\Action\Erase\ExecuteAction - Opengento\Gdpr\Model\Action\Erase\ExecuteNotifier - - - - - - erase_cancel - - Opengento\Gdpr\Model\Action\Erase\CancelAction - Opengento\Gdpr\Model\Action\Erase\CancelNotifier - - - - - - erase_create_execute - - Opengento\Gdpr\Model\Action\Erase\CreateAction - Opengento\Gdpr\Model\Action\Erase\ExecuteAction - - - - - - export_create - - Opengento\Gdpr\Model\Action\Export\CreateAction - - - - - - export_execute - - Opengento\Gdpr\Model\Action\Export\ExportAction - - - - - - export_create_or_execute - - Opengento\Gdpr\Model\Action\Export\CreateOrExportAction - - - @@ -1733,21 +1601,6 @@ - - - - opengento_gdpr_action_entity - Opengento\Gdpr\Model\ResourceModel\ActionEntity - - - - - - Opengento\Gdpr\Model\ResourceModel\ActionEntity\SearchResult - Opengento\Gdpr\Model\ResourceModel\ActionEntity\SearchResult - - - diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml index defe7395..edf7003a 100644 --- a/etc/frontend/di.xml +++ b/etc/frontend/di.xml @@ -6,73 +6,10 @@ */ --> - - - - Opengento\Gdpr\Model\Action\Export\CreateAction - Opengento\Gdpr\Model\Action\Export\CreateNotifier - - - - - - - Opengento\Gdpr\Model\Action\Export\ExportAction - Opengento\Gdpr\Model\Action\Export\ExportNotifier - - - - - - - Opengento\Gdpr\Model\Action\Export\CreateOrExportAction - Opengento\Gdpr\Model\Action\Export\ExportNotifier - - - - - - - Opengento\Gdpr\Model\Action\PerformedBy\Guest - Opengento\Gdpr\Model\Action\PerformedBy\Customer - - - - Magento\Sales\Controller\Guest\OrderLoader - - - Opengento\Gdpr\Model\Action\EraseCreateAction - - - - - Opengento\Gdpr\Model\Action\EraseCreateAction - - - - - Opengento\Gdpr\Model\Action\EraseCancelAction - - - - - Opengento\Gdpr\Model\Action\EraseCancelAction - - - - - Opengento\Gdpr\Model\Action\ExportCreateAction - - - - - Opengento\Gdpr\Model\Action\ExportCreateAction - - diff --git a/view/adminhtml/layout/gdpr_action_index.xml b/view/adminhtml/layout/gdpr_action_index.xml deleted file mode 100644 index f8303a82..00000000 --- a/view/adminhtml/layout/gdpr_action_index.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - diff --git a/view/adminhtml/ui_component/gdpr_action_listing.xml b/view/adminhtml/ui_component/gdpr_action_listing.xml deleted file mode 100644 index e0388023..00000000 --- a/view/adminhtml/ui_component/gdpr_action_listing.xml +++ /dev/null @@ -1,114 +0,0 @@ - - -- - - gdpr_action_listing.gdpr_action_listing_data_source - - - - gdpr_action_columns - - gdpr_action_listing.gdpr_action_listing_data_source - - - - - - action_id - - - - Opengento_Gdpr::gdpr_actions - - - id - action_id - - - - - - true - - - - - - - - - - - - action_id - - - - - textRange - - asc - - - - - text - - true - - - - - text - - true - - - - - text - - true - - - - - dateRange - date - - true - - - - - - select - select - - - - - - text - - text - - - true - - - - - text - - true - - - - diff --git a/view/frontend/layout/default.xml b/view/frontend/layout/default.xml deleted file mode 100644 index 1ba1a722..00000000 --- a/view/frontend/layout/default.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - Magento_Cookie::html/notices.phtml - Opengento_Gdpr::cookie/notices.phtml - - Opengento\Gdpr\ViewModel\Cookie\NoticeDataProvider - - - - diff --git a/view/frontend/templates/cookie/notices.phtml b/view/frontend/templates/cookie/notices.phtml deleted file mode 100644 index 1149bd6d..00000000 --- a/view/frontend/templates/cookie/notices.phtml +++ /dev/null @@ -1,59 +0,0 @@ -getData('cookieHelper'); -/** @var NoticeDataProvider $noticeDataProvider */ -$noticeDataProvider = $block->getData('noticeDataProvider'); - -$learnMoreUrl = $noticeDataProvider->getLearnMoreUrl() ?: $block->getPrivacyPolicyLink() -?> -isCookieRestrictionModeEnabled()): ?> - - renderStyleAsTag('display: none;', 'div#notice-cookie-block') ?> - - From c64cd7b49893a8eec8c5c75ca2ec2f90d71422fa Mon Sep 17 00:00:00 2001 From: Thomas Klein Date: Thu, 27 Jun 2024 22:25:11 +0200 Subject: [PATCH 04/31] Fix #143 - Ignore customer validation --- .../CustomerAddressDataProcessor.php | 28 +++------ .../Processor/CustomerDataProcessor.php | 63 +++++-------------- 2 files changed, 26 insertions(+), 65 deletions(-) diff --git a/Model/Customer/Anonymize/Processor/CustomerAddressDataProcessor.php b/Model/Customer/Anonymize/Processor/CustomerAddressDataProcessor.php index 22cfc2f6..9937323a 100644 --- a/Model/Customer/Anonymize/Processor/CustomerAddressDataProcessor.php +++ b/Model/Customer/Anonymize/Processor/CustomerAddressDataProcessor.php @@ -9,30 +9,18 @@ use Magento\Customer\Api\AddressRepositoryInterface; use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Framework\DataObject; use Magento\Framework\Exception\LocalizedException; use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; class CustomerAddressDataProcessor implements ProcessorInterface { - private AnonymizerInterface $anonymizer; - - /** - * @var AddressRepositoryInterface - */ - private AddressRepositoryInterface $addressRepository; - - private SearchCriteriaBuilder $criteriaBuilder; - public function __construct( - AnonymizerInterface $anonymizer, - AddressRepositoryInterface $addressRepository, - SearchCriteriaBuilder $criteriaBuilder - ) { - $this->anonymizer = $anonymizer; - $this->addressRepository = $addressRepository; - $this->criteriaBuilder = $criteriaBuilder; - } + private AnonymizerInterface $anonymizer, + private AddressRepositoryInterface $addressRepository, + private SearchCriteriaBuilder $criteriaBuilder + ) {} /** * @inheritdoc @@ -44,7 +32,11 @@ public function execute(int $customerId): bool $addressList = $this->addressRepository->getList($this->criteriaBuilder->create()); foreach ($addressList->getItems() as $address) { - $this->addressRepository->save($this->anonymizer->anonymize($address)); + $address = $this->anonymizer->anonymize($address); + if ($address instanceof DataObject) { + $address->setData('should_ignore_validation', true); + } + $this->addressRepository->save($address); } return true; diff --git a/Model/Customer/Anonymize/Processor/CustomerDataProcessor.php b/Model/Customer/Anonymize/Processor/CustomerDataProcessor.php index e07a874c..5160c288 100644 --- a/Model/Customer/Anonymize/Processor/CustomerDataProcessor.php +++ b/Model/Customer/Anonymize/Processor/CustomerDataProcessor.php @@ -14,6 +14,7 @@ use Magento\Customer\Model\CustomerRegistry; use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\DataObject; use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Exception\NoSuchEntityException; @@ -37,53 +38,16 @@ class CustomerDataProcessor implements ProcessorInterface { private const CONFIG_PATH_ERASURE_REMOVE_CUSTOMER = 'gdpr/erasure/remove_customer'; - private AnonymizerInterface $anonymizer; - - /** - * @var CustomerRepositoryInterface - */ - private CustomerRepositoryInterface $customerRepository; - - private OrderRepositoryInterface $orderRepository; - - private SearchCriteriaBuilder $criteriaBuilder; - - /** - * @var CustomerRegistry - */ - private CustomerRegistry $customerRegistry; - - /** - * @var OrigDataRegistry - */ - private OrigDataRegistry $origDataRegistry; - - /** - * @var SessionCleanerInterface - */ - private SessionCleanerInterface $sessionCleaner; - - private ScopeConfigInterface $scopeConfig; - public function __construct( - AnonymizerInterface $anonymizer, - CustomerRepositoryInterface $customerRepository, - OrderRepositoryInterface $orderRepository, - SearchCriteriaBuilder $criteriaBuilder, - CustomerRegistry $customerRegistry, - OrigDataRegistry $origDataRegistry, - SessionCleanerInterface $sessionCleaner, - ScopeConfigInterface $scopeConfig - ) { - $this->anonymizer = $anonymizer; - $this->customerRepository = $customerRepository; - $this->orderRepository = $orderRepository; - $this->criteriaBuilder = $criteriaBuilder; - $this->customerRegistry = $customerRegistry; - $this->origDataRegistry = $origDataRegistry; - $this->sessionCleaner = $sessionCleaner; - $this->scopeConfig = $scopeConfig; - } + private AnonymizerInterface $anonymizer, + private CustomerRepositoryInterface $customerRepository, + private OrderRepositoryInterface $orderRepository, + private SearchCriteriaBuilder $criteriaBuilder, + private CustomerRegistry $customerRegistry, + private OrigDataRegistry $origDataRegistry, + private SessionCleanerInterface $sessionCleaner, + private ScopeConfigInterface $scopeConfig + ) {} /** * @inheritdoc @@ -144,7 +108,12 @@ private function anonymizeCustomer(CustomerInterface $customer): void $secureData->setData('lock_expires', $dateTime->format(DateTimeFormat::DATETIME_PHP_FORMAT)); $secureData->setPasswordHash(sha1(uniqid((string) mt_rand(), true))); - $this->customerRepository->save($this->anonymizer->anonymize($customer)); + $customer = $this->anonymizer->anonymize($customer); + if ($customer instanceof DataObject) { + $customer->setData('ignore_validation_flag', true); + } + + $this->customerRepository->save($customer); } private function shouldRemoveCustomerWithoutOrders(): bool From 9350f2f6eeead4214edfad07614205bec405ea47 Mon Sep 17 00:00:00 2001 From: Thomas Klein Date: Thu, 27 Jun 2024 22:43:35 +0200 Subject: [PATCH 05/31] sugar syntax --- .../Form/Field/Select/OptionSourceSelect.php | 8 +--- Block/Adminhtml/Customer/Edit/EraseButton.php | 10 +---- .../Adminhtml/Customer/Edit/ExportButton.php | 5 +-- Block/Adminhtml/Order/Edit/EraseButton.php | 7 +--- Block/Adminhtml/Order/Edit/ExportButton.php | 2 +- Controller/Privacy/Erase.php | 2 +- Cron/EraseEntityScheduler.php | 2 +- Model/Config.php | 2 +- .../Processor/CustomerDataProcessor.php | 2 +- .../Processor/OrderDataProcessor.php | 2 +- Model/Customer/CustomerChecker.php | 38 ++++--------------- .../Delete/Processor/OrderDataProcessor.php | 2 +- Model/Customer/Notifier/MailSender.php | 2 +- Model/Customer/OrigDataRegistry.php | 2 +- Model/Erase/EraseEntityScheduler.php | 2 +- Model/Erase/EraseSalesInformation.php | 2 +- Model/EraseEntity.php | 16 ++++---- Model/EraseEntityChecker.php | 2 +- Model/EraseEntityManagement.php | 2 +- Model/Export/ExportToFile.php | 2 +- Model/ExportEntity.php | 16 ++++---- Model/ExportEntityChecker.php | 2 +- Model/ExportEntityManagement.php | 4 +- Model/Notifier/AbstractMailSender.php | 6 +-- .../Processor/OrderDataProcessor.php | 2 +- .../Delete/Processor/OrderDataProcessor.php | 2 +- .../Processor/SubscriberDataProcessor.php | 2 +- Model/Order/Notifier/MailSender.php | 2 +- Model/Order/OrderChecker.php | 13 ++----- Observer/DeleteExport.php | 2 +- Observer/InvalidateExport.php | 2 +- .../Customer/Guest/EraseDataProvider.php | 2 +- .../Customer/Guest/ExportDataProvider.php | 2 +- .../Privacy/EraseCustomerDataProvider.php | 2 +- .../Customer/Privacy/EraseDataProvider.php | 4 +- .../Privacy/ExportCustomerDataProvider.php | 2 +- .../Customer/Privacy/ExportDataProvider.php | 2 +- .../Customer/Privacy/SettingsDataProvider.php | 2 +- .../templates/export/renderer/default.phtml | 2 +- 39 files changed, 68 insertions(+), 115 deletions(-) diff --git a/Block/Adminhtml/Config/Form/Field/Select/OptionSourceSelect.php b/Block/Adminhtml/Config/Form/Field/Select/OptionSourceSelect.php index f2297087..7026c5c9 100644 --- a/Block/Adminhtml/Config/Form/Field/Select/OptionSourceSelect.php +++ b/Block/Adminhtml/Config/Form/Field/Select/OptionSourceSelect.php @@ -13,17 +13,11 @@ class OptionSourceSelect extends Select { - /** - * @var OptionSourceInterface - */ - private OptionSourceInterface $optionSource; - public function __construct( Context $context, - OptionSourceInterface $optionSource, + private OptionSourceInterface $optionSource, array $data = [] ) { - $this->optionSource = $optionSource; parent::__construct($context, $data); } diff --git a/Block/Adminhtml/Customer/Edit/EraseButton.php b/Block/Adminhtml/Customer/Edit/EraseButton.php index fb8e6362..f0c9e82c 100644 --- a/Block/Adminhtml/Customer/Edit/EraseButton.php +++ b/Block/Adminhtml/Customer/Edit/EraseButton.php @@ -17,18 +17,12 @@ class EraseButton extends GenericButton implements ButtonProviderInterface { - private EraseEntityCheckerInterface $eraseCustomerChecker; - - private Config $config; - public function __construct( Context $context, Registry $registry, - EraseEntityCheckerInterface $eraseCustomerChecker, - Config $config + private EraseEntityCheckerInterface $eraseCustomerChecker, + private Config $config ) { - $this->eraseCustomerChecker = $eraseCustomerChecker; - $this->config = $config; parent::__construct($context, $registry); } diff --git a/Block/Adminhtml/Customer/Edit/ExportButton.php b/Block/Adminhtml/Customer/Edit/ExportButton.php index ca16fad4..7eb5602e 100644 --- a/Block/Adminhtml/Customer/Edit/ExportButton.php +++ b/Block/Adminhtml/Customer/Edit/ExportButton.php @@ -16,14 +16,11 @@ class ExportButton extends GenericButton implements ButtonProviderInterface { - private Config $config; - public function __construct( Context $context, Registry $registry, - Config $config + private Config $config ) { - $this->config = $config; parent::__construct($context, $registry); } diff --git a/Block/Adminhtml/Order/Edit/EraseButton.php b/Block/Adminhtml/Order/Edit/EraseButton.php index 4bdf523b..66b020ba 100644 --- a/Block/Adminhtml/Order/Edit/EraseButton.php +++ b/Block/Adminhtml/Order/Edit/EraseButton.php @@ -16,14 +16,11 @@ class EraseButton extends AbstractBlock { - private EraseEntityCheckerInterface $eraseEntityChecker; - public function __construct( Context $context, - EraseEntityCheckerInterface $eraseEntityChecker, + private EraseEntityCheckerInterface $eraseEntityChecker, array $data = [] ) { - $this->eraseEntityChecker = $eraseEntityChecker; parent::__construct($context, $data); } @@ -37,7 +34,7 @@ protected function _construct(): void /** @var View $orderView */ $orderView = $this->getLayout()->getBlock('sales_order_edit'); - $orderId = (int) $orderView->getOrderId(); + $orderId = (int)$orderView->getOrderId(); if ($this->_authorization->isAllowed('Opengento_Gdpr::order_erase') && $this->eraseEntityChecker->canCreate($orderId, 'order') diff --git a/Block/Adminhtml/Order/Edit/ExportButton.php b/Block/Adminhtml/Order/Edit/ExportButton.php index 5a546ecb..57c4f257 100644 --- a/Block/Adminhtml/Order/Edit/ExportButton.php +++ b/Block/Adminhtml/Order/Edit/ExportButton.php @@ -24,7 +24,7 @@ protected function _construct(): void /** @var View $orderView */ $orderView = $this->getLayout()->getBlock('sales_order_edit'); - $orderId = (int) $orderView->getOrderId(); + $orderId = (int)$orderView->getOrderId(); if ($this->_authorization->isAllowed('Opengento_Gdpr::order_export')) { $orderView->addButton( diff --git a/Controller/Privacy/Erase.php b/Controller/Privacy/Erase.php index 3ad59c4a..05b93845 100755 --- a/Controller/Privacy/Erase.php +++ b/Controller/Privacy/Erase.php @@ -41,7 +41,7 @@ protected function isAllowed(): bool protected function executeAction(): Page|Redirect { - if ($this->eraseCustomerChecker->exists((int) $this->customerSession->getCustomerId(), 'customer')) { + if ($this->eraseCustomerChecker->exists((int)$this->customerSession->getCustomerId(), 'customer')) { $this->messageManager->addErrorMessage(new Phrase('Your account is already being removed.')); /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); diff --git a/Cron/EraseEntityScheduler.php b/Cron/EraseEntityScheduler.php index 2a4cbefb..4221430e 100644 --- a/Cron/EraseEntityScheduler.php +++ b/Cron/EraseEntityScheduler.php @@ -83,6 +83,6 @@ private function scheduleEntitiesErasure(): void private function resolveErasureMaxAge(): int { - return (int) $this->scopeConfig->getValue(self::CONFIG_PATH_ERASURE_MAX_AGE, ScopeInterface::SCOPE_STORE); + return (int)$this->scopeConfig->getValue(self::CONFIG_PATH_ERASURE_MAX_AGE, ScopeInterface::SCOPE_STORE); } } diff --git a/Model/Config.php b/Model/Config.php index e8627ea8..a0ca28df 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -51,7 +51,7 @@ public function isErasureEnabled(): bool */ public function getAllowedStatesToErase(): array { - return explode(',', (string) $this->scopeConfig->getValue( + return explode(',', (string)$this->scopeConfig->getValue( self::CONFIG_PATH_ERASURE_ALLOWED_STATES, ScopeInterface::SCOPE_STORE )); diff --git a/Model/Customer/Anonymize/Processor/CustomerDataProcessor.php b/Model/Customer/Anonymize/Processor/CustomerDataProcessor.php index 5160c288..f586ec20 100644 --- a/Model/Customer/Anonymize/Processor/CustomerDataProcessor.php +++ b/Model/Customer/Anonymize/Processor/CustomerDataProcessor.php @@ -106,7 +106,7 @@ private function anonymizeCustomer(CustomerInterface $customer): void $secureData = $this->customerRegistry->retrieveSecureData($customer->getId()); $dateTime = (new DateTime())->setTimestamp(PHP_INT_MAX); $secureData->setData('lock_expires', $dateTime->format(DateTimeFormat::DATETIME_PHP_FORMAT)); - $secureData->setPasswordHash(sha1(uniqid((string) mt_rand(), true))); + $secureData->setPasswordHash(sha1(uniqid((string)mt_rand(), true))); $customer = $this->anonymizer->anonymize($customer); if ($customer instanceof DataObject) { diff --git a/Model/Customer/Anonymize/Processor/OrderDataProcessor.php b/Model/Customer/Anonymize/Processor/OrderDataProcessor.php index 367d49d1..04fa265e 100644 --- a/Model/Customer/Anonymize/Processor/OrderDataProcessor.php +++ b/Model/Customer/Anonymize/Processor/OrderDataProcessor.php @@ -58,7 +58,7 @@ public function execute(int $customerId): bool foreach ($orderList->getItems() as $order) { $lastActive = new DateTime($order->getUpdatedAt()); $this->salesInformation->isAlive($lastActive) - ? $this->salesInformation->scheduleEraseEntity((int) $order->getEntityId(), 'order', $lastActive) + ? $this->salesInformation->scheduleEraseEntity((int)$order->getEntityId(), 'order', $lastActive) : $this->anonymize($order); } diff --git a/Model/Customer/CustomerChecker.php b/Model/Customer/CustomerChecker.php index 11c4c970..a7421e10 100644 --- a/Model/Customer/CustomerChecker.php +++ b/Model/Customer/CustomerChecker.php @@ -7,46 +7,24 @@ namespace Opengento\Gdpr\Model\Customer; -use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Sales\Api\Data\OrderInterface; -use Magento\Sales\Api\OrderRepositoryInterface; +use Magento\Sales\Model\ResourceModel\Order\CollectionFactory; use Opengento\Gdpr\Model\Config; use Opengento\Gdpr\Model\Entity\EntityCheckerInterface; class CustomerChecker implements EntityCheckerInterface { - private OrderRepositoryInterface $orderRepository; - - private SearchCriteriaBuilder $criteriaBuilder; - - private Config $config; - - /** - * @var bool[] - */ - private array $cache; - public function __construct( - OrderRepositoryInterface $orderRepository, - SearchCriteriaBuilder $criteriaBuilder, - Config $config - ) { - $this->orderRepository = $orderRepository; - $this->criteriaBuilder = $criteriaBuilder; - $this->config = $config; - $this->cache = []; - } + private CollectionFactory $collectionFactory, + private Config $config + ) {} public function canErase(int $customerId): bool { - if (!isset($this->cache[$customerId])) { - $this->criteriaBuilder->addFilter(OrderInterface::STATE, $this->config->getAllowedStatesToErase(), 'nin'); - $this->criteriaBuilder->addFilter(OrderInterface::CUSTOMER_ID, $customerId); - $orderList = $this->orderRepository->getList($this->criteriaBuilder->create()); - - $this->cache[$customerId] = !$orderList->getTotalCount(); - } + $collection = $this->collectionFactory->create(); + $collection->addFieldToFilter(OrderInterface::CUSTOMER_ID, $customerId); + $collection->addFieldToFilter(OrderInterface::STATE, ['nin' => $this->config->getAllowedStatesToErase()]); - return $this->cache[$customerId]; + return $collection->getSize() > 0; } } diff --git a/Model/Customer/Delete/Processor/OrderDataProcessor.php b/Model/Customer/Delete/Processor/OrderDataProcessor.php index 6c8470bc..2beb36bc 100644 --- a/Model/Customer/Delete/Processor/OrderDataProcessor.php +++ b/Model/Customer/Delete/Processor/OrderDataProcessor.php @@ -45,7 +45,7 @@ public function execute(int $customerId): bool foreach ($orderList->getItems() as $order) { $lastActive = new DateTime($order->getUpdatedAt()); $this->salesInformation->isAlive($lastActive) - ? $this->salesInformation->scheduleEraseEntity((int) $order->getEntityId(), 'order', $lastActive) + ? $this->salesInformation->scheduleEraseEntity((int)$order->getEntityId(), 'order', $lastActive) : $this->orderRepository->delete($order); } diff --git a/Model/Customer/Notifier/MailSender.php b/Model/Customer/Notifier/MailSender.php index b61f764f..63564d72 100644 --- a/Model/Customer/Notifier/MailSender.php +++ b/Model/Customer/Notifier/MailSender.php @@ -42,7 +42,7 @@ public function __construct( */ public function send(CustomerInterface $customer): void { - $storeId = $customer->getStoreId() === null ? null : (int) $customer->getStoreId(); + $storeId = $customer->getStoreId() === null ? null : (int)$customer->getStoreId(); $vars = [ 'customer' => $customer, 'store' => $this->storeManager->getStore($customer->getStoreId()), diff --git a/Model/Customer/OrigDataRegistry.php b/Model/Customer/OrigDataRegistry.php index 24c43357..30a43149 100644 --- a/Model/Customer/OrigDataRegistry.php +++ b/Model/Customer/OrigDataRegistry.php @@ -23,6 +23,6 @@ public function get(int $customerId): ?CustomerInterface public function set(CustomerInterface $customer): void { - $this->customers[(int) $customer->getId()] = $customer; + $this->customers[(int)$customer->getId()] = $customer; } } diff --git a/Model/Erase/EraseEntityScheduler.php b/Model/Erase/EraseEntityScheduler.php index 84587d19..a3b490fe 100644 --- a/Model/Erase/EraseEntityScheduler.php +++ b/Model/Erase/EraseEntityScheduler.php @@ -47,7 +47,7 @@ public function schedule(array $entityTypes, Filter $filter): void */ foreach ($this->collectEntityIds($entityTypes, $filter) as $entityType => $entityIds) { foreach ($entityIds as $entityId) { - $this->eraseManagement->create((int) $entityId, $entityType); + $this->eraseManagement->create((int)$entityId, $entityType); } } } diff --git a/Model/Erase/EraseSalesInformation.php b/Model/Erase/EraseSalesInformation.php index dd2b1d53..e9e40072 100644 --- a/Model/Erase/EraseSalesInformation.php +++ b/Model/Erase/EraseSalesInformation.php @@ -62,6 +62,6 @@ public function isAlive(DateTimeInterface $lastActive): bool private function resolveErasureSalesMaxAge(): int { - return (int) $this->scopeConfig->getValue(self::CONFIG_PATH_ERASURE_SALES_MAX_AGE, ScopeInterface::SCOPE_STORE); + return (int)$this->scopeConfig->getValue(self::CONFIG_PATH_ERASURE_SALES_MAX_AGE, ScopeInterface::SCOPE_STORE); } } diff --git a/Model/EraseEntity.php b/Model/EraseEntity.php index 55433d25..38e1660f 100755 --- a/Model/EraseEntity.php +++ b/Model/EraseEntity.php @@ -22,7 +22,7 @@ protected function _construct(): void public function getEraseId(): int { - return (int) $this->getId(); + return (int)$this->getId(); } public function setEraseId(int $eraseId): EraseEntityInterface @@ -32,7 +32,7 @@ public function setEraseId(int $eraseId): EraseEntityInterface public function getEntityId(): int { - return (int) $this->_getData(self::ENTITY_ID); + return (int)$this->_getData(self::ENTITY_ID); } public function setEntityId($entityId): EraseEntityInterface @@ -42,7 +42,7 @@ public function setEntityId($entityId): EraseEntityInterface public function getEntityType(): string { - return (string) $this->_getData(self::ENTITY_TYPE); + return (string)$this->_getData(self::ENTITY_TYPE); } public function setEntityType(string $entityType): EraseEntityInterface @@ -52,7 +52,7 @@ public function setEntityType(string $entityType): EraseEntityInterface public function getScheduledAt(): string { - return (string) $this->_getData(self::SCHEDULED_AT); + return (string)$this->_getData(self::SCHEDULED_AT); } public function setScheduledAt(string $scheduledAt): EraseEntityInterface @@ -62,7 +62,7 @@ public function setScheduledAt(string $scheduledAt): EraseEntityInterface public function getState(): string { - return (string) $this->_getData(self::STATE); + return (string)$this->_getData(self::STATE); } public function setState(string $state): EraseEntityInterface @@ -72,7 +72,7 @@ public function setState(string $state): EraseEntityInterface public function getStatus(): string { - return (string) $this->_getData(self::STATUS); + return (string)$this->_getData(self::STATUS); } public function setStatus(string $status): EraseEntityInterface @@ -82,7 +82,7 @@ public function setStatus(string $status): EraseEntityInterface public function getMessage(): ?string { - return $this->_getData(self::MESSAGE) === null ? null : (string) $this->_getData(self::MESSAGE); + return $this->_getData(self::MESSAGE) === null ? null : (string)$this->_getData(self::MESSAGE); } public function setMessage(?string $message): EraseEntityInterface @@ -92,7 +92,7 @@ public function setMessage(?string $message): EraseEntityInterface public function getErasedAt(): string { - return (string) $this->_getData(self::ERASED_AT); + return (string)$this->_getData(self::ERASED_AT); } public function setErasedAt(string $erasedAt): EraseEntityInterface diff --git a/Model/EraseEntityChecker.php b/Model/EraseEntityChecker.php index 37a5e8e0..ff2049ee 100644 --- a/Model/EraseEntityChecker.php +++ b/Model/EraseEntityChecker.php @@ -33,7 +33,7 @@ public function __construct( public function exists(int $entityId, string $entityType): bool { try { - return (bool) $this->eraseRepository->getByEntity($entityId, $entityType)->getEraseId(); + return (bool)$this->eraseRepository->getByEntity($entityId, $entityType)->getEraseId(); } catch (NoSuchEntityException $e) { return false; } diff --git a/Model/EraseEntityManagement.php b/Model/EraseEntityManagement.php index 7809cf53..bf694411 100644 --- a/Model/EraseEntityManagement.php +++ b/Model/EraseEntityManagement.php @@ -122,6 +122,6 @@ private function retrieveScheduledAt(): string private function resolveErasureDelay(): int { - return (int) $this->scopeConfig->getValue(self::CONFIG_PATH_ERASURE_DELAY, ScopeInterface::SCOPE_STORE); + return (int)$this->scopeConfig->getValue(self::CONFIG_PATH_ERASURE_DELAY, ScopeInterface::SCOPE_STORE); } } diff --git a/Model/Export/ExportToFile.php b/Model/Export/ExportToFile.php index 53ae8124..7080b503 100644 --- a/Model/Export/ExportToFile.php +++ b/Model/Export/ExportToFile.php @@ -71,7 +71,7 @@ public function export(ExportEntityInterface $exportEntity): string public function resolveExportRendererCodes(): array { - return explode(',', (string) $this->scopeConfig->getValue( + return explode(',', (string)$this->scopeConfig->getValue( self::CONFIG_PATH_EXPORT_RENDERERS, ScopeInterface::SCOPE_STORE )); diff --git a/Model/ExportEntity.php b/Model/ExportEntity.php index 4af187fb..a84f1e41 100644 --- a/Model/ExportEntity.php +++ b/Model/ExportEntity.php @@ -22,7 +22,7 @@ protected function _construct(): void public function getExportId(): int { - return (int) $this->getId(); + return (int)$this->getId(); } public function setExportId(int $exportId): ExportEntityInterface @@ -32,7 +32,7 @@ public function setExportId(int $exportId): ExportEntityInterface public function getEntityId(): int { - return (int) $this->_getData(self::ENTITY_ID); + return (int)$this->_getData(self::ENTITY_ID); } public function setEntityId($entityId): ExportEntityInterface @@ -42,7 +42,7 @@ public function setEntityId($entityId): ExportEntityInterface public function getEntityType(): string { - return (string) $this->_getData(self::ENTITY_TYPE); + return (string)$this->_getData(self::ENTITY_TYPE); } public function setEntityType(string $entityType): ExportEntityInterface @@ -52,7 +52,7 @@ public function setEntityType(string $entityType): ExportEntityInterface public function getFileName(): string { - return (string) $this->_getData(self::FILE_NAME); + return (string)$this->_getData(self::FILE_NAME); } public function setFileName(string $filename): ExportEntityInterface @@ -62,7 +62,7 @@ public function setFileName(string $filename): ExportEntityInterface public function getFilePath(): ?string { - return $this->_getData(self::FILE_PATH) === null ? null : (string) $this->_getData(self::FILE_PATH); + return $this->_getData(self::FILE_PATH) === null ? null : (string)$this->_getData(self::FILE_PATH); } public function setFilePath(?string $filePath): ExportEntityInterface @@ -72,7 +72,7 @@ public function setFilePath(?string $filePath): ExportEntityInterface public function getCreatedAt(): string { - return (string) $this->_getData(self::CREATED_AT); + return (string)$this->_getData(self::CREATED_AT); } public function setCreatedAt(string $createdAt): ExportEntityInterface @@ -82,7 +82,7 @@ public function setCreatedAt(string $createdAt): ExportEntityInterface public function getExportedAt(): ?string { - return $this->_getData(self::EXPORTED_AT) === null ? null : (string) $this->_getData(self::EXPORTED_AT); + return $this->_getData(self::EXPORTED_AT) === null ? null : (string)$this->_getData(self::EXPORTED_AT); } public function setExportedAt(string $exportedAt): ExportEntityInterface @@ -92,7 +92,7 @@ public function setExportedAt(string $exportedAt): ExportEntityInterface public function getExpiredAt(): string { - return (string) $this->_getData(self::EXPIRED_AT); + return (string)$this->_getData(self::EXPIRED_AT); } public function setExpiredAt(string $expiredAt): ExportEntityInterface diff --git a/Model/ExportEntityChecker.php b/Model/ExportEntityChecker.php index 6b5e9521..ec45d2f8 100644 --- a/Model/ExportEntityChecker.php +++ b/Model/ExportEntityChecker.php @@ -24,7 +24,7 @@ public function __construct( public function exists(int $entityId, string $entityType): bool { try { - return (bool) $this->exportRepository->getByEntity($entityId, $entityType)->getExportId(); + return (bool)$this->exportRepository->getByEntity($entityId, $entityType)->getExportId(); } catch (NoSuchEntityException $e) { return false; } diff --git a/Model/ExportEntityManagement.php b/Model/ExportEntityManagement.php index 9e87dca9..0eb094b1 100644 --- a/Model/ExportEntityManagement.php +++ b/Model/ExportEntityManagement.php @@ -80,7 +80,7 @@ public function create(int $entityId, string $entityType, ?string $fileName = nu */ public function export(ExportEntityInterface $exportEntity): ExportEntityInterface { - $lifeTime = (int) $this->scopeConfig->getValue(self::CONFIG_PATH_EXPORT_LIFE_TIME, ScopeInterface::SCOPE_STORE); + $lifeTime = (int)$this->scopeConfig->getValue(self::CONFIG_PATH_EXPORT_LIFE_TIME, ScopeInterface::SCOPE_STORE); $exportEntity->setFilePath($this->exportToFile->export($exportEntity)); $exportEntity->setExpiredAt( (new DateTime('+' . $lifeTime . 'minutes'))->format(DateTimeFormat::DATETIME_PHP_FORMAT) @@ -100,6 +100,6 @@ public function invalidate(ExportEntityInterface $exportEntity): ExportEntityInt private function resolveDefaultFileName(): string { - return (string) $this->scopeConfig->getValue(self::CONFIG_PATH_EXPORT_FILE_NAME, ScopeInterface::SCOPE_STORE); + return (string)$this->scopeConfig->getValue(self::CONFIG_PATH_EXPORT_FILE_NAME, ScopeInterface::SCOPE_STORE); } } diff --git a/Model/Notifier/AbstractMailSender.php b/Model/Notifier/AbstractMailSender.php index ce0410b0..2e727864 100644 --- a/Model/Notifier/AbstractMailSender.php +++ b/Model/Notifier/AbstractMailSender.php @@ -111,7 +111,7 @@ protected function isAvailable(?int $storeId = null): bool */ protected function getFrom(?int $storeId = null): string { - return (string) $this->scopeConfig->getValue( + return (string)$this->scopeConfig->getValue( $this->configPaths['from'], ScopeInterface::SCOPE_STORE, $storeId @@ -140,7 +140,7 @@ protected function getCopyTo(?int $storeId = null): array */ protected function getCopyMethod(?int $storeId = null): string { - return (string) $this->scopeConfig->getValue( + return (string)$this->scopeConfig->getValue( $this->configPaths['copy_method'], ScopeInterface::SCOPE_STORE, $storeId @@ -153,7 +153,7 @@ protected function getCopyMethod(?int $storeId = null): string */ protected function getTemplateIdentifier(?int $storeId = null): string { - return (string) $this->scopeConfig->getValue( + return (string)$this->scopeConfig->getValue( $this->configPaths['template_identifier'], ScopeInterface::SCOPE_STORE, $storeId diff --git a/Model/Order/Anonymize/Processor/OrderDataProcessor.php b/Model/Order/Anonymize/Processor/OrderDataProcessor.php index b7a1f6de..1fdf9c8d 100644 --- a/Model/Order/Anonymize/Processor/OrderDataProcessor.php +++ b/Model/Order/Anonymize/Processor/OrderDataProcessor.php @@ -50,7 +50,7 @@ public function execute(int $orderId): bool $lastActive = new DateTime($order->getUpdatedAt()); if ($this->salesInformation->isAlive($lastActive)) { - $this->salesInformation->scheduleEraseEntity((int) $order->getEntityId(), 'order', $lastActive); + $this->salesInformation->scheduleEraseEntity((int)$order->getEntityId(), 'order', $lastActive); return true; } diff --git a/Model/Order/Delete/Processor/OrderDataProcessor.php b/Model/Order/Delete/Processor/OrderDataProcessor.php index 322ec9f1..f274eb50 100644 --- a/Model/Order/Delete/Processor/OrderDataProcessor.php +++ b/Model/Order/Delete/Processor/OrderDataProcessor.php @@ -37,7 +37,7 @@ public function execute(int $orderId): bool $lastActive = new DateTime($order->getUpdatedAt()); if ($this->salesInformation->isAlive($lastActive)) { - $this->salesInformation->scheduleEraseEntity((int) $order->getEntityId(), 'order', $lastActive); + $this->salesInformation->scheduleEraseEntity((int)$order->getEntityId(), 'order', $lastActive); return true; } diff --git a/Model/Order/Delete/Processor/SubscriberDataProcessor.php b/Model/Order/Delete/Processor/SubscriberDataProcessor.php index 43c1c4d5..beda160c 100644 --- a/Model/Order/Delete/Processor/SubscriberDataProcessor.php +++ b/Model/Order/Delete/Processor/SubscriberDataProcessor.php @@ -49,7 +49,7 @@ public function execute(int $orderId): bool $subscriber = $this->subscriberFactory->create(); $subscriber->loadBySubscriberEmail( $order->getCustomerEmail(), - (int) $this->storeManager->getStore($order->getStoreId())->getWebsiteId() + (int)$this->storeManager->getStore($order->getStoreId())->getWebsiteId() ); $this->subscriberResource->delete($subscriber); diff --git a/Model/Order/Notifier/MailSender.php b/Model/Order/Notifier/MailSender.php index 74a2532a..6bfda1ba 100644 --- a/Model/Order/Notifier/MailSender.php +++ b/Model/Order/Notifier/MailSender.php @@ -47,7 +47,7 @@ public function __construct( */ public function send(OrderInterface $order): void { - $storeId = $order->getStoreId() === null ? null : (int) $order->getStoreId(); + $storeId = $order->getStoreId() === null ? null : (int)$order->getStoreId(); $vars = [ 'order' => $order, 'billing' => $order->getBillingAddress(), diff --git a/Model/Order/OrderChecker.php b/Model/Order/OrderChecker.php index a9d3ddac..1668ef6e 100644 --- a/Model/Order/OrderChecker.php +++ b/Model/Order/OrderChecker.php @@ -15,17 +15,10 @@ class OrderChecker implements EntityCheckerInterface { - private OrderRepositoryInterface $orderRepository; - - private Config $config; - public function __construct( - OrderRepositoryInterface $orderRepository, - Config $config - ) { - $this->orderRepository = $orderRepository; - $this->config = $config; - } + private OrderRepositoryInterface $orderRepository, + private Config $config + ) {} public function canErase(int $orderId): bool { diff --git a/Observer/DeleteExport.php b/Observer/DeleteExport.php index efd945e1..eb97ba65 100644 --- a/Observer/DeleteExport.php +++ b/Observer/DeleteExport.php @@ -78,7 +78,7 @@ private function fetchExportEntities(DataObject $entity): SearchResultsInterface foreach ($entityTypes as $entityType => $idFieldName) { $this->criteriaBuilder->addFilters([ - $this->createEntityIdFilter((int) $entity->getData($idFieldName)), + $this->createEntityIdFilter((int)$entity->getData($idFieldName)), $this->createEntityTypeFilter($entityType) ]); } diff --git a/Observer/InvalidateExport.php b/Observer/InvalidateExport.php index 1b7243fc..ec5eaa84 100644 --- a/Observer/InvalidateExport.php +++ b/Observer/InvalidateExport.php @@ -82,7 +82,7 @@ private function fetchExportEntities(DataObject $entity): SearchResultsInterface foreach ($entityTypes as $entityType => $idFieldName) { $this->criteriaBuilder->addFilters([ - $this->createEntityIdFilter((int) $entity->getData($idFieldName)), + $this->createEntityIdFilter((int)$entity->getData($idFieldName)), $this->createEntityTypeFilter($entityType) ]); } diff --git a/ViewModel/Customer/Guest/EraseDataProvider.php b/ViewModel/Customer/Guest/EraseDataProvider.php index 697496de..1ad7434b 100644 --- a/ViewModel/Customer/Guest/EraseDataProvider.php +++ b/ViewModel/Customer/Guest/EraseDataProvider.php @@ -53,6 +53,6 @@ private function currentOrderId(): int /** @var OrderInterface $order */ $order = $this->registry->registry('current_order'); - return (int) $order->getEntityId(); + return (int)$order->getEntityId(); } } diff --git a/ViewModel/Customer/Guest/ExportDataProvider.php b/ViewModel/Customer/Guest/ExportDataProvider.php index a713a356..bb808942 100644 --- a/ViewModel/Customer/Guest/ExportDataProvider.php +++ b/ViewModel/Customer/Guest/ExportDataProvider.php @@ -53,6 +53,6 @@ private function currentOrderId(): int /** @var OrderInterface $order */ $order = $this->registry->registry('current_order'); - return (int) $order->getEntityId(); + return (int)$order->getEntityId(); } } diff --git a/ViewModel/Customer/Privacy/EraseCustomerDataProvider.php b/ViewModel/Customer/Privacy/EraseCustomerDataProvider.php index 3dcb5f71..f8e99e3a 100644 --- a/ViewModel/Customer/Privacy/EraseCustomerDataProvider.php +++ b/ViewModel/Customer/Privacy/EraseCustomerDataProvider.php @@ -50,6 +50,6 @@ public function canCreate(): bool private function currentCustomerId(): int { - return (int) $this->session->getCustomerId(); + return (int)$this->session->getCustomerId(); } } diff --git a/ViewModel/Customer/Privacy/EraseDataProvider.php b/ViewModel/Customer/Privacy/EraseDataProvider.php index e94db74e..8a6ee368 100644 --- a/ViewModel/Customer/Privacy/EraseDataProvider.php +++ b/ViewModel/Customer/Privacy/EraseDataProvider.php @@ -38,7 +38,7 @@ public function getErasureInformationHtml(): string { return $this->erasureInformation ??= $this->blockFactory->createBlock( BlockByIdentifier::class, - ['data' => ['identifier' => (string) $this->scopeConfig->getValue( + ['data' => ['identifier' => (string)$this->scopeConfig->getValue( self::CONFIG_PATH_ERASURE_INFORMATION_BLOCK, ScopeInterface::SCOPE_STORE )]] @@ -49,7 +49,7 @@ public function getAnonymizeInformationHtml(): string { return $this->anonymizeInformation ??= $this->blockFactory->createBlock( BlockByIdentifier::class, - ['data' => ['identifier' => (string) $this->scopeConfig->getValue( + ['data' => ['identifier' => (string)$this->scopeConfig->getValue( self::CONFIG_PATH_ANONYMIZE_INFORMATION_BLOCK, ScopeInterface::SCOPE_STORE )]] diff --git a/ViewModel/Customer/Privacy/ExportCustomerDataProvider.php b/ViewModel/Customer/Privacy/ExportCustomerDataProvider.php index d404e4c7..cd9085d4 100644 --- a/ViewModel/Customer/Privacy/ExportCustomerDataProvider.php +++ b/ViewModel/Customer/Privacy/ExportCustomerDataProvider.php @@ -50,6 +50,6 @@ public function isExported(): bool private function currentCustomerId(): int { - return (int) $this->session->getCustomerId(); + return (int)$this->session->getCustomerId(); } } diff --git a/ViewModel/Customer/Privacy/ExportDataProvider.php b/ViewModel/Customer/Privacy/ExportDataProvider.php index 6bc385f7..e13e068c 100644 --- a/ViewModel/Customer/Privacy/ExportDataProvider.php +++ b/ViewModel/Customer/Privacy/ExportDataProvider.php @@ -35,7 +35,7 @@ public function getExportInformationHtml(): string { return $this->exportInformation ??= $this->blockFactory->createBlock( BlockByIdentifier::class, - ['data' => ['identifier' => (string) $this->scopeConfig->getValue( + ['data' => ['identifier' => (string)$this->scopeConfig->getValue( self::CONFIG_PATH_EXPORT_INFORMATION_BLOCK, ScopeInterface::SCOPE_STORE )]] diff --git a/ViewModel/Customer/Privacy/SettingsDataProvider.php b/ViewModel/Customer/Privacy/SettingsDataProvider.php index f47b0d03..ed608708 100644 --- a/ViewModel/Customer/Privacy/SettingsDataProvider.php +++ b/ViewModel/Customer/Privacy/SettingsDataProvider.php @@ -35,7 +35,7 @@ public function getPrivacyInformationHtml(): string { return $this->informationHtml ??= $this->blockFactory->createBlock( BlockByIdentifier::class, - ['data' => ['identifier' => (string) $this->scopeConfig->getValue( + ['data' => ['identifier' => (string)$this->scopeConfig->getValue( self::CONFIG_PATH_GENERAL_INFORMATION_BLOCK, ScopeInterface::SCOPE_STORE )]] diff --git a/view/base/templates/export/renderer/default.phtml b/view/base/templates/export/renderer/default.phtml index 7fc707aa..a05b2f91 100644 --- a/view/base/templates/export/renderer/default.phtml +++ b/view/base/templates/export/renderer/default.phtml @@ -24,7 +24,7 @@ $exportData = array_filter($viewModel->toArray()); if (!function_exists('formatLabel')) { function formatLabel($label): string { - return ucwords(str_replace('_', ' ', (string) $label)); + return ucwords(str_replace('_', ' ', (string)$label)); } } if (!function_exists('renderNestedItems')) { From 41784af1e723c8f68987518ff33bd97d6c0b4419 Mon Sep 17 00:00:00 2001 From: Thomas Klein Date: Thu, 27 Jun 2024 23:03:44 +0200 Subject: [PATCH 06/31] Fix nullable properties for config source components --- Cron/EraseEntity.php | 43 +++--------- Cron/EraseEntityScheduler.php | 33 ++------- Cron/ExportEntity.php | 28 ++------ Cron/ExportEntityExpired.php | 23 ++----- Model/Config/Source/EraseComponents.php | 69 ++++++------------- Model/Config/Source/OrderPendingStates.php | 13 +--- .../Source/VirtualArrayArgumentList.php | 35 +++------- .../Source/VirtualCustomerAttributes.php | 42 +++++------ .../Config/Source/VirtualEntityAttributes.php | 12 ++-- Model/Erase/SecureEraseEntityManagement.php | 13 +--- 10 files changed, 87 insertions(+), 224 deletions(-) diff --git a/Cron/EraseEntity.php b/Cron/EraseEntity.php index 492e51b0..0783e69b 100755 --- a/Cron/EraseEntity.php +++ b/Cron/EraseEntity.php @@ -25,40 +25,15 @@ */ class EraseEntity { - private LoggerInterface $logger; - - private Config $config; - - private Registry $registry; - - private EraseEntityManagementInterface $eraseManagement; - - private EraseEntityRepositoryInterface $eraseRepository; - - private SearchCriteriaBuilder $criteriaBuilder; - - /** - * @var DateTime - */ - private DateTime $dateTime; - public function __construct( - LoggerInterface $logger, - Config $config, - Registry $registry, - EraseEntityManagementInterface $eraseManagement, - EraseEntityRepositoryInterface $eraseRepository, - SearchCriteriaBuilder $criteriaBuilder, - DateTime $dateTime - ) { - $this->logger = $logger; - $this->config = $config; - $this->registry = $registry; - $this->eraseManagement = $eraseManagement; - $this->eraseRepository = $eraseRepository; - $this->criteriaBuilder = $criteriaBuilder; - $this->dateTime = $dateTime; - } + private LoggerInterface $logger, + private Config $config, + private Registry $registry, + private EraseEntityManagementInterface $eraseManagement, + private EraseEntityRepositoryInterface $eraseRepository, + private SearchCriteriaBuilder $criteriaBuilder, + private DateTime $dateTime + ) {} public function execute(): void { @@ -101,7 +76,7 @@ private function retrieveEraseEntityList(): SearchResultsInterface try { $eraseCustomerList = $this->eraseRepository->getList($this->criteriaBuilder->create()); - } catch (LocalizedException $e) { + } catch (LocalizedException) { $eraseCustomerList = []; } diff --git a/Cron/EraseEntityScheduler.php b/Cron/EraseEntityScheduler.php index 4221430e..4381dddd 100644 --- a/Cron/EraseEntityScheduler.php +++ b/Cron/EraseEntityScheduler.php @@ -26,35 +26,14 @@ class EraseEntityScheduler { private const CONFIG_PATH_ERASURE_MAX_AGE = 'gdpr/erasure/entity_max_age'; - private LoggerInterface $logger; - - private ScopeConfigInterface $scopeConfig; - - private Config $config; - - /** - * @var EraseEntitySchedulerService - */ - private EraseEntitySchedulerService $eraseEntityScheduler; - - private FilterBuilder $filterBuilder; - - private EntityTypeList $entityTypeList; - public function __construct( - LoggerInterface $logger, - ScopeConfigInterface $scopeConfig, - Config $config, - EraseEntitySchedulerService $eraseEntityScheduler, - FilterBuilder $filterBuilder, - EntityTypeList $entityTypeList + private LoggerInterface $logger, + private ScopeConfigInterface $scopeConfig, + private Config $config, + private EraseEntitySchedulerService $eraseEntityScheduler, + private FilterBuilder $filterBuilder, + private EntityTypeList $entityTypeList ) { - $this->logger = $logger; - $this->scopeConfig = $scopeConfig; - $this->config = $config; - $this->eraseEntityScheduler = $eraseEntityScheduler; - $this->filterBuilder = $filterBuilder; - $this->entityTypeList = $entityTypeList; } public function execute(): void diff --git a/Cron/ExportEntity.php b/Cron/ExportEntity.php index 0618bb70..587e78d2 100644 --- a/Cron/ExportEntity.php +++ b/Cron/ExportEntity.php @@ -21,29 +21,13 @@ */ class ExportEntity { - private LoggerInterface $logger; - - private Config $config; - - private ExportEntityRepositoryInterface $exportRepository; - - private ExportEntityManagementInterface $exportManagement; - - private SearchCriteriaBuilder $criteriaBuilder; - public function __construct( - LoggerInterface $logger, - Config $config, - ExportEntityRepositoryInterface $exportRepository, - ExportEntityManagementInterface $exportManagement, - SearchCriteriaBuilder $criteriaBuilder - ) { - $this->logger = $logger; - $this->config = $config; - $this->exportRepository = $exportRepository; - $this->exportManagement = $exportManagement; - $this->criteriaBuilder = $criteriaBuilder; - } + private LoggerInterface $logger, + private Config $config, + private ExportEntityRepositoryInterface $exportRepository, + private ExportEntityManagementInterface $exportManagement, + private SearchCriteriaBuilder $criteriaBuilder + ) {} public function execute(): void { diff --git a/Cron/ExportEntityExpired.php b/Cron/ExportEntityExpired.php index 6e0d1a7f..17444ced 100644 --- a/Cron/ExportEntityExpired.php +++ b/Cron/ExportEntityExpired.php @@ -20,25 +20,12 @@ */ class ExportEntityExpired { - private LoggerInterface $logger; - - private Config $config; - - private ExportEntityRepositoryInterface $exportRepository; - - private SearchCriteriaBuilder $criteriaBuilder; - public function __construct( - LoggerInterface $logger, - Config $config, - ExportEntityRepositoryInterface $exportRepository, - SearchCriteriaBuilder $criteriaBuilder - ) { - $this->logger = $logger; - $this->config = $config; - $this->exportRepository = $exportRepository; - $this->criteriaBuilder = $criteriaBuilder; - } + private LoggerInterface $logger, + private Config $config, + private ExportEntityRepositoryInterface $exportRepository, + private SearchCriteriaBuilder $criteriaBuilder + ) {} public function execute(): void { diff --git a/Model/Config/Source/EraseComponents.php b/Model/Config/Source/EraseComponents.php index b5b0006d..a3f60d6d 100644 --- a/Model/Config/Source/EraseComponents.php +++ b/Model/Config/Source/EraseComponents.php @@ -12,44 +12,27 @@ use Magento\Framework\Phrase; use function array_keys; +use function array_map; use function array_merge; class EraseComponents implements OptionSourceInterface { - /** - * @var ConfigInterface - */ - private ConfigInterface $objectManagerConfig; - - /** - * Class must be an instance of `\Opengento\Gdpr\Service\Erase\ProcessorResolverFactory` - * - * @var string - */ - private string $factoryClassName; - - /** - * @var string[][] - */ - private array $options = []; + private ?array $options = null; public function __construct( - ConfigInterface $objectManagerConfig, - string $factoryClassName - ) { - $this->objectManagerConfig = $objectManagerConfig; - $this->factoryClassName = $factoryClassName; - } + private ConfigInterface $objectManagerConfig, + private string $factoryClassName + ) {} public function toOptionArray(): array { - if (!$this->options) { - foreach ($this->retrieveDelegateProcessors() as $delegateProcessor) { - $this->options[] = ['value' => $delegateProcessor, 'label' => new Phrase($delegateProcessor)]; - } - } - - return $this->options; + return $this->options ??= array_map( + static fn (string $delegateProcessor): array => [ + 'value' => $delegateProcessor, + 'label' => new Phrase($delegateProcessor) + ], + $this->retrieveDelegateProcessors() + ); } /** @@ -57,26 +40,18 @@ public function toOptionArray(): array */ private function retrieveDelegateProcessors(): array { - $delegateProcessors = []; - /** @var string[] $resolvers */ - $resolvers = $this->retrieveArgument($this->factoryClassName, 'processorResolvers', []); - - foreach ($resolvers as $resolver) { - $delegateProcessors[] = $this->retrieveArgument($resolver, 'processors'); - } - - return array_keys(array_merge([], ...$delegateProcessors)); + return array_keys( + array_merge( + [], + ...array_map( + fn (string $resolver): mixed => $this->retrieveArgument($resolver, 'processors'), + $this->retrieveArgument($this->factoryClassName, 'processorResolvers', []) + ) + ) + ); } - /** - * Retrieve a construct argument value of a class - * - * @param string $className - * @param string $argumentName - * @param mixed $defaultValue - * @return mixed - */ - private function retrieveArgument(string $className, string $argumentName, $defaultValue = null) + private function retrieveArgument(string $className, string $argumentName, mixed $defaultValue = null): mixed { $arguments = $this->objectManagerConfig->getArguments( $this->objectManagerConfig->getPreference($className) diff --git a/Model/Config/Source/OrderPendingStates.php b/Model/Config/Source/OrderPendingStates.php index 8ed95dd2..a60adb52 100644 --- a/Model/Config/Source/OrderPendingStates.php +++ b/Model/Config/Source/OrderPendingStates.php @@ -12,18 +12,9 @@ class OrderPendingStates implements OptionSourceInterface { - private CollectionFactory $collectionFactory; + private ?array $options = null; - /** - * @var string[][] - */ - private array $options; - - public function __construct( - CollectionFactory $collectionFactory - ) { - $this->collectionFactory = $collectionFactory; - } + public function __construct(private CollectionFactory $collectionFactory) {} public function toOptionArray(): array { diff --git a/Model/Config/Source/VirtualArrayArgumentList.php b/Model/Config/Source/VirtualArrayArgumentList.php index 13e36688..a6594014 100644 --- a/Model/Config/Source/VirtualArrayArgumentList.php +++ b/Model/Config/Source/VirtualArrayArgumentList.php @@ -12,39 +12,24 @@ use Magento\Framework\Phrase; use function array_keys; +use function array_map; class VirtualArrayArgumentList implements OptionSourceInterface { - /** - * @var ConfigInterface - */ - private ConfigInterface $objectManagerConfig; - - private string $className; - - private string $argumentName; - - private array $options = []; + private ?array $options = null; public function __construct( - ConfigInterface $objectManagerConfig, - string $className, - string $argumentName - ) { - $this->objectManagerConfig = $objectManagerConfig; - $this->className = $className; - $this->argumentName = $argumentName; - } + private ConfigInterface $objectManagerConfig, + private string $className, + private string $argumentName + ) {} public function toOptionArray(): array { - if (!$this->options) { - foreach (array_keys($this->retrieveItems()) as $item) { - $this->options[] = ['value' => $item, 'label' => new Phrase($item)]; - } - } - - return $this->options; + return $this->options ??= array_map( + static fn (string $item): array => ['value' => $item, 'label' => new Phrase($item)], + array_keys($this->retrieveItems()) + ); } /** diff --git a/Model/Config/Source/VirtualCustomerAttributes.php b/Model/Config/Source/VirtualCustomerAttributes.php index 533a0b3e..9b8c9560 100644 --- a/Model/Config/Source/VirtualCustomerAttributes.php +++ b/Model/Config/Source/VirtualCustomerAttributes.php @@ -7,40 +7,36 @@ namespace Opengento\Gdpr\Model\Config\Source; +use Magento\Customer\Api\Data\AttributeMetadataInterface; use Magento\Customer\Api\MetadataInterface; use Magento\Framework\Data\OptionSourceInterface; use Magento\Framework\Exception\LocalizedException; +use function array_map; + class VirtualCustomerAttributes implements OptionSourceInterface { - private MetadataInterface $metadata; - - private array $options; + private ?array $options = null; - public function __construct( - MetadataInterface $metadata - ) { - $this->metadata = $metadata; - $this->options = []; - } + public function __construct(private MetadataInterface $metadata) {} public function toOptionArray(): array { - if (!$this->options) { - try { - $attributes = $this->metadata->getAllAttributesMetadata(); - } catch (LocalizedException $e) { - $attributes = []; - } + return $this->options ??= array_map( + static fn (AttributeMetadataInterface $attributeMetadata): array => [ + 'value' => $attributeMetadata->getAttributeCode(), + 'label' => $attributeMetadata->getFrontendLabel(), + ], + $this->resolveAttributeMetadataList() + ); + } - foreach ($attributes as $attribute) { - $this->options[] = [ - 'value' => $attribute->getAttributeCode(), - 'label' => $attribute->getFrontendLabel(), - ]; - } + private function resolveAttributeMetadataList(): array + { + try { + return $this->metadata->getAllAttributesMetadata(); + } catch (LocalizedException) { + return []; } - - return $this->options; } } diff --git a/Model/Config/Source/VirtualEntityAttributes.php b/Model/Config/Source/VirtualEntityAttributes.php index de584f7d..22fbfe60 100644 --- a/Model/Config/Source/VirtualEntityAttributes.php +++ b/Model/Config/Source/VirtualEntityAttributes.php @@ -11,6 +11,7 @@ use Magento\Framework\Model\EntitySnapshot\AttributeProviderInterface; use function array_keys; +use function array_map; /** * Class VirtualEntityAttributes @@ -28,12 +29,9 @@ public function __construct( public function toOptionArray(): array { - if ($this->options === null) { - foreach (array_keys($this->attributeProvider->getAttributes($this->entityType)) as $attribute) { - $this->options[] = ['value' => $attribute, 'label' => $attribute]; - } - } - - return $this->options; + return $this->options ??= array_map( + static fn (string $attribute): array => ['value' => $attribute, 'label' => $attribute], + array_keys($this->attributeProvider->getAttributes($this->entityType)) + ); } } diff --git a/Model/Erase/SecureEraseEntityManagement.php b/Model/Erase/SecureEraseEntityManagement.php index 34f63bbe..cc71bf0d 100644 --- a/Model/Erase/SecureEraseEntityManagement.php +++ b/Model/Erase/SecureEraseEntityManagement.php @@ -15,17 +15,10 @@ class SecureEraseEntityManagement implements EraseEntityManagementInterface { - private EraseEntityManagementInterface $eraseManagement; - - private EraseEntityCheckerInterface $eraseEntityChecker; - public function __construct( - EraseEntityManagementInterface $eraseManagement, - EraseEntityCheckerInterface $eraseEntityChecker - ) { - $this->eraseManagement = $eraseManagement; - $this->eraseEntityChecker = $eraseEntityChecker; - } + private EraseEntityManagementInterface $eraseManagement, + private EraseEntityCheckerInterface $eraseEntityChecker + ) {} public function create(int $entityId, string $entityType): EraseEntityInterface { From 22d90fd6ed948b38a8a1e385be3e3ed0a5df1437 Mon Sep 17 00:00:00 2001 From: Thomas Klein Date: Sat, 3 Aug 2024 23:35:44 +0200 Subject: [PATCH 07/31] WIP fix scopable config --- Console/Command/EraseCommand.php | 23 +++---- Console/Command/ExportCommand.php | 38 +++++------ Controller/Guest/Download.php | 2 +- Controller/Guest/Erase.php | 2 +- Controller/Guest/Export.php | 2 +- Controller/Guest/UndoErase.php | 2 +- Controller/Privacy/Download.php | 2 +- Controller/Privacy/Erase.php | 2 +- Controller/Privacy/ErasePost.php | 2 +- Controller/Privacy/Export.php | 2 +- Controller/Privacy/UndoErase.php | 2 +- Cron/EraseEntity.php | 25 +++----- Cron/EraseEntityScheduler.php | 47 ++++---------- Cron/ExportEntity.php | 28 ++++----- Cron/ExportEntityExpired.php | 25 ++++---- Model/Archive/ArchiveManager.php | 17 +---- Model/Archive/Zip.php | 23 +++---- Model/Config.php | 54 ++++------------ Model/Config/Backend/Export.php | 14 +---- Model/Config/Entity/Erasure.php | 54 ++++++++++++++++ .../Processor/CustomerDataProcessor.php | 10 ++- Model/Customer/CustomerChecker.php | 10 +-- Model/Customer/Erase/Notifier.php | 2 +- Model/Customer/Export/Notifier.php | 2 +- .../SourceProvider/IdleFilterModifier.php | 63 ++++++++++--------- .../SourceProvider/ExpireFilterModifier.php | 32 ++++++++++ .../Entity/SourceProvider/FilterModifier.php | 41 ------------ .../SourceProvider/ModifierComposite.php | 19 ++---- .../SourceProvider/ModifierInterface.php | 6 +- .../NotErasedFilterModifier.php | 43 +++++-------- Model/Entity/SourceProviderFactory.php | 21 ++----- Model/Erase/EraseEntityScheduler.php | 31 +++------ Model/Erase/EraseSalesInformation.php | 2 +- Model/EraseEntityManagement.php | 2 +- Model/Export/ExportToFile.php | 2 +- Model/ExportEntityManagement.php | 4 +- Model/Order/Erase/Notifier.php | 2 +- Model/Order/Export/Notifier.php | 2 +- Model/Order/OrderChecker.php | 33 ++++++++-- .../SourceProvider/GuestFilterModifier.php | 25 +++----- Observer/DeleteExport.php | 4 +- Observer/InvalidateExport.php | 4 +- etc/db_schema.xml | 19 ------ etc/db_schema_whitelist.json | 21 +------ etc/di.xml | 10 ++- 45 files changed, 327 insertions(+), 449 deletions(-) create mode 100644 Model/Config/Entity/Erasure.php create mode 100644 Model/Entity/SourceProvider/ExpireFilterModifier.php delete mode 100644 Model/Entity/SourceProvider/FilterModifier.php diff --git a/Console/Command/EraseCommand.php b/Console/Command/EraseCommand.php index 46557968..ac8b4df6 100644 --- a/Console/Command/EraseCommand.php +++ b/Console/Command/EraseCommand.php @@ -7,16 +7,14 @@ namespace Opengento\Gdpr\Console\Command; -use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\App\Area; use Magento\Framework\App\State; use Magento\Framework\Console\Cli; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Registry; -use Opengento\Gdpr\Api\Data\EraseEntityInterface; use Opengento\Gdpr\Api\EraseEntityManagementInterface; -use Opengento\Gdpr\Api\EraseEntityRepositoryInterface; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -30,8 +28,6 @@ public function __construct( private State $appState, private Registry $registry, private EraseEntityManagementInterface $eraseManagement, - private EraseEntityRepositoryInterface $eraseEntityRepository, - private SearchCriteriaBuilder $searchCriteriaBuilder, string $name = 'gdpr:entity:erase' ) { parent::__construct($name); @@ -71,17 +67,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int $entityIds = $input->getArgument(self::INPUT_ARGUMENT_ENTITY_ID); $entityType = $input->getArgument(self::INPUT_ARGUMENT_ENTITY_TYPE); - try { - $this->searchCriteriaBuilder->addFilter(EraseEntityInterface::ENTITY_ID, $entityIds, 'in'); - $this->searchCriteriaBuilder->addFilter(EraseEntityInterface::ENTITY_TYPE, $entityType); - $eraseEntityList = $this->eraseEntityRepository->getList($this->searchCriteriaBuilder->create()); - foreach ($eraseEntityList->getItems() as $eraseEntity) { - $this->eraseManagement->process($eraseEntity); + $progressBar = new ProgressBar($output, count($entityIds)); + $progressBar->start(); - $output->writeln( - 'Entity\'s (' . $entityType . ') with ID "' . $eraseEntity->getEntityId() . '" has been erased.' - ); + try { + foreach ($entityIds as $entityId) { + $this->eraseManagement->process($this->eraseManagement->create($entityId, $entityType)); + $progressBar->advance(); } + $progressBar->finish(); + $output->writeln('Entities has been erased.'); } catch (LocalizedException $e) { $output->writeln('' . $e->getMessage() . ''); $returnCode = Cli::RETURN_FAILURE; diff --git a/Console/Command/ExportCommand.php b/Console/Command/ExportCommand.php index 77eed265..2ad719a6 100644 --- a/Console/Command/ExportCommand.php +++ b/Console/Command/ExportCommand.php @@ -8,31 +8,25 @@ namespace Opengento\Gdpr\Console\Command; use Exception; -use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\App\Area; use Magento\Framework\App\State; use Magento\Framework\Console\Cli; use Magento\Framework\Exception\LocalizedException; -use Opengento\Gdpr\Api\Data\ExportEntityInterface; use Opengento\Gdpr\Api\ExportEntityManagementInterface; -use Opengento\Gdpr\Api\ExportEntityRepositoryInterface; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class ExportCommand extends Command { private const INPUT_ARGUMENT_ENTITY_ID = 'entity_id'; private const INPUT_ARGUMENT_ENTITY_TYPE = 'entity_type'; - private const INPUT_OPTION_FILENAME = 'filename'; public function __construct( private State $appState, private ExportEntityManagementInterface $exportEntityManagement, - private ExportEntityRepositoryInterface $exportEntityRepository, - private SearchCriteriaBuilder $searchCriteriaBuilder, string $name = 'gdpr:entity:export' ) { parent::__construct($name); @@ -53,13 +47,6 @@ protected function configure(): void self::INPUT_ARGUMENT_ENTITY_ID, InputArgument::REQUIRED + InputArgument::IS_ARRAY, 'Entity ID' - ), - new InputOption( - self::INPUT_OPTION_FILENAME, - '-f', - InputOption::VALUE_OPTIONAL, - 'Export file name', - 'personal_data' ) ]); } @@ -75,18 +62,23 @@ protected function execute(InputInterface $input, OutputInterface $output): int $resultCode = Cli::RETURN_SUCCESS; $entityIds = $input->getArgument(self::INPUT_ARGUMENT_ENTITY_ID); $entityType = $input->getArgument(self::INPUT_ARGUMENT_ENTITY_TYPE); - $fileName = $input->getOption(self::INPUT_OPTION_FILENAME); + + $progressBar = new ProgressBar($output, count($entityIds)); + $progressBar->start(); + + $files = []; try { - $this->searchCriteriaBuilder->addFilter(ExportEntityInterface::ENTITY_ID, $entityIds, 'in'); - $this->searchCriteriaBuilder->addFilter(ExportEntityInterface::ENTITY_TYPE, $entityType); - $exportEntityList = $this->exportEntityRepository->getList($this->searchCriteriaBuilder->create()); - foreach ($exportEntityList->getItems() as $exportEntity) { + foreach ($entityIds as $entityId) { + $exportEntity = $this->exportEntityManagement->create($entityId, $entityType); $this->exportEntityManagement->export($exportEntity); - - $output->writeln( - 'Entity\'s related data have been exported to: ' . $exportEntity->getFilePath() . '.' - ); + $files[] = $exportEntity->getFilePath(); + $progressBar->advance(); + } + $progressBar->finish(); + $output->writeln('Entities data have been exported to:'); + foreach ($files as $file) { + $output->writeln($file); } } catch (Exception $e) { $output->writeln('' . $e->getMessage() . ''); diff --git a/Controller/Guest/Download.php b/Controller/Guest/Download.php index 2417b32b..8d790e24 100755 --- a/Controller/Guest/Download.php +++ b/Controller/Guest/Download.php @@ -53,7 +53,7 @@ public function __construct( protected function isAllowed(): bool { - return parent::isAllowed() && $this->config->isExportEnabled(); + return $this->config->isExportEnabled(); } protected function executeAction(): ResultInterface|ResponseInterface|Redirect diff --git a/Controller/Guest/Erase.php b/Controller/Guest/Erase.php index eb39ac11..56c9ea57 100644 --- a/Controller/Guest/Erase.php +++ b/Controller/Guest/Erase.php @@ -37,7 +37,7 @@ public function __construct( protected function isAllowed(): bool { - return parent::isAllowed() && $this->config->isErasureEnabled(); + return $this->config->isErasureEnabled(); } protected function executeAction(): Redirect diff --git a/Controller/Guest/Export.php b/Controller/Guest/Export.php index 8159eed7..2361ace6 100755 --- a/Controller/Guest/Export.php +++ b/Controller/Guest/Export.php @@ -38,7 +38,7 @@ public function __construct( protected function isAllowed(): bool { - return parent::isAllowed() && $this->config->isExportEnabled(); + return $this->config->isExportEnabled(); } protected function executeAction(): Redirect diff --git a/Controller/Guest/UndoErase.php b/Controller/Guest/UndoErase.php index f0e95faa..b8dd31d5 100644 --- a/Controller/Guest/UndoErase.php +++ b/Controller/Guest/UndoErase.php @@ -37,7 +37,7 @@ public function __construct( protected function isAllowed(): bool { - return parent::isAllowed() && $this->config->isErasureEnabled(); + return $this->config->isErasureEnabled(); } protected function executeAction(): Redirect diff --git a/Controller/Privacy/Download.php b/Controller/Privacy/Download.php index a84353a0..acabbc53 100755 --- a/Controller/Privacy/Download.php +++ b/Controller/Privacy/Download.php @@ -43,7 +43,7 @@ public function __construct( protected function isAllowed(): bool { - return parent::isAllowed() && $this->config->isExportEnabled(); + return $this->config->isExportEnabled(); } protected function executeAction(): ResultInterface|ResponseInterface|Redirect diff --git a/Controller/Privacy/Erase.php b/Controller/Privacy/Erase.php index 05b93845..bf1210d0 100755 --- a/Controller/Privacy/Erase.php +++ b/Controller/Privacy/Erase.php @@ -36,7 +36,7 @@ public function __construct( protected function isAllowed(): bool { - return parent::isAllowed() && $this->config->isErasureEnabled(); + return $this->config->isErasureEnabled(); } protected function executeAction(): Page|Redirect diff --git a/Controller/Privacy/ErasePost.php b/Controller/Privacy/ErasePost.php index 7bb81fae..263818bf 100755 --- a/Controller/Privacy/ErasePost.php +++ b/Controller/Privacy/ErasePost.php @@ -42,7 +42,7 @@ public function __construct( protected function isAllowed(): bool { - return parent::isAllowed() && $this->config->isErasureEnabled(); + return $this->config->isErasureEnabled(); } protected function executeAction(): Redirect diff --git a/Controller/Privacy/Export.php b/Controller/Privacy/Export.php index eb5ad6d0..9e563b44 100755 --- a/Controller/Privacy/Export.php +++ b/Controller/Privacy/Export.php @@ -38,7 +38,7 @@ public function __construct( protected function isAllowed(): bool { - return parent::isAllowed() && $this->config->isExportEnabled(); + return $this->config->isExportEnabled(); } protected function executeAction(): Redirect diff --git a/Controller/Privacy/UndoErase.php b/Controller/Privacy/UndoErase.php index e54e51e6..bd04b453 100755 --- a/Controller/Privacy/UndoErase.php +++ b/Controller/Privacy/UndoErase.php @@ -37,7 +37,7 @@ public function __construct( protected function isAllowed(): bool { - return parent::isAllowed() && $this->config->isErasureEnabled(); + return $this->config->isErasureEnabled(); } protected function executeAction(): Redirect diff --git a/Cron/EraseEntity.php b/Cron/EraseEntity.php index 0783e69b..3329f0d6 100755 --- a/Cron/EraseEntity.php +++ b/Cron/EraseEntity.php @@ -17,7 +17,6 @@ use Opengento\Gdpr\Api\Data\EraseEntitySearchResultsInterface; use Opengento\Gdpr\Api\EraseEntityManagementInterface; use Opengento\Gdpr\Api\EraseEntityRepositoryInterface; -use Opengento\Gdpr\Model\Config; use Psr\Log\LoggerInterface; /** @@ -27,7 +26,6 @@ class EraseEntity { public function __construct( private LoggerInterface $logger, - private Config $config, private Registry $registry, private EraseEntityManagementInterface $eraseManagement, private EraseEntityRepositoryInterface $eraseRepository, @@ -37,24 +35,27 @@ public function __construct( public function execute(): void { - if ($this->config->isModuleEnabled() && $this->config->isErasureEnabled()) { - $oldValue = $this->registry->registry('isSecureArea'); - $this->registry->register('isSecureArea', true, true); + $oldValue = $this->registry->registry('isSecureArea'); + $this->registry->register('isSecureArea', true, true); + try { foreach ($this->retrieveEraseEntityList()->getItems() as $eraseEntity) { try { $this->eraseManagement->process($eraseEntity); } catch (Exception $e) { - $this->logger->error($e->getMessage(), $e->getTrace()); + $this->logger->error($e->getMessage(), ['exception' => $e]); } } - - $this->registry->register('isSecureArea', $oldValue, true); + } catch (LocalizedException $e) { + $this->logger->error($e->getLogMessage(), ['exception' => $e]); } + + $this->registry->register('isSecureArea', $oldValue, true); } /** * @return EraseEntitySearchResultsInterface + * @throws LocalizedException */ private function retrieveEraseEntityList(): SearchResultsInterface { @@ -74,12 +75,6 @@ private function retrieveEraseEntityList(): SearchResultsInterface 'in' ); - try { - $eraseCustomerList = $this->eraseRepository->getList($this->criteriaBuilder->create()); - } catch (LocalizedException) { - $eraseCustomerList = []; - } - - return $eraseCustomerList; + return $this->eraseRepository->getList($this->criteriaBuilder->create()); } } diff --git a/Cron/EraseEntityScheduler.php b/Cron/EraseEntityScheduler.php index 4381dddd..5be647c0 100644 --- a/Cron/EraseEntityScheduler.php +++ b/Cron/EraseEntityScheduler.php @@ -7,13 +7,8 @@ namespace Opengento\Gdpr\Cron; -use DateTime; use Exception; -use Magento\Framework\Api\FilterBuilder; -use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Framework\Exception\CouldNotSaveException; -use Magento\Framework\Exception\LocalizedException; -use Magento\Store\Model\ScopeInterface; +use Magento\Store\Model\StoreManagerInterface; use Opengento\Gdpr\Model\Config; use Opengento\Gdpr\Model\Entity\EntityTypeList; use Opengento\Gdpr\Model\Erase\EraseEntityScheduler as EraseEntitySchedulerService; @@ -24,44 +19,26 @@ */ class EraseEntityScheduler { - private const CONFIG_PATH_ERASURE_MAX_AGE = 'gdpr/erasure/entity_max_age'; public function __construct( private LoggerInterface $logger, - private ScopeConfigInterface $scopeConfig, private Config $config, private EraseEntitySchedulerService $eraseEntityScheduler, - private FilterBuilder $filterBuilder, - private EntityTypeList $entityTypeList - ) { - } + private EntityTypeList $entityTypeList, + private StoreManagerInterface $storeManager + ) {} public function execute(): void { - if ($this->config->isModuleEnabled() && $this->config->isErasureEnabled()) { - try { - $this->scheduleEntitiesErasure(); - } catch (Exception $e) { - $this->logger->error($e->getMessage(), $e->getTrace()); + foreach ($this->storeManager->getWebsites() as $website) { + $websiteId = $website->getId(); + if ($this->config->isErasureEnabled($websiteId)) { + try { + $this->eraseEntityScheduler->schedule($this->entityTypeList->getEntityTypes(), $website); + } catch (Exception $e) { + $this->logger->error($e->getMessage(), ['exception' => $e]); + } } } } - - /** - * @throws CouldNotSaveException - * @throws LocalizedException - * @throws Exception - */ - private function scheduleEntitiesErasure(): void - { - $this->filterBuilder->setField('created_at'); - $this->filterBuilder->setValue(new DateTime('-' . $this->resolveErasureMaxAge() . 'days')); - $this->filterBuilder->setConditionType('lteq'); - $this->eraseEntityScheduler->schedule($this->entityTypeList->getEntityTypes(), $this->filterBuilder->create()); - } - - private function resolveErasureMaxAge(): int - { - return (int)$this->scopeConfig->getValue(self::CONFIG_PATH_ERASURE_MAX_AGE, ScopeInterface::SCOPE_STORE); - } } diff --git a/Cron/ExportEntity.php b/Cron/ExportEntity.php index 587e78d2..94ea42d4 100644 --- a/Cron/ExportEntity.php +++ b/Cron/ExportEntity.php @@ -13,7 +13,6 @@ use Opengento\Gdpr\Api\Data\ExportEntityInterface; use Opengento\Gdpr\Api\ExportEntityManagementInterface; use Opengento\Gdpr\Api\ExportEntityRepositoryInterface; -use Opengento\Gdpr\Model\Config; use Psr\Log\LoggerInterface; /** @@ -23,7 +22,6 @@ class ExportEntity { public function __construct( private LoggerInterface $logger, - private Config $config, private ExportEntityRepositoryInterface $exportRepository, private ExportEntityManagementInterface $exportManagement, private SearchCriteriaBuilder $criteriaBuilder @@ -31,24 +29,22 @@ public function __construct( public function execute(): void { - if ($this->config->isModuleEnabled() && $this->config->isExportEnabled()) { - $this->criteriaBuilder->addFilter(ExportEntityInterface::EXPORTED_AT, true, 'null'); - $this->criteriaBuilder->addFilter(ExportEntityInterface::FILE_PATH, true, 'null'); + $this->criteriaBuilder->addFilter(ExportEntityInterface::EXPORTED_AT, true, 'null'); + $this->criteriaBuilder->addFilter(ExportEntityInterface::FILE_PATH, true, 'null'); - try { - $exportList = $this->exportRepository->getList($this->criteriaBuilder->create()); + try { + $exportList = $this->exportRepository->getList($this->criteriaBuilder->create()); - foreach ($exportList->getItems() as $exportEntity) { - try { - $this->exportManagement->export($exportEntity); - } catch (NoSuchEntityException $e) { - $this->logger->error($e->getLogMessage(), $e->getTrace()); - $this->exportRepository->delete($exportEntity); - } + foreach ($exportList->getItems() as $exportEntity) { + try { + $this->exportManagement->export($exportEntity); + } catch (NoSuchEntityException $e) { + $this->logger->error($e->getLogMessage(), ['exception' => $e]); + $this->exportRepository->delete($exportEntity); } - } catch (Exception $e) { - $this->logger->critical($e->getMessage(), $e->getTrace()); } + } catch (Exception $e) { + $this->logger->critical($e->getMessage(), ['exception' => $e]); } } } diff --git a/Cron/ExportEntityExpired.php b/Cron/ExportEntityExpired.php index 17444ced..d372fb8f 100644 --- a/Cron/ExportEntityExpired.php +++ b/Cron/ExportEntityExpired.php @@ -22,29 +22,26 @@ class ExportEntityExpired { public function __construct( private LoggerInterface $logger, - private Config $config, private ExportEntityRepositoryInterface $exportRepository, private SearchCriteriaBuilder $criteriaBuilder ) {} public function execute(): void { - if ($this->config->isModuleEnabled() && $this->config->isExportEnabled()) { - $this->criteriaBuilder->addFilter( - ExportEntityInterface::EXPIRED_AT, - (new \DateTime())->format(DateTime::DATE_PHP_FORMAT), - 'lteq' - ); + $this->criteriaBuilder->addFilter( + ExportEntityInterface::EXPIRED_AT, + (new \DateTime())->format(DateTime::DATE_PHP_FORMAT), + 'lteq' + ); - try { - $exportList = $this->exportRepository->getList($this->criteriaBuilder->create()); + try { + $exportList = $this->exportRepository->getList($this->criteriaBuilder->create()); - foreach ($exportList->getItems() as $exportEntity) { - $this->exportRepository->delete($exportEntity); - } - } catch (Exception $e) { - $this->logger->error($e->getMessage(), $e->getTrace()); + foreach ($exportList->getItems() as $exportEntity) { + $this->exportRepository->delete($exportEntity); } + } catch (Exception $e) { + $this->logger->error($e->getMessage(), ['exception' => $e]); } } } diff --git a/Model/Archive/ArchiveManager.php b/Model/Archive/ArchiveManager.php index 2f2df505..8d525789 100644 --- a/Model/Archive/ArchiveManager.php +++ b/Model/Archive/ArchiveManager.php @@ -16,23 +16,12 @@ class ArchiveManager { - private ArchiveInterface $archive; - - private Filesystem $filesystem; - public function __construct( - ArchiveInterface $archive, - Filesystem $filesystem - ) { - $this->archive = $archive; - $this->filesystem = $filesystem; - } + private ArchiveInterface $archive, + private Filesystem $filesystem + ) {} /** - * @param string $source - * @param string $destination - * @param bool $remove [optional] Remove the source files from the file system. - * @return string * @throws FileSystemException * @throws NotFoundException */ diff --git a/Model/Archive/Zip.php b/Model/Archive/Zip.php index 38cfcb46..2bb47c59 100644 --- a/Model/Archive/Zip.php +++ b/Model/Archive/Zip.php @@ -20,28 +20,19 @@ */ class Zip implements ArchiveInterface { - private Filesystem $filesystem; - - /** - * @var ArchiveZip - */ - private ArchiveZip $zip; - public function __construct( - Filesystem $filesystem, - ArchiveZip $zip - ) { - $this->filesystem = $filesystem; - $this->zip = $zip; - } + private Filesystem $filesystem, + private ArchiveZip $zip + ) {} public function pack($source, $destination): string { - $directoryRead = $this->filesystem->getDirectoryReadByPath($source); - $zip = new ZipArchive(); $zip->open($destination, ZipArchive::CREATE); - $zip->addFile($source, $directoryRead->isDirectory($source) ? '' : basename($source)); + $zip->addFile( + $source, + $this->filesystem->getDirectoryReadByPath($source)->isDirectory($source) ? '' : basename($source) + ); $zip->close(); return $destination; diff --git a/Model/Config.php b/Model/Config.php index a0ca28df..dc6fa1f0 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -10,58 +10,28 @@ use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Store\Model\ScopeInterface; -use function explode; - class Config { - /** - * Scope Config: Data Settings Paths - */ - public const CONFIG_PATH_GENERAL_ENABLED = 'gdpr/general/enabled'; - public const CONFIG_PATH_ERASURE_ENABLED = 'gdpr/erasure/enabled'; - public const CONFIG_PATH_ERASURE_ALLOWED_STATES = 'gdpr/erasure/allowed_states'; - public const CONFIG_PATH_EXPORT_ENABLED = 'gdpr/export/enabled'; - - private ScopeConfigInterface $scopeConfig; - - public function __construct( - ScopeConfigInterface $scopeConfig - ) { - $this->scopeConfig = $scopeConfig; - } + private const CONFIG_PATH_GENERAL_ENABLED = 'gdpr/general/enabled'; + private const CONFIG_PATH_ERASURE_ENABLED = 'gdpr/erasure/enabled'; + private const CONFIG_PATH_EXPORT_ENABLED = 'gdpr/export/enabled'; - public function isModuleEnabled(): bool - { - return $this->scopeConfig->isSetFlag( - self::CONFIG_PATH_GENERAL_ENABLED, - ScopeInterface::SCOPE_STORE - ); - } + public function __construct(private ScopeConfigInterface $scopeConfig) {} - public function isErasureEnabled(): bool + public function isModuleEnabled(int|string|null $website = null): bool { - return $this->scopeConfig->isSetFlag( - self::CONFIG_PATH_ERASURE_ENABLED, - ScopeInterface::SCOPE_STORE - ); + return $this->scopeConfig->isSetFlag(self::CONFIG_PATH_GENERAL_ENABLED, ScopeInterface::SCOPE_WEBSITE, $website); } - /** - * @return string[] - */ - public function getAllowedStatesToErase(): array + public function isErasureEnabled(int|string|null $website = null): bool { - return explode(',', (string)$this->scopeConfig->getValue( - self::CONFIG_PATH_ERASURE_ALLOWED_STATES, - ScopeInterface::SCOPE_STORE - )); + return $this->isModuleEnabled($website) + && $this->scopeConfig->isSetFlag(self::CONFIG_PATH_ERASURE_ENABLED, ScopeInterface::SCOPE_WEBSITE, $website); } - public function isExportEnabled(): bool + public function isExportEnabled(int|string|null $website = null): bool { - return $this->scopeConfig->isSetFlag( - self::CONFIG_PATH_EXPORT_ENABLED, - ScopeInterface::SCOPE_STORE - ); + return $this->isModuleEnabled($website) + && $this->scopeConfig->isSetFlag(self::CONFIG_PATH_EXPORT_ENABLED, ScopeInterface::SCOPE_WEBSITE, $website); } } diff --git a/Model/Config/Backend/Export.php b/Model/Config/Backend/Export.php index ed7a1f53..52823b54 100644 --- a/Model/Config/Backend/Export.php +++ b/Model/Config/Backend/Export.php @@ -21,10 +21,6 @@ class Export extends Value { - private ExportEntityRepositoryInterface $exportRepository; - - private SearchCriteriaBuilder $criteriaBuilder; - public function __construct( Context $context, Registry $registry, @@ -32,12 +28,10 @@ public function __construct( TypeListInterface $cacheTypeList, AbstractResource $resource, AbstractDb $resourceCollection, - ExportEntityRepositoryInterface $exportRepository, - SearchCriteriaBuilder $criteriaBuilder, + private ExportEntityRepositoryInterface $exportRepository, + private SearchCriteriaBuilder $criteriaBuilder, array $data = [] ) { - $this->exportRepository = $exportRepository; - $this->criteriaBuilder = $criteriaBuilder; parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } @@ -49,9 +43,7 @@ public function __construct( public function afterSave(): self { if ($this->isValueChanged()) { - $exportList = $this->exportRepository->getList($this->criteriaBuilder->create()); - - foreach ($exportList->getItems() as $exportEntity) { + foreach ($this->exportRepository->getList($this->criteriaBuilder->create())->getItems() as $exportEntity) { $this->exportRepository->delete($exportEntity); } } diff --git a/Model/Config/Entity/Erasure.php b/Model/Config/Entity/Erasure.php new file mode 100644 index 00000000..e651df04 --- /dev/null +++ b/Model/Config/Entity/Erasure.php @@ -0,0 +1,54 @@ +scopeConfig->getValue( + self::CONFIG_PATH_ERASURE_MAX_AGE, + ScopeInterface::SCOPE_WEBSITE, + $website + ); + } + + /** + * @throws Exception + */ + public function getEntityExpireDate(int|string|null $website = null): DateTimeImmutable + { + return new DateTimeImmutable('-' . $this->getEntityMaxAge($website) . 'days'); + } + + /** + * @return string[] + */ + public function getAllowedStatesToErase(int|string|null $website = null): array + { + return explode(',', (string)$this->scopeConfig->getValue( + self::CONFIG_PATH_ERASURE_ALLOWED_STATES, + ScopeInterface::SCOPE_WEBSITE, + $website + )); + } +} diff --git a/Model/Customer/Anonymize/Processor/CustomerDataProcessor.php b/Model/Customer/Anonymize/Processor/CustomerDataProcessor.php index f586ec20..c13463d9 100644 --- a/Model/Customer/Anonymize/Processor/CustomerDataProcessor.php +++ b/Model/Customer/Anonymize/Processor/CustomerDataProcessor.php @@ -78,7 +78,7 @@ private function processCustomerData(int $customerId): void $this->origDataRegistry->set(clone $customer); $isRemoved = false; - if ($this->shouldRemoveCustomerWithoutOrders() && !$this->fetchOrdersList($customer)->getTotalCount()) { + if ($this->shouldRemoveCustomerWithoutOrders($customer) && !$this->fetchOrdersList($customer)->getTotalCount()) { $isRemoved = $this->customerRepository->deleteById($customer->getId()); } if (!$isRemoved) { @@ -116,8 +116,12 @@ private function anonymizeCustomer(CustomerInterface $customer): void $this->customerRepository->save($customer); } - private function shouldRemoveCustomerWithoutOrders(): bool + private function shouldRemoveCustomerWithoutOrders(CustomerInterface $customer): bool { - return $this->scopeConfig->isSetFlag(self::CONFIG_PATH_ERASURE_REMOVE_CUSTOMER, ScopeInterface::SCOPE_STORE); + return $this->scopeConfig->isSetFlag( + self::CONFIG_PATH_ERASURE_REMOVE_CUSTOMER, + ScopeInterface::SCOPE_WEBSITE, + $customer->getWebsiteId() + ); } } diff --git a/Model/Customer/CustomerChecker.php b/Model/Customer/CustomerChecker.php index a7421e10..2b5449bd 100644 --- a/Model/Customer/CustomerChecker.php +++ b/Model/Customer/CustomerChecker.php @@ -9,21 +9,21 @@ use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Model\ResourceModel\Order\CollectionFactory; -use Opengento\Gdpr\Model\Config; +use Opengento\Gdpr\Model\Config\Entity\Erasure as ErasureConfig; use Opengento\Gdpr\Model\Entity\EntityCheckerInterface; class CustomerChecker implements EntityCheckerInterface { public function __construct( private CollectionFactory $collectionFactory, - private Config $config + private ErasureConfig $erasureConfig ) {} - public function canErase(int $customerId): bool + public function canErase(int $entityId): bool { $collection = $this->collectionFactory->create(); - $collection->addFieldToFilter(OrderInterface::CUSTOMER_ID, $customerId); - $collection->addFieldToFilter(OrderInterface::STATE, ['nin' => $this->config->getAllowedStatesToErase()]); + $collection->addFieldToFilter(OrderInterface::CUSTOMER_ID, $entityId); + $collection->addFieldToFilter(OrderInterface::STATE, ['nin' => $this->erasureConfig->getAllowedStatesToErase()]);//ToDo scope Website return $collection->getSize() > 0; } diff --git a/Model/Customer/Erase/Notifier.php b/Model/Customer/Erase/Notifier.php index b0ce7fae..7c4e9b57 100644 --- a/Model/Customer/Erase/Notifier.php +++ b/Model/Customer/Erase/Notifier.php @@ -51,7 +51,7 @@ public function notify(EraseEntityInterface $eraseEntity): void try { $sender->send($customer); } catch (LocalizedException $e) { - $this->logger->error($e->getLogMessage(), $e->getTrace()); + $this->logger->error($e->getLogMessage(), ['exception' => $e]); } } } diff --git a/Model/Customer/Export/Notifier.php b/Model/Customer/Export/Notifier.php index d53f4864..524dfdbe 100644 --- a/Model/Customer/Export/Notifier.php +++ b/Model/Customer/Export/Notifier.php @@ -45,7 +45,7 @@ public function notify(ExportEntityInterface $exportEntity): void try { $sender->send($customer); } catch (LocalizedException $e) { - $this->logger->error($e->getLogMessage(), $e->getTrace()); + $this->logger->error($e->getLogMessage(), ['exception' => $e]); } } } diff --git a/Model/Customer/SourceProvider/IdleFilterModifier.php b/Model/Customer/SourceProvider/IdleFilterModifier.php index a366e214..6f08c2fc 100644 --- a/Model/Customer/SourceProvider/IdleFilterModifier.php +++ b/Model/Customer/SourceProvider/IdleFilterModifier.php @@ -7,40 +7,47 @@ namespace Opengento\Gdpr\Model\Customer\SourceProvider; -use Magento\Framework\Api\Filter; -use Magento\Framework\Data\Collection; +use Exception; +use Magento\Framework\Data\Collection\AbstractDb; +use Magento\Store\Api\Data\WebsiteInterface; +use Opengento\Gdpr\Model\Config\Entity\Erasure as ErasureConfig; use Opengento\Gdpr\Model\Entity\SourceProvider\ModifierInterface; class IdleFilterModifier implements ModifierInterface { - public function apply(Collection $collection, Filter $filter): void + public function __construct( + private ErasureConfig $erasureConfig + ) {} + + /** + * @throws Exception + */ + public function apply(AbstractDb $collection, WebsiteInterface $website): void { - if ($collection instanceof Collection\AbstractDb && $filter->getField() === 'created_at') { - $connection = $collection->getConnection(); + $connection = $collection->getConnection(); - $visitorSelect = $connection->select() - ->from( - $connection->getTableName('customer_visitor'), - ['customer_id' => 'customer_id', 'last_visit_at' => 'MAX(last_visit_at)'] - ) - ->group(['customer_id']); + $visitorSelect = $connection->select() + ->from( + $connection->getTableName('customer_visitor'), + ['customer_id' => 'customer_id', 'last_visit_at' => 'MAX(last_visit_at)'] + ) + ->group(['customer_id']); - $collection->getSelect()->joinLeft( - ['cv' => $visitorSelect], - 'e.entity_id=cv.customer_id', - null - ); - $collection->getSelect()->joinLeft( - ['cl' => $connection->getTableName('customer_log')], - 'e.entity_id=cl.customer_id', - null - ); - $collection->getSelect()->where( - $connection->prepareSqlCondition( - 'IFNULL(cv.last_visit_at, GREATEST(IFNULL(cl.last_login_at, e.created_at), IFNULL(cl.last_logout_at, e.updated_at)))', - [$filter->getConditionType() => $filter->getValue()] - ) - ); - } + $collection->getSelect()->joinLeft( + ['cv' => $visitorSelect], + 'e.entity_id=cv.customer_id', + null + ); + $collection->getSelect()->joinLeft( + ['cl' => $connection->getTableName('customer_log')], + 'e.entity_id=cl.customer_id', + null + ); + $collection->getSelect()->where( + $connection->prepareSqlCondition( + 'IFNULL(cv.last_visit_at, GREATEST(IFNULL(cl.last_login_at, e.created_at), IFNULL(cl.last_logout_at, e.updated_at)))', + ['lteq' => $this->erasureConfig->getEntityExpireDate($website->getId())] + ) + ); } } diff --git a/Model/Entity/SourceProvider/ExpireFilterModifier.php b/Model/Entity/SourceProvider/ExpireFilterModifier.php new file mode 100644 index 00000000..1a5c5bbb --- /dev/null +++ b/Model/Entity/SourceProvider/ExpireFilterModifier.php @@ -0,0 +1,32 @@ +addFieldToFilter( + $this->fieldToFilter, + ['lteq' => $this->erasureConfig->getEntityExpireDate($website->getId())] + ); + } +} diff --git a/Model/Entity/SourceProvider/FilterModifier.php b/Model/Entity/SourceProvider/FilterModifier.php deleted file mode 100644 index e9108b48..00000000 --- a/Model/Entity/SourceProvider/FilterModifier.php +++ /dev/null @@ -1,41 +0,0 @@ -filterIdentifier = $filterIdentifier; - $this->fieldToFilter = $fieldToFilter; - } - - /** - * @inheritdoc - * @throws LocalizedException - */ - public function apply(Collection $collection, Filter $filter): void - { - if ($filter->getField() === $this->filterIdentifier) { - $collection->addFieldToFilter( - $this->fieldToFilter, - [$filter->getConditionType() => $filter->getValue()] - ); - } - } -} diff --git a/Model/Entity/SourceProvider/ModifierComposite.php b/Model/Entity/SourceProvider/ModifierComposite.php index 1af430e9..dc8ebf2b 100644 --- a/Model/Entity/SourceProvider/ModifierComposite.php +++ b/Model/Entity/SourceProvider/ModifierComposite.php @@ -7,29 +7,20 @@ namespace Opengento\Gdpr\Model\Entity\SourceProvider; -use Magento\Framework\Api\Filter; -use Magento\Framework\Data\Collection; +use Magento\Framework\Data\Collection\AbstractDb; +use Magento\Store\Api\Data\WebsiteInterface; /** * @api */ class ModifierComposite implements ModifierInterface { - /** - * @var ModifierInterface[] - */ - private array $modifiers; + public function __construct(private array $modifiers = []) {} - public function __construct( - array $modifiers - ) { - $this->modifiers = $modifiers; - } - - public function apply(Collection $collection, Filter $filter): void + public function apply(AbstractDb $collection, WebsiteInterface $website): void { foreach ($this->modifiers as $modifier) { - $modifier->apply($collection, $filter); + $modifier->apply($collection, $website); } } } diff --git a/Model/Entity/SourceProvider/ModifierInterface.php b/Model/Entity/SourceProvider/ModifierInterface.php index dcf49935..eb940cfc 100644 --- a/Model/Entity/SourceProvider/ModifierInterface.php +++ b/Model/Entity/SourceProvider/ModifierInterface.php @@ -7,13 +7,13 @@ namespace Opengento\Gdpr\Model\Entity\SourceProvider; -use Magento\Framework\Api\Filter; -use Magento\Framework\Data\Collection; +use Magento\Framework\Data\Collection\AbstractDb; +use Magento\Store\Api\Data\WebsiteInterface; /** * @api */ interface ModifierInterface { - public function apply(Collection $collection, Filter $filter): void; + public function apply(AbstractDb $collection, WebsiteInterface $website): void; } diff --git a/Model/Entity/SourceProvider/NotErasedFilterModifier.php b/Model/Entity/SourceProvider/NotErasedFilterModifier.php index 709f02c4..96ceca86 100644 --- a/Model/Entity/SourceProvider/NotErasedFilterModifier.php +++ b/Model/Entity/SourceProvider/NotErasedFilterModifier.php @@ -7,47 +7,32 @@ namespace Opengento\Gdpr\Model\Entity\SourceProvider; -use Magento\Framework\Api\Filter; -use Magento\Framework\Data\Collection; use Magento\Framework\Data\Collection\AbstractDb; +use Magento\Store\Api\Data\WebsiteInterface; use function sprintf; class NotErasedFilterModifier implements ModifierInterface { private const DEFAULT_PRIMARY_FIELD = 'entity_id'; - private const DEFAULT_MAIN_TABLE_ALIAS = 'main_table'; - private const JOIN_ON = '%s.%s=ogee.entity_id AND ogee.entity_type="%s"'; - private string $entityType; - - private string $entityPrimaryField; - - private string $mainTableAlias; - public function __construct( - string $entityType, - string $entityPrimaryField = self::DEFAULT_PRIMARY_FIELD, - string $mainTableAlias = self::DEFAULT_MAIN_TABLE_ALIAS - ) { - $this->entityType = $entityType; - $this->entityPrimaryField = $entityPrimaryField; - $this->mainTableAlias = $mainTableAlias; - } + private string $entityType, + private string $entityPrimaryField = self::DEFAULT_PRIMARY_FIELD, + private string $mainTableAlias = self::DEFAULT_MAIN_TABLE_ALIAS + ) {} - public function apply(Collection $collection, Filter $filter): void + public function apply(AbstractDb $collection, WebsiteInterface $website): void { - if ($collection instanceof AbstractDb) { - $connection = $collection->getConnection(); - $select = $collection->getSelect(); - $select->joinLeft( - ['ogee' => $connection->getTableName('opengento_gdpr_erase_entity')], - sprintf(self::JOIN_ON, $this->mainTableAlias, $this->entityPrimaryField, $this->entityType), - [''] - ); - $select->where('ogee.erase_id IS NULL'); - } + $connection = $collection->getConnection(); + $select = $collection->getSelect(); + $select->joinLeft( + ['ogee' => $connection->getTableName('opengento_gdpr_erase_entity')], + sprintf(self::JOIN_ON, $this->mainTableAlias, $this->entityPrimaryField, $this->entityType), + [''] + ); + $select->where('ogee.erase_id IS NULL'); } } diff --git a/Model/Entity/SourceProviderFactory.php b/Model/Entity/SourceProviderFactory.php index 7efb324f..02ce18b5 100644 --- a/Model/Entity/SourceProviderFactory.php +++ b/Model/Entity/SourceProviderFactory.php @@ -8,7 +8,7 @@ namespace Opengento\Gdpr\Model\Entity; use InvalidArgumentException; -use Magento\Framework\Data\Collection; +use Magento\Framework\Data\Collection\AbstractDb; use Magento\Framework\ObjectManagerInterface; use function sprintf; @@ -18,26 +18,15 @@ */ class SourceProviderFactory { - /** - * @var string[] - */ - private array $sourceProviders; - - private ObjectManagerInterface $objectManager; - /** * @param string[] $sourceProviders - * @param ObjectManagerInterface $objectManager */ public function __construct( - array $sourceProviders, - ObjectManagerInterface $objectManager - ) { - $this->sourceProviders = $sourceProviders; - $this->objectManager = $objectManager; - } + private array $sourceProviders, + private ObjectManagerInterface $objectManager + ) {} - public function create(string $entityType): Collection + public function create(string $entityType): AbstractDb { if (!isset($this->sourceProviders[$entityType])) { throw new InvalidArgumentException(sprintf('Unknown source provider for entity type "%s".', $entityType)); diff --git a/Model/Erase/EraseEntityScheduler.php b/Model/Erase/EraseEntityScheduler.php index a3b490fe..53498bfa 100644 --- a/Model/Erase/EraseEntityScheduler.php +++ b/Model/Erase/EraseEntityScheduler.php @@ -8,44 +8,33 @@ namespace Opengento\Gdpr\Model\Erase; use Generator; -use Magento\Framework\Api\Filter; use Magento\Framework\Exception\CouldNotSaveException; use Magento\Framework\Exception\LocalizedException; +use Magento\Store\Api\Data\WebsiteInterface; use Opengento\Gdpr\Api\EraseEntityManagementInterface; use Opengento\Gdpr\Model\Entity\SourceProvider\ModifierFactory; use Opengento\Gdpr\Model\Entity\SourceProviderFactory; class EraseEntityScheduler { - private SourceProviderFactory $srcProviderFactory; - - private ModifierFactory $modifierFactory; - - private EraseEntityManagementInterface $eraseManagement; - public function __construct( - SourceProviderFactory $srcProviderFactory, - ModifierFactory $modifierFactory, - EraseEntityManagementInterface $eraseManagement - ) { - $this->srcProviderFactory = $srcProviderFactory; - $this->modifierFactory = $modifierFactory; - $this->eraseManagement = $eraseManagement; - } + private SourceProviderFactory $srcProviderFactory, + private ModifierFactory $modifierFactory, + private EraseEntityManagementInterface $eraseManagement + ) {} /** * @param string[] $entityTypes - * @param Filter $filter * @throws CouldNotSaveException * @throws LocalizedException */ - public function schedule(array $entityTypes, Filter $filter): void + public function schedule(array $entityTypes, WebsiteInterface $website): void { /** * @var string $entityType * @var string[] $entityIds */ - foreach ($this->collectEntityIds($entityTypes, $filter) as $entityType => $entityIds) { + foreach ($this->collectEntityIds($entityTypes, $website) as $entityType => $entityIds) { foreach ($entityIds as $entityId) { $this->eraseManagement->create((int)$entityId, $entityType); } @@ -54,14 +43,12 @@ public function schedule(array $entityTypes, Filter $filter): void /** * @param string[] $entityTypes - * @param Filter $filter - * @return Generator */ - private function collectEntityIds(array $entityTypes, Filter $filter): Generator + private function collectEntityIds(array $entityTypes, WebsiteInterface $website): Generator { foreach ($entityTypes as $entityType) { $source = $this->srcProviderFactory->create($entityType); - $this->modifierFactory->get($entityType)->apply($source, $filter); + $this->modifierFactory->get($entityType)->apply($source, $website); yield $entityType => $source->getAllIds(); } diff --git a/Model/Erase/EraseSalesInformation.php b/Model/Erase/EraseSalesInformation.php index e9e40072..ca641ca1 100644 --- a/Model/Erase/EraseSalesInformation.php +++ b/Model/Erase/EraseSalesInformation.php @@ -62,6 +62,6 @@ public function isAlive(DateTimeInterface $lastActive): bool private function resolveErasureSalesMaxAge(): int { - return (int)$this->scopeConfig->getValue(self::CONFIG_PATH_ERASURE_SALES_MAX_AGE, ScopeInterface::SCOPE_STORE); + return (int)$this->scopeConfig->getValue(self::CONFIG_PATH_ERASURE_SALES_MAX_AGE, ScopeInterface::SCOPE_STORE);//Todo scope website } } diff --git a/Model/EraseEntityManagement.php b/Model/EraseEntityManagement.php index bf694411..40230c9b 100644 --- a/Model/EraseEntityManagement.php +++ b/Model/EraseEntityManagement.php @@ -122,6 +122,6 @@ private function retrieveScheduledAt(): string private function resolveErasureDelay(): int { - return (int)$this->scopeConfig->getValue(self::CONFIG_PATH_ERASURE_DELAY, ScopeInterface::SCOPE_STORE); + return (int)$this->scopeConfig->getValue(self::CONFIG_PATH_ERASURE_DELAY, ScopeInterface::SCOPE_STORE);//Todo scope website } } diff --git a/Model/Export/ExportToFile.php b/Model/Export/ExportToFile.php index 7080b503..f0e58540 100644 --- a/Model/Export/ExportToFile.php +++ b/Model/Export/ExportToFile.php @@ -73,7 +73,7 @@ public function resolveExportRendererCodes(): array { return explode(',', (string)$this->scopeConfig->getValue( self::CONFIG_PATH_EXPORT_RENDERERS, - ScopeInterface::SCOPE_STORE + ScopeInterface::SCOPE_STORE //ToDo scope website )); } diff --git a/Model/ExportEntityManagement.php b/Model/ExportEntityManagement.php index 0eb094b1..0192ea56 100644 --- a/Model/ExportEntityManagement.php +++ b/Model/ExportEntityManagement.php @@ -80,7 +80,7 @@ public function create(int $entityId, string $entityType, ?string $fileName = nu */ public function export(ExportEntityInterface $exportEntity): ExportEntityInterface { - $lifeTime = (int)$this->scopeConfig->getValue(self::CONFIG_PATH_EXPORT_LIFE_TIME, ScopeInterface::SCOPE_STORE); + $lifeTime = (int)$this->scopeConfig->getValue(self::CONFIG_PATH_EXPORT_LIFE_TIME, ScopeInterface::SCOPE_STORE);//Todo scope website $exportEntity->setFilePath($this->exportToFile->export($exportEntity)); $exportEntity->setExpiredAt( (new DateTime('+' . $lifeTime . 'minutes'))->format(DateTimeFormat::DATETIME_PHP_FORMAT) @@ -100,6 +100,6 @@ public function invalidate(ExportEntityInterface $exportEntity): ExportEntityInt private function resolveDefaultFileName(): string { - return (string)$this->scopeConfig->getValue(self::CONFIG_PATH_EXPORT_FILE_NAME, ScopeInterface::SCOPE_STORE); + return (string)$this->scopeConfig->getValue(self::CONFIG_PATH_EXPORT_FILE_NAME, ScopeInterface::SCOPE_STORE);//Todo scope website } } diff --git a/Model/Order/Erase/Notifier.php b/Model/Order/Erase/Notifier.php index 3976753f..5e3c7a86 100644 --- a/Model/Order/Erase/Notifier.php +++ b/Model/Order/Erase/Notifier.php @@ -41,7 +41,7 @@ public function notify(EraseEntityInterface $eraseEntity): void try { $sender->send($order); } catch (LocalizedException $e) { - $this->logger->error($e->getLogMessage(), $e->getTrace()); + $this->logger->error($e->getLogMessage(), ['exception' => $e]); } } } diff --git a/Model/Order/Export/Notifier.php b/Model/Order/Export/Notifier.php index f1be5a36..7261ebf3 100644 --- a/Model/Order/Export/Notifier.php +++ b/Model/Order/Export/Notifier.php @@ -44,7 +44,7 @@ public function notify(ExportEntityInterface $exportEntity): void try { $sender->send($order); } catch (LocalizedException $e) { - $this->logger->error($e->getLogMessage(), $e->getTrace()); + $this->logger->error($e->getLogMessage(), ['exception' => $e]); } } } diff --git a/Model/Order/OrderChecker.php b/Model/Order/OrderChecker.php index 1668ef6e..3fefb907 100644 --- a/Model/Order/OrderChecker.php +++ b/Model/Order/OrderChecker.php @@ -7,8 +7,11 @@ namespace Opengento\Gdpr\Model\Order; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Api\OrderRepositoryInterface; -use Opengento\Gdpr\Model\Config; +use Magento\Store\Model\StoreManagerInterface; +use Opengento\Gdpr\Model\Config\Entity\Erasure as ErasureConfig; use Opengento\Gdpr\Model\Entity\EntityCheckerInterface; use function in_array; @@ -17,13 +20,33 @@ class OrderChecker implements EntityCheckerInterface { public function __construct( private OrderRepositoryInterface $orderRepository, - private Config $config + private StoreManagerInterface $storeManager, + private ErasureConfig $erasureConfig ) {} - public function canErase(int $orderId): bool + /** + * @throws NoSuchEntityException + */ + public function canErase(int $entityId): bool { - $order = $this->orderRepository->get($orderId); + $order = $this->orderRepository->get($entityId); - return in_array($order->getState(), $this->config->getAllowedStatesToErase(), true); + return in_array($order->getState(), $this->allowedStates($order), true); + } + + /** + * @throws NoSuchEntityException + */ + private function allowedStates(OrderInterface $order): array + { + return $this->erasureConfig->getAllowedStatesToErase($this->resolveWebsiteId($order)); + } + + /** + * @throws NoSuchEntityException + */ + private function resolveWebsiteId(OrderInterface $order): int + { + return (int)$this->storeManager->getStore($order->getStoreId())->getWebsiteId(); } } diff --git a/Model/Order/SourceProvider/GuestFilterModifier.php b/Model/Order/SourceProvider/GuestFilterModifier.php index a669de0f..5e97df3a 100644 --- a/Model/Order/SourceProvider/GuestFilterModifier.php +++ b/Model/Order/SourceProvider/GuestFilterModifier.php @@ -7,30 +7,23 @@ namespace Opengento\Gdpr\Model\Order\SourceProvider; -use Magento\Framework\Api\Filter; -use Magento\Framework\Data\Collection; -use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Data\Collection\AbstractDb; use Magento\Sales\Api\Data\OrderInterface; -use Opengento\Gdpr\Model\Config; +use Magento\Store\Api\Data\WebsiteInterface; +use Opengento\Gdpr\Model\Config\Entity\Erasure as ErasureConfig; use Opengento\Gdpr\Model\Entity\SourceProvider\ModifierInterface; class GuestFilterModifier implements ModifierInterface { - private Config $config; + public function __construct(private ErasureConfig $erasureConfig) {} - public function __construct(Config $config) - { - $this->config = $config; - } - - /** - * @inheritdoc - * @throws LocalizedException - */ - public function apply(Collection $collection, Filter $filter): void + public function apply(AbstractDb $collection, WebsiteInterface $website): void { $collection->addFieldToFilter(OrderInterface::CUSTOMER_ID, ['null' => true]); $collection->addFieldToFilter(OrderInterface::CUSTOMER_IS_GUEST, ['eq' => 1]); - $collection->addFieldToFilter(OrderInterface::STATE, ['in' => $this->config->getAllowedStatesToErase()]); + $collection->addFieldToFilter( + OrderInterface::STATE, + ['in' => $this->erasureConfig->getAllowedStatesToErase($website->getId())] + ); } } diff --git a/Observer/DeleteExport.php b/Observer/DeleteExport.php index eb97ba65..502383f9 100644 --- a/Observer/DeleteExport.php +++ b/Observer/DeleteExport.php @@ -59,9 +59,9 @@ public function execute(Observer $observer): void $this->exportRepository->delete($exportEntity); } } catch (LocalizedException $e) { - $this->logger->error($e->getLogMessage(), $e->getTrace()); + $this->logger->error($e->getLogMessage(), ['exception' => $e]); } catch (Exception $e) { - $this->logger->error($e->getMessage(), $e->getTrace()); + $this->logger->error($e->getMessage(), ['exception' => $e]); } } } diff --git a/Observer/InvalidateExport.php b/Observer/InvalidateExport.php index ec5eaa84..f7feaabb 100644 --- a/Observer/InvalidateExport.php +++ b/Observer/InvalidateExport.php @@ -63,9 +63,9 @@ public function execute(Observer $observer): void $this->exportManagement->invalidate($exportEntity); } } catch (LocalizedException $e) { - $this->logger->error($e->getLogMessage(), $e->getTrace()); + $this->logger->error($e->getLogMessage(), ['exception' => $e]); } catch (Exception $e) { - $this->logger->error($e->getMessage(), $e->getTrace()); + $this->logger->error($e->getMessage(), ['exception' => $e]); } } } diff --git a/etc/db_schema.xml b/etc/db_schema.xml index b80e24a5..3743380b 100644 --- a/etc/db_schema.xml +++ b/etc/db_schema.xml @@ -56,23 +56,4 @@
- - - - - - - - - - - - - - - - - - -
diff --git a/etc/db_schema_whitelist.json b/etc/db_schema_whitelist.json index 8829420a..5fbd8e89 100644 --- a/etc/db_schema_whitelist.json +++ b/etc/db_schema_whitelist.json @@ -42,24 +42,5 @@ "constraint": { "PRIMARY": true } - }, - "opengento_gdpr_action_entity": { - "column": { - "action_id": true, - "type": true, - "performed_from": true, - "performed_by": true, - "performed_at": true, - "state": true, - "message": true, - "parameters": true - }, - "index": { - "OPENGENTO_GDPR_ACTION_ENTITY_TYPE": true, - "OPENGENTO_GDPR_ACTION_ENTITY_STATE": true - }, - "constraint": { - "PRIMARY": true - } } -} \ No newline at end of file +} diff --git a/etc/di.xml b/etc/di.xml index 9ed029b7..02da0457 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -696,9 +696,8 @@ Opengento\Gdpr\Model\Config\Source\Order\EraseComponents - + - created_at Magento\Sales\Api\Data\OrderInterface::UPDATED_AT @@ -711,7 +710,7 @@ Opengento\Gdpr\Model\Order\SourceProvider\GuestFilterModifier - Opengento\Gdpr\Model\Order\SourceProvider\UpdatedAtFilterModifier + Opengento\Gdpr\Model\Order\SourceProvider\ExpireFilterModifier Opengento\Gdpr\Model\Order\SourceProvider\NotErasedFilterModifier @@ -733,16 +732,15 @@ - + - created_at created_at - Opengento\Gdpr\Model\Entity\SourceProvider\DefaultFilterModifier + Opengento\Gdpr\Model\Entity\SourceProvider\DefaultExpireFilterModifier From 24eb48724dd99cb61fafd780ee56e5fa1488d18a Mon Sep 17 00:00:00 2001 From: Thomas Klein Date: Sat, 3 Aug 2024 23:51:32 +0200 Subject: [PATCH 08/31] Fix nullable properties --- Model/Customer/CustomerChecker.php | 8 ++++- Observer/DeleteExport.php | 30 ++++------------ Observer/InvalidateExport.php | 36 ++++--------------- .../Customer/Guest/EraseDataProvider.php | 30 ++++------------ .../Customer/Guest/ExportDataProvider.php | 30 ++++------------ .../Privacy/EraseCustomerDataProvider.php | 27 +++----------- .../Customer/Privacy/EraseDataProvider.php | 18 +++------- .../Privacy/ExportCustomerDataProvider.php | 27 +++----------- .../Customer/Privacy/ExportDataProvider.php | 15 +++----- .../Customer/Privacy/SettingsDataProvider.php | 15 +++----- 10 files changed, 57 insertions(+), 179 deletions(-) diff --git a/Model/Customer/CustomerChecker.php b/Model/Customer/CustomerChecker.php index 2b5449bd..67fb9844 100644 --- a/Model/Customer/CustomerChecker.php +++ b/Model/Customer/CustomerChecker.php @@ -7,6 +7,7 @@ namespace Opengento\Gdpr\Model\Customer; +use Magento\Customer\Api\CustomerRepositoryInterface; use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Model\ResourceModel\Order\CollectionFactory; use Opengento\Gdpr\Model\Config\Entity\Erasure as ErasureConfig; @@ -15,15 +16,20 @@ class CustomerChecker implements EntityCheckerInterface { public function __construct( + private CustomerRepositoryInterface $customerRepository, private CollectionFactory $collectionFactory, private ErasureConfig $erasureConfig ) {} public function canErase(int $entityId): bool { + $customer = $this->customerRepository->getById($entityId); $collection = $this->collectionFactory->create(); $collection->addFieldToFilter(OrderInterface::CUSTOMER_ID, $entityId); - $collection->addFieldToFilter(OrderInterface::STATE, ['nin' => $this->erasureConfig->getAllowedStatesToErase()]);//ToDo scope Website + $collection->addFieldToFilter( + OrderInterface::STATE, + ['nin' => $this->erasureConfig->getAllowedStatesToErase($customer->getWebsiteId())] + ); return $collection->getSize() > 0; } diff --git a/Observer/DeleteExport.php b/Observer/DeleteExport.php index 502383f9..90212850 100644 --- a/Observer/DeleteExport.php +++ b/Observer/DeleteExport.php @@ -24,33 +24,16 @@ class DeleteExport implements ObserverInterface { - private ExportEntityRepositoryInterface $exportRepository; - - private SearchCriteriaBuilder $criteriaBuilder; - - private FilterBuilder $filterBuilder; - - private EntityTypeResolver $entityTypeResolver; - - private LoggerInterface $logger; - public function __construct( - ExportEntityRepositoryInterface $exportRepository, - SearchCriteriaBuilder $criteriaBuilder, - FilterBuilder $filterBuilder, - EntityTypeResolver $entityTypeResolver, - LoggerInterface $logger - ) { - $this->exportRepository = $exportRepository; - $this->criteriaBuilder = $criteriaBuilder; - $this->filterBuilder = $filterBuilder; - $this->entityTypeResolver = $entityTypeResolver; - $this->logger = $logger; - } + private ExportEntityRepositoryInterface $exportRepository, + private SearchCriteriaBuilder $criteriaBuilder, + private FilterBuilder $filterBuilder, + private EntityTypeResolver $entityTypeResolver, + private LoggerInterface $logger + ) {} public function execute(Observer $observer): void { - /** @var DataObject $entity */ $entity = $observer->getData('data_object'); if ($entity instanceof DataObject) { @@ -67,7 +50,6 @@ public function execute(Observer $observer): void } /** - * @param DataObject $entity * @return ExportEntitySearchResultsInterface * @throws LocalizedException * @throws Exception diff --git a/Observer/InvalidateExport.php b/Observer/InvalidateExport.php index f7feaabb..2a499ba5 100644 --- a/Observer/InvalidateExport.php +++ b/Observer/InvalidateExport.php @@ -25,38 +25,17 @@ class InvalidateExport implements ObserverInterface { - private ExportEntityRepositoryInterface $exportRepository; - - private ExportEntityManagementInterface $exportManagement; - - private SearchCriteriaBuilder $criteriaBuilder; - - private FilterBuilder $filterBuilder; - - private EntityTypeResolver $entityTypeResolver; - - private LoggerInterface $logger; - public function __construct( - ExportEntityRepositoryInterface $exportRepository, - ExportEntityManagementInterface $exportManagement, - SearchCriteriaBuilder $criteriaBuilder, - FilterBuilder $filterBuilder, - EntityTypeResolver $entityTypeResolver, - LoggerInterface $logger - ) { - $this->exportRepository = $exportRepository; - $this->exportManagement = $exportManagement; - $this->criteriaBuilder = $criteriaBuilder; - $this->filterBuilder = $filterBuilder; - $this->entityTypeResolver = $entityTypeResolver; - $this->logger = $logger; - } + private ExportEntityRepositoryInterface $exportRepository, + private ExportEntityManagementInterface $exportManagement, + private SearchCriteriaBuilder $criteriaBuilder, + private FilterBuilder $filterBuilder, + private EntityTypeResolver $entityTypeResolver, + private LoggerInterface $logger + ) {} public function execute(Observer $observer): void { - $entity = $observer->getData('data_object'); - if ($entity instanceof DataObject) { try { foreach ($this->fetchExportEntities($entity)->getItems() as $exportEntity) { @@ -71,7 +50,6 @@ public function execute(Observer $observer): void } /** - * @param DataObject $entity * @return ExportEntitySearchResultsInterface * @throws LocalizedException * @throws Exception diff --git a/ViewModel/Customer/Guest/EraseDataProvider.php b/ViewModel/Customer/Guest/EraseDataProvider.php index 1ad7434b..31777eec 100644 --- a/ViewModel/Customer/Guest/EraseDataProvider.php +++ b/ViewModel/Customer/Guest/EraseDataProvider.php @@ -14,38 +14,22 @@ class EraseDataProvider implements ArgumentInterface { - private EraseEntityCheckerInterface $eraseEntityChecker; - - private Registry $registry; - - /** - * @var null|bool - */ - private ?bool $canCancel; - - /** - * @var null|bool - */ - private ?bool $canCreate; + private ?bool $canCancel = null; + private ?bool $canCreate = null; public function __construct( - EraseEntityCheckerInterface $eraseEntityChecker, - Registry $registry - ) { - $this->eraseEntityChecker = $eraseEntityChecker; - $this->registry = $registry; - } + private EraseEntityCheckerInterface $eraseEntityChecker, + private Registry $registry + ) {} public function canCancel(): bool { - return $this->canCancel ?? - $this->canCancel = $this->eraseEntityChecker->canCancel($this->currentOrderId(), 'order'); + return $this->canCancel ??= $this->eraseEntityChecker->canCancel($this->currentOrderId(), 'order'); } public function canCreate(): bool { - return $this->canCreate ?? - $this->canCreate = $this->eraseEntityChecker->canCreate($this->currentOrderId(), 'order'); + return $this->canCreate ??= $this->eraseEntityChecker->canCreate($this->currentOrderId(), 'order'); } private function currentOrderId(): int diff --git a/ViewModel/Customer/Guest/ExportDataProvider.php b/ViewModel/Customer/Guest/ExportDataProvider.php index bb808942..f041ce8b 100644 --- a/ViewModel/Customer/Guest/ExportDataProvider.php +++ b/ViewModel/Customer/Guest/ExportDataProvider.php @@ -14,38 +14,22 @@ class ExportDataProvider implements ArgumentInterface { - private ExportEntityCheckerInterface $exportEntityChecker; - - private Registry $registry; - - /** - * @var bool|null - */ - private ?bool $isExportEntityExists; - - /** - * @var bool|null - */ - private ?bool $isExported; + private ?bool $isExportEntityExists = null; + private ?bool $isExported = null; public function __construct( - ExportEntityCheckerInterface $exportEntityChecker, - Registry $registry - ) { - $this->exportEntityChecker = $exportEntityChecker; - $this->registry = $registry; - } + private ExportEntityCheckerInterface $exportEntityChecker, + private Registry $registry + ) {} public function hasExport(): bool { - return $this->isExportEntityExists ?? - $this->isExportEntityExists = $this->exportEntityChecker->exists($this->currentOrderId(), 'order'); + return $this->isExportEntityExists ??= $this->exportEntityChecker->exists($this->currentOrderId(), 'order'); } public function isExported(): bool { - return $this->isExported ?? - $this->isExported = $this->exportEntityChecker->isExported($this->currentOrderId(), 'order'); + return $this->isExported ??= $this->exportEntityChecker->isExported($this->currentOrderId(), 'order'); } private function currentOrderId(): int diff --git a/ViewModel/Customer/Privacy/EraseCustomerDataProvider.php b/ViewModel/Customer/Privacy/EraseCustomerDataProvider.php index f8e99e3a..b731151e 100644 --- a/ViewModel/Customer/Privacy/EraseCustomerDataProvider.php +++ b/ViewModel/Customer/Privacy/EraseCustomerDataProvider.php @@ -13,30 +13,13 @@ class EraseCustomerDataProvider implements ArgumentInterface { - private EraseEntityCheckerInterface $eraseEntityChecker; - - /** - * @var Session - */ - private Session $session; - - /** - * @var null|bool - */ - private ?bool $canCancel; - - /** - * @var null|bool - */ - private ?bool $canCreate; + private ?bool $canCancel = null; + private ?bool $canCreate = null; public function __construct( - EraseEntityCheckerInterface $eraseEntityChecker, - Session $session - ) { - $this->eraseEntityChecker = $eraseEntityChecker; - $this->session = $session; - } + private EraseEntityCheckerInterface $eraseEntityChecker, + private Session $session + ) {} public function canCancel(): bool { diff --git a/ViewModel/Customer/Privacy/EraseDataProvider.php b/ViewModel/Customer/Privacy/EraseDataProvider.php index 8a6ee368..0772c94a 100644 --- a/ViewModel/Customer/Privacy/EraseDataProvider.php +++ b/ViewModel/Customer/Privacy/EraseDataProvider.php @@ -18,21 +18,13 @@ class EraseDataProvider implements ArgumentInterface private const CONFIG_PATH_ERASURE_INFORMATION_BLOCK = 'gdpr/erasure/block_id'; private const CONFIG_PATH_ANONYMIZE_INFORMATION_BLOCK = 'gdpr/anonymize/block_id'; - private ScopeConfigInterface $scopeConfig; - - private BlockFactory $blockFactory; - - private ?string $erasureInformation; - - private ?string $anonymizeInformation; + private ?string $erasureInformation = null; + private ?string $anonymizeInformation = null; public function __construct( - ScopeConfigInterface $scopeConfig, - BlockFactory $blockFactory - ) { - $this->scopeConfig = $scopeConfig; - $this->blockFactory = $blockFactory; - } + private ScopeConfigInterface $scopeConfig, + private BlockFactory $blockFactory + ) {} public function getErasureInformationHtml(): string { diff --git a/ViewModel/Customer/Privacy/ExportCustomerDataProvider.php b/ViewModel/Customer/Privacy/ExportCustomerDataProvider.php index cd9085d4..f022288f 100644 --- a/ViewModel/Customer/Privacy/ExportCustomerDataProvider.php +++ b/ViewModel/Customer/Privacy/ExportCustomerDataProvider.php @@ -13,30 +13,13 @@ class ExportCustomerDataProvider implements ArgumentInterface { - private ExportEntityCheckerInterface $exportEntityChecker; - - /** - * @var Session - */ - private Session $session; - - /** - * @var null|bool - */ - private ?bool $isExportEntityExists; - - /** - * @var null|bool - */ - private ?bool $isExported; + private ?bool $isExportEntityExists = null; + private ?bool $isExported = null; public function __construct( - ExportEntityCheckerInterface $exportEntityChecker, - Session $session - ) { - $this->exportEntityChecker = $exportEntityChecker; - $this->session = $session; - } + private ExportEntityCheckerInterface $exportEntityChecker, + private Session $session + ) {} public function hasExport(): bool { diff --git a/ViewModel/Customer/Privacy/ExportDataProvider.php b/ViewModel/Customer/Privacy/ExportDataProvider.php index e13e068c..3a5455d1 100644 --- a/ViewModel/Customer/Privacy/ExportDataProvider.php +++ b/ViewModel/Customer/Privacy/ExportDataProvider.php @@ -17,19 +17,12 @@ class ExportDataProvider implements ArgumentInterface { private const CONFIG_PATH_EXPORT_INFORMATION_BLOCK = 'gdpr/export/block_id'; - private ScopeConfigInterface $scopeConfig; - - private BlockFactory $blockFactory; - - private ?string $exportInformation; + private ?string $exportInformation = null; public function __construct( - ScopeConfigInterface $scopeConfig, - BlockFactory $blockFactory - ) { - $this->scopeConfig = $scopeConfig; - $this->blockFactory = $blockFactory; - } + private ScopeConfigInterface $scopeConfig, + private BlockFactory $blockFactory + ) {} public function getExportInformationHtml(): string { diff --git a/ViewModel/Customer/Privacy/SettingsDataProvider.php b/ViewModel/Customer/Privacy/SettingsDataProvider.php index ed608708..188e19bf 100644 --- a/ViewModel/Customer/Privacy/SettingsDataProvider.php +++ b/ViewModel/Customer/Privacy/SettingsDataProvider.php @@ -17,19 +17,12 @@ class SettingsDataProvider implements ArgumentInterface { private const CONFIG_PATH_GENERAL_INFORMATION_BLOCK = 'gdpr/general/block_id'; - private ScopeConfigInterface $scopeConfig; - - private BlockFactory $blockFactory; - - private ?string $informationHtml; + private ?string $informationHtml = null; public function __construct( - ScopeConfigInterface $scopeConfig, - BlockFactory $blockFactory - ) { - $this->scopeConfig = $scopeConfig; - $this->blockFactory = $blockFactory; - } + private ScopeConfigInterface $scopeConfig, + private BlockFactory $blockFactory + ) {} public function getPrivacyInformationHtml(): string { From 8c8db883f49f14643304d3e2929c64438482578c Mon Sep 17 00:00:00 2001 From: Thomas Klein Date: Sun, 4 Aug 2024 17:28:13 +0200 Subject: [PATCH 09/31] Add notifier decorator --- Model/Erase/NotifierRepository.php | 34 +++++++++++++ Model/Erase/NotifyEraseEntityManagement.php | 47 ++++++++++++++++++ Model/EraseEntityManagement.php | 33 +++---------- Model/Export/NotifierRepository.php | 34 +++++++++++++ Model/Export/NotifyExportEntityManagement.php | 41 ++++++++++++++++ Model/ExportEntityManagement.php | 41 ++++------------ etc/di.xml | 48 ++++++++++++++++++- 7 files changed, 216 insertions(+), 62 deletions(-) create mode 100644 Model/Erase/NotifierRepository.php create mode 100644 Model/Erase/NotifyEraseEntityManagement.php create mode 100644 Model/Export/NotifierRepository.php create mode 100644 Model/Export/NotifyExportEntityManagement.php diff --git a/Model/Erase/NotifierRepository.php b/Model/Erase/NotifierRepository.php new file mode 100644 index 00000000..f46c6bfb --- /dev/null +++ b/Model/Erase/NotifierRepository.php @@ -0,0 +1,34 @@ +notifiers[$action][$entityType] ?? throw $this->createException($entityType, $action); + } + + private function createException(string $entityType, string $action): NoSuchEntityException + { + return new NoSuchEntityException( + new Phrase('No such notifier for entity type "' . $entityType . '" and action "' . $action . '"') + ); + } +} diff --git a/Model/Erase/NotifyEraseEntityManagement.php b/Model/Erase/NotifyEraseEntityManagement.php new file mode 100644 index 00000000..be4d9598 --- /dev/null +++ b/Model/Erase/NotifyEraseEntityManagement.php @@ -0,0 +1,47 @@ +eraseManagement->create($entityId, $entityType); + $this->notifierRepository->get($entityType, 'pending')->notify($eraseEntity); + + return $eraseEntity; + } + + public function cancel(int $entityId, string $entityType): bool + { + $canceled = $this->eraseManagement->cancel($entityId, $entityType); + if ($canceled) { + $this->notifierRepository->get($entityType, 'cancel')->notify($this->eraseRepository->getByEntity($entityId, $entityType)); + } + + return $canceled; + } + + public function process(EraseEntityInterface $entity): EraseEntityInterface + { + $eraseEntity = $this->eraseManagement->process($entity); + $this->notifierRepository->get($entity->getEntityType(), 'success')->notify($eraseEntity); + + return $eraseEntity; + } +} diff --git a/Model/EraseEntityManagement.php b/Model/EraseEntityManagement.php index 40230c9b..c22995f0 100644 --- a/Model/EraseEntityManagement.php +++ b/Model/EraseEntityManagement.php @@ -25,29 +25,13 @@ class EraseEntityManagement implements EraseEntityManagementInterface { private const CONFIG_PATH_ERASURE_DELAY = 'gdpr/erasure/delay'; - private EraseEntityInterfaceFactory $eraseEntityFactory; - - private EraseEntityRepositoryInterface $eraseRepository; - - private ProcessorFactory $processorFactory; - - private ScopeConfigInterface $scopeConfig; - - private DateTime $localeDate; - public function __construct( - EraseEntityInterfaceFactory $eraseEntityFactory, - EraseEntityRepositoryInterface $eraseRepository, - ProcessorFactory $processorFactory, - ScopeConfigInterface $scopeConfig, - DateTime $localeDate - ) { - $this->eraseEntityFactory = $eraseEntityFactory; - $this->eraseRepository = $eraseRepository; - $this->processorFactory = $processorFactory; - $this->scopeConfig = $scopeConfig; - $this->localeDate = $localeDate; - } + private EraseEntityInterfaceFactory $eraseEntityFactory, + private EraseEntityRepositoryInterface $eraseRepository, + private ProcessorFactory $processorFactory, + private ScopeConfigInterface $scopeConfig, + private DateTime $localeDate + ) {} public function create(int $entityId, string $entityType): EraseEntityInterface { @@ -83,8 +67,6 @@ public function process(EraseEntityInterface $entity): EraseEntityInterface } /** - * @param EraseEntityInterface $entity - * @return EraseEntityInterface * @throws CouldNotSaveException */ private function success(EraseEntityInterface $entity): EraseEntityInterface @@ -98,9 +80,6 @@ private function success(EraseEntityInterface $entity): EraseEntityInterface } /** - * @param EraseEntityInterface $entity - * @param string|null $message [optional] - * @return EraseEntityInterface * @throws CouldNotSaveException */ private function fail(EraseEntityInterface $entity, ?string $message = null): EraseEntityInterface diff --git a/Model/Export/NotifierRepository.php b/Model/Export/NotifierRepository.php new file mode 100644 index 00000000..37aef550 --- /dev/null +++ b/Model/Export/NotifierRepository.php @@ -0,0 +1,34 @@ +notifiers[$action][$entityType] ?? throw $this->createException($entityType, $action); + } + + private function createException(string $entityType, string $action): NoSuchEntityException + { + return new NoSuchEntityException( + new Phrase('No such notifier for entity type "' . $entityType . '" and action "' . $action . '"') + ); + } +} diff --git a/Model/Export/NotifyExportEntityManagement.php b/Model/Export/NotifyExportEntityManagement.php new file mode 100644 index 00000000..8e5b0422 --- /dev/null +++ b/Model/Export/NotifyExportEntityManagement.php @@ -0,0 +1,41 @@ +exportManagement->create($entityId, $entityType, $fileName); + $this->notifierRepository->get($entityType, 'pending')->notify($exportEntity); + + return $exportEntity; + } + + public function export(ExportEntityInterface $exportEntity): ExportEntityInterface + { + $exportEntity = $this->exportManagement->export($exportEntity); + $this->notifierRepository->get($exportEntity->getEntityType(), 'ready')->notify($exportEntity); + + + return $exportEntity; + } + + public function invalidate(ExportEntityInterface $exportEntity): ExportEntityInterface + { + return $this->exportManagement->invalidate($exportEntity); + } +} diff --git a/Model/ExportEntityManagement.php b/Model/ExportEntityManagement.php index 0192ea56..32e11a67 100644 --- a/Model/ExportEntityManagement.php +++ b/Model/ExportEntityManagement.php @@ -26,32 +26,13 @@ class ExportEntityManagement implements ExportEntityManagementInterface private const CONFIG_PATH_EXPORT_FILE_NAME = 'gdpr/export/file_name'; private const CONFIG_PATH_EXPORT_LIFE_TIME = 'gdpr/export/life_time'; - private ExportEntityInterfaceFactory $exportEntityFactory; - - private ExportEntityRepositoryInterface $exportRepository; - - private ExportEntityCheckerInterface $exportEntityChecker; - - /** - * @var ExportToFile - */ - private ExportToFile $exportToFile; - - private ScopeConfigInterface $scopeConfig; - public function __construct( - ExportEntityInterfaceFactory $exportEntityFactory, - ExportEntityRepositoryInterface $exportRepository, - ExportEntityCheckerInterface $exportEntityChecker, - ExportToFile $exportToFile, - ScopeConfigInterface $scopeConfig - ) { - $this->exportEntityFactory = $exportEntityFactory; - $this->exportRepository = $exportRepository; - $this->exportEntityChecker = $exportEntityChecker; - $this->exportToFile = $exportToFile; - $this->scopeConfig = $scopeConfig; - } + private ExportEntityInterfaceFactory $exportEntityFactory, + private ExportEntityRepositoryInterface $exportRepository, + private ExportEntityCheckerInterface $exportEntityChecker, + private ExportToFile $exportToFile, + private ScopeConfigInterface $scopeConfig + ) {} public function create(int $entityId, string $entityType, ?string $fileName = null): ExportEntityInterface { @@ -69,15 +50,10 @@ public function create(int $entityId, string $entityType, ?string $fileName = nu $exportEntity->setEntityId($entityId); $exportEntity->setEntityType($entityType); $exportEntity->setFileName($fileName ?? $this->resolveDefaultFileName()); - $exportEntity = $this->exportRepository->save($exportEntity); - return $exportEntity; + return $this->exportRepository->save($exportEntity); } - /** - * @inheritdoc - * @throws Exception - */ public function export(ExportEntityInterface $exportEntity): ExportEntityInterface { $lifeTime = (int)$this->scopeConfig->getValue(self::CONFIG_PATH_EXPORT_LIFE_TIME, ScopeInterface::SCOPE_STORE);//Todo scope website @@ -86,9 +62,8 @@ public function export(ExportEntityInterface $exportEntity): ExportEntityInterfa (new DateTime('+' . $lifeTime . 'minutes'))->format(DateTimeFormat::DATETIME_PHP_FORMAT) ); $exportEntity->setExportedAt((new DateTime())->format(DateTimeFormat::DATETIME_PHP_FORMAT)); - $this->exportRepository->save($exportEntity); - return $exportEntity; + return $this->exportRepository->save($exportEntity); } public function invalidate(ExportEntityInterface $exportEntity): ExportEntityInterface diff --git a/etc/di.xml b/etc/di.xml index 02da0457..f3f6142a 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -10,9 +10,14 @@ - + + + Opengento\Gdpr\Model\Erase\NotifyEraseEntityManagement + + + Opengento\Gdpr\Model\EraseEntityManagement @@ -22,8 +27,13 @@ - + + + + Opengento\Gdpr\Model\ExportEntityManagement + + @@ -1525,6 +1535,25 @@ + + + + + + Opengento\Gdpr\Model\Customer\Erase\Notifier\Pending\Proxy + Opengento\Gdpr\Model\Order\Erase\Notifier\Pending\Proxy + + + Opengento\Gdpr\Model\Customer\Erase\Notifier\Succeeded\Proxy + Opengento\Gdpr\Model\Order\Erase\Notifier\Succeeded\Proxy + + + Opengento\Gdpr\Model\Customer\Erase\Notifier\Canceled\Proxy + Opengento\Gdpr\Model\Order\Erase\Notifier\Canceled\Proxy + + + + @@ -1599,6 +1628,21 @@ + + + + + + Opengento\Gdpr\Model\Customer\Export\Notifier\Pending\Proxy + Opengento\Gdpr\Model\Order\Export\Notifier\Pending\Proxy + + + Opengento\Gdpr\Model\Customer\Export\Notifier\Ready\Proxy + Opengento\Gdpr\Model\Order\Export\Notifier\Ready\Proxy + + + + From 15fde18a28d9bbdab27be1e11b96f6c997f6fea9 Mon Sep 17 00:00:00 2001 From: Thomas Klein Date: Sun, 4 Aug 2024 18:53:40 +0200 Subject: [PATCH 10/31] Fix settings scope + notifications --- Block/Adminhtml/Order/Edit/EraseButton.php | 56 ---------- Block/Adminhtml/Order/Edit/ExportButton.php | 40 ------- Controller/AbstractPrivacy.php | 56 ---------- Controller/Adminhtml/AbstractAction.php | 56 ---------- Controller/Adminhtml/Guest/Erase.php | 52 +++++---- Controller/Adminhtml/Guest/Export.php | 65 +++++++----- Controller/Adminhtml/Privacy/Erase.php | 41 +++---- Controller/Adminhtml/Privacy/Export.php | 56 +++++----- Controller/Adminhtml/Privacy/MassErase.php | 3 +- Controller/Adminhtml/Privacy/MassExport.php | 4 +- Controller/Guest/Download.php | 4 +- Controller/Guest/Export.php | 2 +- Controller/Privacy/Download.php | 14 +-- Controller/Privacy/Erase.php | 10 +- Controller/Privacy/ErasePost.php | 12 +-- Controller/Privacy/Export.php | 12 +-- Controller/Privacy/Settings.php | 5 +- Controller/Privacy/UndoErase.php | 10 +- Cron/EraseEntityScheduler.php | 3 +- Model/EraseEntityChecker.php | 6 +- Model/EraseEntityManagement.php | 3 +- Model/Export/ExportToFile.php | 27 ++--- Model/ExportEntityManagement.php | 4 +- .../Component/Customer/Form}/EraseButton.php | 20 +++- .../Component/Customer/Form}/ExportButton.php | 11 +- Ui/Component/Order/Form/EraseButton.php | 57 ++++++++++ Ui/Component/Order/Form/ExportButton.php | 52 +++++++++ etc/adminhtml/system/erasure.xml | 58 +++++----- etc/adminhtml/system/export.xml | 48 ++++----- etc/adminhtml/system/general.xml | 2 +- etc/db_schema.xml | 6 +- etc/db_schema_whitelist.json | 6 +- etc/di.xml | 100 +++++++++--------- view/adminhtml/layout/sales_order_view.xml | 4 +- view/adminhtml/ui_component/customer_form.xml | 4 +- 35 files changed, 425 insertions(+), 484 deletions(-) delete mode 100644 Block/Adminhtml/Order/Edit/EraseButton.php delete mode 100644 Block/Adminhtml/Order/Edit/ExportButton.php delete mode 100644 Controller/AbstractPrivacy.php delete mode 100644 Controller/Adminhtml/AbstractAction.php rename {Block/Adminhtml/Customer/Edit => Ui/Component/Customer/Form}/EraseButton.php (65%) rename {Block/Adminhtml/Customer/Edit => Ui/Component/Customer/Form}/ExportButton.php (72%) create mode 100644 Ui/Component/Order/Form/EraseButton.php create mode 100644 Ui/Component/Order/Form/ExportButton.php diff --git a/Block/Adminhtml/Order/Edit/EraseButton.php b/Block/Adminhtml/Order/Edit/EraseButton.php deleted file mode 100644 index 66b020ba..00000000 --- a/Block/Adminhtml/Order/Edit/EraseButton.php +++ /dev/null @@ -1,56 +0,0 @@ -getLayout()->getBlock('sales_order_edit'); - $orderId = (int)$orderView->getOrderId(); - - if ($this->_authorization->isAllowed('Opengento_Gdpr::order_erase') && - $this->eraseEntityChecker->canCreate($orderId, 'order') - ) { - $confirmMessage = new Phrase('Are you sure you want to do this?'); - $eraseUrl = $this->getUrl('sales/guest/erase', ['id' => $orderId]); - - $orderView->addButton( - 'opengento-gdpr-order-view-erase-button', - [ - 'label' => new Phrase('Erase Personal Data'), - 'class' => 'action-secondary erase', - 'onclick' => 'deleteConfirm("' . $confirmMessage . '", "' . $eraseUrl . '", {"data":{}})', - ], - 1 - ); - } - } -} diff --git a/Block/Adminhtml/Order/Edit/ExportButton.php b/Block/Adminhtml/Order/Edit/ExportButton.php deleted file mode 100644 index 57c4f257..00000000 --- a/Block/Adminhtml/Order/Edit/ExportButton.php +++ /dev/null @@ -1,40 +0,0 @@ -getLayout()->getBlock('sales_order_edit'); - $orderId = (int)$orderView->getOrderId(); - - if ($this->_authorization->isAllowed('Opengento_Gdpr::order_export')) { - $orderView->addButton( - 'opengento-gdpr-order-view-export-button', - [ - 'label' => new Phrase('Export Personal Data'), - 'class' => 'export', - 'onclick' => 'setLocation("' . $this->getUrl('sales/guest/export', ['id' => $orderId]) . '")', - ] - ); - } - } -} diff --git a/Controller/AbstractPrivacy.php b/Controller/AbstractPrivacy.php deleted file mode 100644 index 646a5588..00000000 --- a/Controller/AbstractPrivacy.php +++ /dev/null @@ -1,56 +0,0 @@ -customerSession->authenticate() ? $this->defaultAction() : $this->response; - } - - /** - * @throws NotFoundException - */ - private function defaultAction(): ResultInterface|ResponseInterface - { - return $this->isAllowed() ? $this->executeAction() : $this->forwardNoRoute(); - } -} diff --git a/Controller/Adminhtml/AbstractAction.php b/Controller/Adminhtml/AbstractAction.php deleted file mode 100644 index 996b6656..00000000 --- a/Controller/Adminhtml/AbstractAction.php +++ /dev/null @@ -1,56 +0,0 @@ -config = $config; - parent::__construct($context); - } - - public function execute(): ResultInterface|ResponseInterface - { - return $this->isAllowed() ? $this->executeAction() : $this->forwardNoRoute(); - } - - /** - * Execute action based on request and return result - * - * @return ResultInterface|ResponseInterface - * @throws NotFoundException - */ - abstract protected function executeAction(): ResultInterface|ResponseInterface; - - protected function isAllowed(): bool - { - return $this->config->isModuleEnabled(); - } - - protected function forwardNoRoute(): ResultInterface - { - /** @var Forward $resultForward */ - $resultForward = $this->resultFactory->create(ResultFactory::TYPE_FORWARD); - - return $resultForward->forward('no_route'); - } -} diff --git a/Controller/Adminhtml/Guest/Erase.php b/Controller/Adminhtml/Guest/Erase.php index b4d7bd29..856fa8de 100644 --- a/Controller/Adminhtml/Guest/Erase.php +++ b/Controller/Adminhtml/Guest/Erase.php @@ -8,46 +8,62 @@ namespace Opengento\Gdpr\Controller\Adminhtml\Guest; use Exception; -use Magento\Backend\App\Action\Context; -use Magento\Backend\Model\View\Result\Redirect; +use Magento\Backend\Model\View\Result\RedirectFactory; use Magento\Framework\App\Action\HttpPostActionInterface; -use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\App\RequestInterface; +use Magento\Framework\App\ResponseInterface; +use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Message\ManagerInterface; use Magento\Framework\Phrase; +use Magento\Sales\Api\OrderRepositoryInterface; +use Magento\Store\Model\StoreManagerInterface; use Opengento\Gdpr\Api\EraseEntityManagementInterface; use Opengento\Gdpr\Api\EraseEntityRepositoryInterface; -use Opengento\Gdpr\Controller\Adminhtml\AbstractAction; use Opengento\Gdpr\Model\Config; -class Erase extends AbstractAction implements HttpPostActionInterface +class Erase implements HttpPostActionInterface { public const ADMIN_RESOURCE = 'Opengento_Gdpr::order_erase'; public function __construct( - Context $context, - Config $config, + private RequestInterface $request, + private ManagerInterface $messageManager, + private StoreManagerInterface $storeManager, + private OrderRepositoryInterface $orderRepository, private EraseEntityManagementInterface $eraseEntityManagement, private EraseEntityRepositoryInterface $eraseEntityRepository, - ) { - parent::__construct($context, $config); - } + private Config $config, + private RedirectFactory $redirectFactory, + ) {} - protected function executeAction() + public function execute(): ResultInterface|ResponseInterface { try { - $this->eraseEntityManagement->process( - $this->eraseEntityRepository->getByEntity((int)$this->getRequest()->getParam('id'), 'order') - ); - $this->messageManager->addSuccessMessage(new Phrase('You erased the order.')); + $orderId = (int)$this->request->getParam('id'); + if ($this->isOrderErasureEnabled($orderId)) { + $this->eraseEntityManagement->process( + $this->eraseEntityRepository->getByEntity($orderId, 'order') + ); + $this->messageManager->addSuccessMessage(new Phrase('You erased the order.')); + } } catch (LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); } catch (Exception $e) { $this->messageManager->addExceptionMessage($e, new Phrase('An error occurred on the server.')); } - /** @var Redirect $resultRedirect */ - $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); + return $this->redirectFactory->create()->setPath('sales/order/index'); + } - return $resultRedirect->setPath('sales/order/index'); + /** + * @throws NoSuchEntityException + */ + private function isOrderErasureEnabled(int $orderId): bool + { + return $this->config->isErasureEnabled( + $this->storeManager->getStore($this->orderRepository->get($orderId)->getStoreId())->getWebsiteId() + ); } } diff --git a/Controller/Adminhtml/Guest/Export.php b/Controller/Adminhtml/Guest/Export.php index fc57885f..e141606a 100644 --- a/Controller/Adminhtml/Guest/Export.php +++ b/Controller/Adminhtml/Guest/Export.php @@ -8,58 +8,73 @@ namespace Opengento\Gdpr\Controller\Adminhtml\Guest; use Exception; -use Magento\Backend\App\Action\Context; -use Magento\Backend\Model\View\Result\Redirect; +use Magento\Backend\Model\View\Result\RedirectFactory; +use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\App\RequestInterface; use Magento\Framework\App\Response\Http\FileFactory; use Magento\Framework\App\ResponseInterface; -use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Message\ManagerInterface; use Magento\Framework\Phrase; +use Magento\Sales\Api\OrderRepositoryInterface; +use Magento\Store\Model\StoreManagerInterface; use Opengento\Gdpr\Api\ExportEntityManagementInterface; use Opengento\Gdpr\Api\ExportEntityRepositoryInterface; -use Opengento\Gdpr\Controller\Adminhtml\AbstractAction; use Opengento\Gdpr\Model\Config; -class Export extends AbstractAction +class Export implements HttpGetActionInterface { public const ADMIN_RESOURCE = 'Opengento_Gdpr::order_export'; public function __construct( - Context $context, - Config $config, + private RequestInterface $request, + private ManagerInterface $messageManager, + private StoreManagerInterface $storeManager, + private OrderRepositoryInterface $orderRepository, private ExportEntityManagementInterface $exportEntityManagement, private ExportEntityRepositoryInterface $exportEntityRepository, + private Config $config, + private RedirectFactory $redirectFactory, private FileFactory $fileFactory - ) { - parent::__construct($context, $config); - } + ) {} - protected function executeAction(): ResultInterface|ResponseInterface + public function execute(): ResultInterface|ResponseInterface { try { - $exportEntity = $this->exportEntityManagement->export( - $this->exportEntityRepository->getByEntity((int)$this->getRequest()->getParam('id'), 'order') - ); + $orderId = (int)$this->request->getParam('id'); + if ($this->isOrderExportEnabled($orderId)) { + $exportEntity = $this->exportEntityManagement->export( + $this->exportEntityRepository->getByEntity($orderId, 'order') + ); - return $this->fileFactory->create( - 'guest_privacy_data_' . $exportEntity->getEntityId() . '.zip', - [ - 'type' => 'filename', - 'value' => $exportEntity->getFilePath(), - ], - DirectoryList::TMP - ); + return $this->fileFactory->create( + 'guest_privacy_data_' . $exportEntity->getEntityId() . '.zip', + [ + 'type' => 'filename', + 'value' => $exportEntity->getFilePath(), + ], + DirectoryList::TMP + ); + } } catch (LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); } catch (Exception $e) { $this->messageManager->addExceptionMessage($e, new Phrase('An error occurred on the server.')); } - /** @var Redirect $resultRedirect */ - $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); + return $this->redirectFactory->create()->setRefererOrBaseUrl(); + } - return $resultRedirect->setRefererOrBaseUrl(); + /** + * @throws NoSuchEntityException + */ + private function isOrderExportEnabled(int $orderId): bool + { + return $this->config->isErasureEnabled( + $this->storeManager->getStore($this->orderRepository->get($orderId)->getStoreId())->getWebsiteId() + ); } } diff --git a/Controller/Adminhtml/Privacy/Erase.php b/Controller/Adminhtml/Privacy/Erase.php index cc578b13..2b0bed06 100644 --- a/Controller/Adminhtml/Privacy/Erase.php +++ b/Controller/Adminhtml/Privacy/Erase.php @@ -8,48 +8,49 @@ namespace Opengento\Gdpr\Controller\Adminhtml\Privacy; use Exception; -use Magento\Backend\App\Action\Context; -use Magento\Backend\Model\View\Result\Redirect; +use Magento\Backend\Model\View\Result\RedirectFactory; +use Magento\Customer\Api\CustomerRepositoryInterface; use Magento\Framework\App\Action\HttpPostActionInterface; +use Magento\Framework\App\RequestInterface; use Magento\Framework\App\ResponseInterface; -use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Message\ManagerInterface; use Magento\Framework\Phrase; use Opengento\Gdpr\Api\EraseEntityManagementInterface; use Opengento\Gdpr\Api\EraseEntityRepositoryInterface; -use Opengento\Gdpr\Controller\Adminhtml\AbstractAction; use Opengento\Gdpr\Model\Config; -class Erase extends AbstractAction implements HttpPostActionInterface +class Erase implements HttpPostActionInterface { public const ADMIN_RESOURCE = 'Opengento_Gdpr::customer_erase'; public function __construct( - Context $context, - Config $config, + private RequestInterface $request, + private ManagerInterface $messageManager, + private CustomerRepositoryInterface $customerRepository, private EraseEntityManagementInterface $eraseEntityManagement, - private EraseEntityRepositoryInterface $eraseEntityRepository - ) { - parent::__construct($context, $config); - } + private EraseEntityRepositoryInterface $eraseEntityRepository, + private RedirectFactory $redirectFactory, + private Config $config + ) {} - protected function executeAction(): ResultInterface|ResponseInterface + public function execute(): ResultInterface|ResponseInterface { try { - $this->eraseEntityManagement->process( - $this->eraseEntityRepository->getByEntity((int)$this->getRequest()->getParam('id'), 'customer') - ); - $this->messageManager->addSuccessMessage(new Phrase('You erased the customer.')); + $customerId = (int)$this->request->getParam('id'); + if ($this->config->isErasureEnabled($this->customerRepository->getById($customerId)->getWebsiteId())) { + $this->eraseEntityManagement->process( + $this->eraseEntityRepository->getByEntity($customerId, 'customer') + ); + $this->messageManager->addSuccessMessage(new Phrase('You erased the customer.')); + } } catch (LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); } catch (Exception $e) { $this->messageManager->addExceptionMessage($e, new Phrase('An error occurred on the server.')); } - /** @var Redirect $resultRedirect */ - $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); - - return $resultRedirect->setPath('customer/index'); + return $this->redirectFactory->create()->setPath('customer/index'); } } diff --git a/Controller/Adminhtml/Privacy/Export.php b/Controller/Adminhtml/Privacy/Export.php index 9949f755..79e842a2 100644 --- a/Controller/Adminhtml/Privacy/Export.php +++ b/Controller/Adminhtml/Privacy/Export.php @@ -8,58 +8,60 @@ namespace Opengento\Gdpr\Controller\Adminhtml\Privacy; use Exception; -use Magento\Backend\App\Action\Context; -use Magento\Backend\Model\View\Result\Redirect; +use Magento\Backend\Model\View\Result\RedirectFactory; +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\App\RequestInterface; use Magento\Framework\App\Response\Http\FileFactory; use Magento\Framework\App\ResponseInterface; -use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Message\ManagerInterface; use Magento\Framework\Phrase; use Opengento\Gdpr\Api\ExportEntityManagementInterface; use Opengento\Gdpr\Api\ExportEntityRepositoryInterface; -use Opengento\Gdpr\Controller\Adminhtml\AbstractAction; use Opengento\Gdpr\Model\Config; -class Export extends AbstractAction +class Export implements HttpGetActionInterface { public const ADMIN_RESOURCE = 'Opengento_Gdpr::customer_export'; public function __construct( - Context $context, - Config $config, - private FileFactory $fileFactory, + private RequestInterface $request, + private ManagerInterface $messageManager, + private CustomerRepositoryInterface $customerRepository, private ExportEntityManagementInterface $exportEntityManagement, private ExportEntityRepositoryInterface $exportEntityRepository, - ) { - parent::__construct($context, $config); - } + private RedirectFactory $redirectFactory, + private Config $config, + private FileFactory $fileFactory + ) {} - protected function executeAction(): ResultInterface|ResponseInterface + public function execute(): ResultInterface|ResponseInterface { try { - $exportEntity = $this->exportEntityManagement->export( - $this->exportEntityRepository->getByEntity((int)$this->getRequest()->getParam('id'), 'customer') - ); + $customerId = (int)$this->request->getParam('id'); + if ($this->config->isExportEnabled($this->customerRepository->getById($customerId)->getWebsiteId())) { + $exportEntity = $this->exportEntityManagement->export( + $this->exportEntityRepository->getByEntity($customerId, 'customer') + ); - return $this->fileFactory->create( - 'customer_privacy_data_' . $exportEntity->getEntityId() . '.zip', - [ - 'type' => 'filename', - 'value' => $exportEntity->getFilePath(), - ], - DirectoryList::TMP - ); + return $this->fileFactory->create( + 'customer_privacy_data_' . $exportEntity->getEntityId() . '.zip', + [ + 'type' => 'filename', + 'value' => $exportEntity->getFilePath(), + ], + DirectoryList::TMP + ); + } } catch (LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); } catch (Exception $e) { $this->messageManager->addExceptionMessage($e, new Phrase('An error occurred on the server.')); } - /** @var Redirect $resultRedirect */ - $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); - - return $resultRedirect->setRefererOrBaseUrl(); + return $this->redirectFactory->create()->setRefererOrBaseUrl(); } } diff --git a/Controller/Adminhtml/Privacy/MassErase.php b/Controller/Adminhtml/Privacy/MassErase.php index b3b3b4f4..62e9e527 100644 --- a/Controller/Adminhtml/Privacy/MassErase.php +++ b/Controller/Adminhtml/Privacy/MassErase.php @@ -14,6 +14,7 @@ use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory; use Magento\Eav\Model\Entity\Collection\AbstractCollection; use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Framework\App\ResponseInterface; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Exception\LocalizedException; @@ -38,7 +39,7 @@ public function __construct( parent::__construct($context, $filter, $collectionFactory); } - protected function massAction(AbstractCollection $collection): Redirect|ResultInterface|\Magento\Framework\App\ResponseInterface + protected function massAction(AbstractCollection $collection): ResultInterface|ResponseInterface { $customerErased = 0; diff --git a/Controller/Adminhtml/Privacy/MassExport.php b/Controller/Adminhtml/Privacy/MassExport.php index 52bb246a..ff4abf67 100644 --- a/Controller/Adminhtml/Privacy/MassExport.php +++ b/Controller/Adminhtml/Privacy/MassExport.php @@ -16,7 +16,9 @@ use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\Response\Http\FileFactory; +use Magento\Framework\App\ResponseInterface; use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Phrase; use Magento\Ui\Component\MassAction\Filter; @@ -42,7 +44,7 @@ public function __construct( parent::__construct($context, $filter, $collectionFactory); } - protected function massAction(AbstractCollection $collection) + protected function massAction(AbstractCollection $collection): ResultInterface|ResponseInterface { $archiveFileName = 'customers_privacy_data.zip'; diff --git a/Controller/Guest/Download.php b/Controller/Guest/Download.php index 8d790e24..ba19a7ab 100755 --- a/Controller/Guest/Download.php +++ b/Controller/Guest/Download.php @@ -56,7 +56,7 @@ protected function isAllowed(): bool return $this->config->isExportEnabled(); } - protected function executeAction(): ResultInterface|ResponseInterface|Redirect + protected function executeAction(): ResultInterface|ResponseInterface { try { /** @var OrderInterface $order */ @@ -70,7 +70,7 @@ protected function executeAction(): ResultInterface|ResponseInterface|Redirect ], DirectoryList::TMP ); - } catch (NoSuchEntityException $e) { + } catch (NoSuchEntityException) { $this->messageManager->addErrorMessage( new Phrase('The document does not exists and may have expired. Please renew your demand.') ); diff --git a/Controller/Guest/Export.php b/Controller/Guest/Export.php index 2361ace6..6cbc80ff 100755 --- a/Controller/Guest/Export.php +++ b/Controller/Guest/Export.php @@ -50,7 +50,7 @@ protected function executeAction(): Redirect try { $this->exportEntityManagement->create((int)$this->currentOrder()->getEntityId(), 'order'); $this->messageManager->addSuccessMessage(new Phrase('You will be notified when the export is ready.')); - } catch (AlreadyExistsException $e) { + } catch (AlreadyExistsException) { $this->messageManager->addNoticeMessage(new Phrase('A document is already available in your order page.')); } catch (LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); diff --git a/Controller/Privacy/Download.php b/Controller/Privacy/Download.php index acabbc53..2f6f3701 100755 --- a/Controller/Privacy/Download.php +++ b/Controller/Privacy/Download.php @@ -8,6 +8,7 @@ namespace Opengento\Gdpr\Controller\Privacy; use Exception; +use Magento\Customer\Controller\AccountInterface; use Magento\Customer\Model\Session; use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\App\Filesystem\DirectoryList; @@ -23,22 +24,21 @@ use Magento\Framework\Message\ManagerInterface; use Magento\Framework\Phrase; use Opengento\Gdpr\Api\ExportEntityRepositoryInterface; -use Opengento\Gdpr\Controller\AbstractPrivacy; +use Opengento\Gdpr\Controller\AbstractAction; use Opengento\Gdpr\Model\Config; -class Download extends AbstractPrivacy implements HttpGetActionInterface +class Download extends AbstractAction implements HttpGetActionInterface, AccountInterface { public function __construct( RequestInterface $request, ResultFactory $resultFactory, ManagerInterface $messageManager, Config $config, - Http $response, - Session $customerSession, + private Session $customerSession, private FileFactory $fileFactory, private ExportEntityRepositoryInterface $exportRepository ) { - parent::__construct($request, $resultFactory, $messageManager, $config, $customerSession, $response); + parent::__construct($request, $resultFactory, $messageManager, $config); } protected function isAllowed(): bool @@ -46,7 +46,7 @@ protected function isAllowed(): bool return $this->config->isExportEnabled(); } - protected function executeAction(): ResultInterface|ResponseInterface|Redirect + protected function executeAction(): ResultInterface|ResponseInterface { try { $customerId = (int)$this->customerSession->getCustomerId(); @@ -59,7 +59,7 @@ protected function executeAction(): ResultInterface|ResponseInterface|Redirect ], DirectoryList::TMP ); - } catch (NoSuchEntityException $e) { + } catch (NoSuchEntityException) { $this->messageManager->addErrorMessage( new Phrase('The document does not exists and may have expired. Please renew your demand.') ); diff --git a/Controller/Privacy/Erase.php b/Controller/Privacy/Erase.php index bf1210d0..ad1f6cd9 100755 --- a/Controller/Privacy/Erase.php +++ b/Controller/Privacy/Erase.php @@ -7,6 +7,7 @@ namespace Opengento\Gdpr\Controller\Privacy; +use Magento\Customer\Controller\AccountInterface; use Magento\Customer\Model\Session; use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\App\RequestInterface; @@ -17,21 +18,20 @@ use Magento\Framework\Phrase; use Magento\Framework\View\Result\Page; use Opengento\Gdpr\Api\EraseEntityCheckerInterface; -use Opengento\Gdpr\Controller\AbstractPrivacy; +use Opengento\Gdpr\Controller\AbstractAction; use Opengento\Gdpr\Model\Config; -class Erase extends AbstractPrivacy implements HttpGetActionInterface +class Erase extends AbstractAction implements HttpGetActionInterface, AccountInterface { public function __construct( RequestInterface $request, ResultFactory $resultFactory, ManagerInterface $messageManager, Config $config, - Session $customerSession, - Http $response, + private Session $customerSession, private EraseEntityCheckerInterface $eraseCustomerChecker ) { - parent::__construct($request, $resultFactory, $messageManager, $config, $customerSession, $response); + parent::__construct($request, $resultFactory, $messageManager, $config); } protected function isAllowed(): bool diff --git a/Controller/Privacy/ErasePost.php b/Controller/Privacy/ErasePost.php index 263818bf..e6dc64cc 100755 --- a/Controller/Privacy/ErasePost.php +++ b/Controller/Privacy/ErasePost.php @@ -8,6 +8,7 @@ namespace Opengento\Gdpr\Controller\Privacy; use Exception; +use Magento\Customer\Controller\AccountInterface; use Magento\Customer\Model\AuthenticationInterface; use Magento\Customer\Model\Session; use Magento\Framework\App\Action\HttpPostActionInterface; @@ -22,22 +23,21 @@ use Magento\Framework\Message\ManagerInterface; use Magento\Framework\Phrase; use Opengento\Gdpr\Api\EraseEntityManagementInterface; -use Opengento\Gdpr\Controller\AbstractPrivacy; +use Opengento\Gdpr\Controller\AbstractAction; use Opengento\Gdpr\Model\Config; -class ErasePost extends AbstractPrivacy implements HttpPostActionInterface +class ErasePost extends AbstractAction implements HttpPostActionInterface, AccountInterface { public function __construct( RequestInterface $request, ResultFactory $resultFactory, ManagerInterface $messageManager, Config $config, - Session $customerSession, - Http $response, + private Session $customerSession, private AuthenticationInterface $authentication, private EraseEntityManagementInterface $eraseEntityManagement ) { - parent::__construct($request, $resultFactory, $messageManager, $config, $customerSession, $response); + parent::__construct($request, $resultFactory, $messageManager, $config); } protected function isAllowed(): bool @@ -60,7 +60,7 @@ protected function executeAction(): Redirect } catch (InvalidEmailOrPasswordException $e) { $this->messageManager->addErrorMessage($e->getMessage()); $resultRedirect->setRefererOrBaseUrl(); - } catch (UserLockedException $e) { + } catch (UserLockedException) { $this->customerSession->logout(); try { $this->customerSession->start(); diff --git a/Controller/Privacy/Export.php b/Controller/Privacy/Export.php index 9e563b44..d799ccbb 100755 --- a/Controller/Privacy/Export.php +++ b/Controller/Privacy/Export.php @@ -8,6 +8,7 @@ namespace Opengento\Gdpr\Controller\Privacy; use Exception; +use Magento\Customer\Controller\AccountInterface; use Magento\Customer\Model\Session; use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\App\RequestInterface; @@ -19,21 +20,20 @@ use Magento\Framework\Message\ManagerInterface; use Magento\Framework\Phrase; use Opengento\Gdpr\Api\ExportEntityManagementInterface; -use Opengento\Gdpr\Controller\AbstractPrivacy; +use Opengento\Gdpr\Controller\AbstractAction; use Opengento\Gdpr\Model\Config; -class Export extends AbstractPrivacy implements HttpGetActionInterface +class Export extends AbstractAction implements HttpGetActionInterface, AccountInterface { public function __construct( RequestInterface $request, ResultFactory $resultFactory, ManagerInterface $messageManager, Config $config, - Session $customerSession, - Http $response, + private Session $customerSession, private ExportEntityManagementInterface $exportEntityManagement ) { - parent::__construct($request, $resultFactory, $messageManager, $config, $customerSession, $response); + parent::__construct($request, $resultFactory, $messageManager, $config); } protected function isAllowed(): bool @@ -50,7 +50,7 @@ protected function executeAction(): Redirect try { $this->exportEntityManagement->create((int)$this->customerSession->getCustomerId(), 'customer'); $this->messageManager->addSuccessMessage(new Phrase('You will be notified when the export is ready.')); - } catch (AlreadyExistsException $e) { + } catch (AlreadyExistsException) { $this->messageManager->addNoticeMessage(new Phrase('A document is already available in your account.')); } catch (LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); diff --git a/Controller/Privacy/Settings.php b/Controller/Privacy/Settings.php index 7ccd9678..fa9c518a 100755 --- a/Controller/Privacy/Settings.php +++ b/Controller/Privacy/Settings.php @@ -7,12 +7,13 @@ namespace Opengento\Gdpr\Controller\Privacy; +use Magento\Customer\Controller\AccountInterface; use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\View\Result\Page; -use Opengento\Gdpr\Controller\AbstractPrivacy; +use Opengento\Gdpr\Controller\AbstractAction; -class Settings extends AbstractPrivacy implements HttpGetActionInterface +class Settings extends AbstractAction implements HttpGetActionInterface, AccountInterface { protected function executeAction(): Page { diff --git a/Controller/Privacy/UndoErase.php b/Controller/Privacy/UndoErase.php index bd04b453..2f594294 100755 --- a/Controller/Privacy/UndoErase.php +++ b/Controller/Privacy/UndoErase.php @@ -8,6 +8,7 @@ namespace Opengento\Gdpr\Controller\Privacy; use Exception; +use Magento\Customer\Controller\AccountInterface; use Magento\Customer\Model\Session; use Magento\Framework\App\Action\HttpPostActionInterface; use Magento\Framework\App\RequestInterface; @@ -18,21 +19,20 @@ use Magento\Framework\Message\ManagerInterface; use Magento\Framework\Phrase; use Opengento\Gdpr\Api\EraseEntityManagementInterface; -use Opengento\Gdpr\Controller\AbstractPrivacy; +use Opengento\Gdpr\Controller\AbstractAction; use Opengento\Gdpr\Model\Config; -class UndoErase extends AbstractPrivacy implements HttpPostActionInterface +class UndoErase extends AbstractAction implements HttpPostActionInterface, AccountInterface { public function __construct( RequestInterface $request, ResultFactory $resultFactory, ManagerInterface $messageManager, Config $config, - Session $customerSession, - Http $response, + private Session $customerSession, private EraseEntityManagementInterface $eraseEntityManagement ) { - parent::__construct($request, $resultFactory, $messageManager, $config, $customerSession, $response); + parent::__construct($request, $resultFactory, $messageManager, $config); } protected function isAllowed(): bool diff --git a/Cron/EraseEntityScheduler.php b/Cron/EraseEntityScheduler.php index 5be647c0..8af42ab8 100644 --- a/Cron/EraseEntityScheduler.php +++ b/Cron/EraseEntityScheduler.php @@ -31,8 +31,7 @@ public function __construct( public function execute(): void { foreach ($this->storeManager->getWebsites() as $website) { - $websiteId = $website->getId(); - if ($this->config->isErasureEnabled($websiteId)) { + if ($this->config->isErasureEnabled($website->getId())) { try { $this->eraseEntityScheduler->schedule($this->entityTypeList->getEntityTypes(), $website); } catch (Exception $e) { diff --git a/Model/EraseEntityChecker.php b/Model/EraseEntityChecker.php index ff2049ee..0a3d170f 100644 --- a/Model/EraseEntityChecker.php +++ b/Model/EraseEntityChecker.php @@ -34,7 +34,7 @@ public function exists(int $entityId, string $entityType): bool { try { return (bool)$this->eraseRepository->getByEntity($entityId, $entityType)->getEraseId(); - } catch (NoSuchEntityException $e) { + } catch (NoSuchEntityException) { return false; } } @@ -50,7 +50,7 @@ public function canCancel(int $entityId, string $entityType): bool { try { $entity = $this->eraseRepository->getByEntity($entityId, $entityType); - } catch (NoSuchEntityException $e) { + } catch (NoSuchEntityException) { return false; } @@ -62,7 +62,7 @@ public function canProcess(int $entityId, string $entityType): bool { try { $entity = $this->eraseRepository->getByEntity($entityId, $entityType); - } catch (NoSuchEntityException $e) { + } catch (NoSuchEntityException) { return false; } $entityChecker = $this->entityCheckerFactory->get($entityType); diff --git a/Model/EraseEntityManagement.php b/Model/EraseEntityManagement.php index c22995f0..18b5daa6 100644 --- a/Model/EraseEntityManagement.php +++ b/Model/EraseEntityManagement.php @@ -14,7 +14,6 @@ use Magento\Framework\Phrase; use Magento\Framework\Stdlib\DateTime as DateTimeFormat; use Magento\Framework\Stdlib\DateTime\DateTime; -use Magento\Store\Model\ScopeInterface; use Opengento\Gdpr\Api\Data\EraseEntityInterface; use Opengento\Gdpr\Api\Data\EraseEntityInterfaceFactory; use Opengento\Gdpr\Api\EraseEntityManagementInterface; @@ -101,6 +100,6 @@ private function retrieveScheduledAt(): string private function resolveErasureDelay(): int { - return (int)$this->scopeConfig->getValue(self::CONFIG_PATH_ERASURE_DELAY, ScopeInterface::SCOPE_STORE);//Todo scope website + return (int)$this->scopeConfig->getValue(self::CONFIG_PATH_ERASURE_DELAY); } } diff --git a/Model/Export/ExportToFile.php b/Model/Export/ExportToFile.php index f0e58540..e59ff1a7 100644 --- a/Model/Export/ExportToFile.php +++ b/Model/Export/ExportToFile.php @@ -26,29 +26,14 @@ class ExportToFile { private const CONFIG_PATH_EXPORT_RENDERERS = 'gdpr/export/renderers'; - private ProcessorFactory $processorFactory; - - private RendererFactory $rendererFactory; - - private ArchiveManager $archiveManager; - - private ScopeConfigInterface $scopeConfig; - public function __construct( - ProcessorFactory $processorFactory, - RendererFactory $rendererFactory, - ArchiveManager $archiveManager, - ScopeConfigInterface $scopeConfig - ) { - $this->processorFactory = $processorFactory; - $this->rendererFactory = $rendererFactory; - $this->archiveManager = $archiveManager; - $this->scopeConfig = $scopeConfig; - } + private ProcessorFactory $processorFactory, + private RendererFactory $rendererFactory, + private ArchiveManager $archiveManager, + private ScopeConfigInterface $scopeConfig + ) {} /** - * @param ExportEntityInterface $exportEntity - * @return string|null * @throws FileSystemException * @throws NotFoundException * @throws NoSuchEntityException @@ -73,7 +58,7 @@ public function resolveExportRendererCodes(): array { return explode(',', (string)$this->scopeConfig->getValue( self::CONFIG_PATH_EXPORT_RENDERERS, - ScopeInterface::SCOPE_STORE //ToDo scope website + ScopeInterface::SCOPE_WEBSITE )); } diff --git a/Model/ExportEntityManagement.php b/Model/ExportEntityManagement.php index 32e11a67..95326a93 100644 --- a/Model/ExportEntityManagement.php +++ b/Model/ExportEntityManagement.php @@ -56,7 +56,7 @@ public function create(int $entityId, string $entityType, ?string $fileName = nu public function export(ExportEntityInterface $exportEntity): ExportEntityInterface { - $lifeTime = (int)$this->scopeConfig->getValue(self::CONFIG_PATH_EXPORT_LIFE_TIME, ScopeInterface::SCOPE_STORE);//Todo scope website + $lifeTime = (int)$this->scopeConfig->getValue(self::CONFIG_PATH_EXPORT_LIFE_TIME); $exportEntity->setFilePath($this->exportToFile->export($exportEntity)); $exportEntity->setExpiredAt( (new DateTime('+' . $lifeTime . 'minutes'))->format(DateTimeFormat::DATETIME_PHP_FORMAT) @@ -75,6 +75,6 @@ public function invalidate(ExportEntityInterface $exportEntity): ExportEntityInt private function resolveDefaultFileName(): string { - return (string)$this->scopeConfig->getValue(self::CONFIG_PATH_EXPORT_FILE_NAME, ScopeInterface::SCOPE_STORE);//Todo scope website + return (string)$this->scopeConfig->getValue(self::CONFIG_PATH_EXPORT_FILE_NAME, ScopeInterface::SCOPE_STORE); } } diff --git a/Block/Adminhtml/Customer/Edit/EraseButton.php b/Ui/Component/Customer/Form/EraseButton.php similarity index 65% rename from Block/Adminhtml/Customer/Edit/EraseButton.php rename to Ui/Component/Customer/Form/EraseButton.php index f0c9e82c..543394b6 100644 --- a/Block/Adminhtml/Customer/Edit/EraseButton.php +++ b/Ui/Component/Customer/Form/EraseButton.php @@ -5,10 +5,14 @@ */ declare(strict_types=1); -namespace Opengento\Gdpr\Block\Adminhtml\Customer\Edit; +namespace Opengento\Gdpr\Ui\Component\Customer\Form; use Magento\Backend\Block\Widget\Context; +use Magento\Customer\Api\CustomerRepositoryInterface; use Magento\Customer\Block\Adminhtml\Edit\GenericButton; +use Magento\Framework\AuthorizationInterface; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Phrase; use Magento\Framework\Registry; use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; @@ -20,20 +24,28 @@ class EraseButton extends GenericButton implements ButtonProviderInterface public function __construct( Context $context, Registry $registry, + private AuthorizationInterface $authorization, + private CustomerRepositoryInterface $customerRepository, private EraseEntityCheckerInterface $eraseCustomerChecker, private Config $config ) { parent::__construct($context, $registry); } + /** + * @throws LocalizedException + * @throws NoSuchEntityException + */ public function getButtonData(): array { $customerId = $this->getCustomerId(); + $customer = $this->customerRepository->getById($customerId); $buttonData = []; - if ($customerId && - $this->config->isModuleEnabled() && - $this->eraseCustomerChecker->canCreate($customerId, 'customer') + if ($customerId + && $this->authorization->isAllowed('Opengento_Gdpr::customer_erase') + && $this->config->isErasureEnabled($customer->getWebsiteId()) + && $this->eraseCustomerChecker->canCreate($customerId, 'customer') ) { $buttonData = [ 'label' => new Phrase('Erase Personal Data'), diff --git a/Block/Adminhtml/Customer/Edit/ExportButton.php b/Ui/Component/Customer/Form/ExportButton.php similarity index 72% rename from Block/Adminhtml/Customer/Edit/ExportButton.php rename to Ui/Component/Customer/Form/ExportButton.php index 7eb5602e..fa67918b 100644 --- a/Block/Adminhtml/Customer/Edit/ExportButton.php +++ b/Ui/Component/Customer/Form/ExportButton.php @@ -5,10 +5,12 @@ */ declare(strict_types=1); -namespace Opengento\Gdpr\Block\Adminhtml\Customer\Edit; +namespace Opengento\Gdpr\Ui\Component\Customer\Form; use Magento\Backend\Block\Widget\Context; +use Magento\Customer\Api\CustomerRepositoryInterface; use Magento\Customer\Block\Adminhtml\Edit\GenericButton; +use Magento\Framework\AuthorizationInterface; use Magento\Framework\Phrase; use Magento\Framework\Registry; use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; @@ -19,6 +21,8 @@ class ExportButton extends GenericButton implements ButtonProviderInterface public function __construct( Context $context, Registry $registry, + private AuthorizationInterface $authorization, + private CustomerRepositoryInterface $customerRepository, private Config $config ) { parent::__construct($context, $registry); @@ -27,9 +31,12 @@ public function __construct( public function getButtonData(): array { $customerId = $this->getCustomerId(); + $customer = $this->customerRepository->getById($customerId); $buttonData = []; - if ($customerId && $this->config->isModuleEnabled()) { + if ($customerId + && $this->authorization->isAllowed('Opengento_Gdpr::customer_export') + && $this->config->isExportEnabled($customer->getWebsiteId())) { $buttonData = [ 'label' => new Phrase('Export Personal Data'), 'class' => 'Export', diff --git a/Ui/Component/Order/Form/EraseButton.php b/Ui/Component/Order/Form/EraseButton.php new file mode 100644 index 00000000..a911a635 --- /dev/null +++ b/Ui/Component/Order/Form/EraseButton.php @@ -0,0 +1,57 @@ +getLayout()->getBlock('sales_order_edit'); + if ($orderView instanceof View) { + $orderId = (int)$orderView->getOrderId(); + + if ($this->_authorization->isAllowed('Opengento_Gdpr::order_erase') + && $this->config->isErasureEnabled($orderView->getOrder()->getStore()->getWebsiteId()) + && $this->eraseEntityChecker->canCreate($orderId, 'order') + ) { + $orderView->addButton( + 'opengento-gdpr-order-view-erase-button', + [ + 'label' => new Phrase('Erase Personal Data'), + 'class' => 'action-secondary erase', + 'onclick' => 'deleteConfirm("' . new Phrase('Are you sure you want to do this?') . '", "' + . $this->getUrl('sales/guest/erase', ['id' => $orderId]) . '", {"data":{}})', + ], + 1 + ); + } + } + } +} diff --git a/Ui/Component/Order/Form/ExportButton.php b/Ui/Component/Order/Form/ExportButton.php new file mode 100644 index 00000000..95432fe6 --- /dev/null +++ b/Ui/Component/Order/Form/ExportButton.php @@ -0,0 +1,52 @@ +getLayout()->getBlock('sales_order_edit'); + if ($orderView instanceof View) { + $orderId = (int)$orderView->getOrderId(); + + if ($this->_authorization->isAllowed('Opengento_Gdpr::order_export') + && $this->config->isErasureEnabled($orderView->getOrder()->getStore()->getWebsiteId()) + ) { + $orderView->addButton( + 'opengento-gdpr-order-view-export-button', + [ + 'label' => new Phrase('Export Personal Data'), + 'class' => 'export', + 'onclick' => 'setLocation("' . $this->getUrl('sales/guest/export', ['id' => $orderId]) . '")', + ] + ); + } + } + } +} diff --git a/etc/adminhtml/system/erasure.xml b/etc/adminhtml/system/erasure.xml index e586a386..0d948ed0 100644 --- a/etc/adminhtml/system/erasure.xml +++ b/etc/adminhtml/system/erasure.xml @@ -13,7 +13,7 @@ Opengento_Gdpr::config - + It will enable the erase action to the storefront. Magento\Config\Model\Config\Source\Enabledisable @@ -27,7 +27,7 @@ gdpr/erasure/block_id - + Erasure delay in minute before the execution by the cron. From 60 to 43800. validate-number validate-number-range number-range-60-43800 @@ -36,14 +36,14 @@ gdpr/erasure/delay - + 1 gdpr/erasure/entity_schedule - + The time is in days. validate-number validate-number-range number-range-0-1095 @@ -52,14 +52,14 @@ gdpr/erasure/entity_max_age - + 1 gdpr/erasure/entity_max_age_schedule - + The time is in days. validate-number validate-number-range number-range-0-3650 @@ -68,7 +68,7 @@ gdpr/erasure/sales_max_age - + Opengento\Gdpr\Model\Config\Source\OrderPendingStates @@ -77,7 +77,7 @@ 0 gdpr/erasure/allowed_states - + Defines the components erasure strategy with the component/erase processor mapper for the customers. Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\Customer\EraseComponentsProcessors @@ -88,7 +88,7 @@ 1 gdpr/erasure/customer_components_processors - + Defines the components erasure strategy with the component/erase processor mapper for the guests. Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\Order\EraseComponentsProcessors @@ -110,7 +110,7 @@ Magento\Cms\Model\Config\Source\Block gdpr/anonymize/block_id - + We will delete the customer if he has no orders. It's only applicable if the component "customer" use the "anonymize" processor. Magento\Config\Model\Config\Source\Yesno @@ -118,7 +118,7 @@ - + Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\AttributesAnonymizers Magento\Config\Model\Config\Backend\Serialized\ArraySerialized @@ -127,7 +127,7 @@ gdpr/anonymize/customer_attributes - + Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\AttributesAnonymizers Magento\Config\Model\Config\Backend\Serialized\ArraySerialized @@ -136,7 +136,7 @@ gdpr/anonymize/customer_custom_attributes - + Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\AttributesAnonymizers Magento\Config\Model\Config\Backend\Serialized\ArraySerialized @@ -148,7 +148,7 @@ - + Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\AttributesAnonymizers Magento\Config\Model\Config\Backend\Serialized\ArraySerialized @@ -157,7 +157,7 @@ gdpr/anonymize/customer_address_attributes - + Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\AttributesAnonymizers Magento\Config\Model\Config\Backend\Serialized\ArraySerialized @@ -166,7 +166,7 @@ gdpr/anonymize/customer_address_custom_attributes - + Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\AttributesAnonymizers Magento\Config\Model\Config\Backend\Serialized\ArraySerialized @@ -178,7 +178,7 @@ - + Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\AttributesAnonymizers Magento\Config\Model\Config\Backend\Serialized\ArraySerialized @@ -187,7 +187,7 @@ gdpr/anonymize/quote_attributes - + Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\AttributesAnonymizers Magento\Config\Model\Config\Backend\Serialized\ArraySerialized @@ -196,7 +196,7 @@ gdpr/anonymize/quote_custom_attributes - + Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\AttributesAnonymizers Magento\Config\Model\Config\Backend\Serialized\ArraySerialized @@ -208,7 +208,7 @@ - + Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\AttributesAnonymizers Magento\Config\Model\Config\Backend\Serialized\ArraySerialized @@ -217,7 +217,7 @@ gdpr/anonymize/quote_address_attributes - + Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\AttributesAnonymizers Magento\Config\Model\Config\Backend\Serialized\ArraySerialized @@ -226,7 +226,7 @@ gdpr/anonymize/quote_address_custom_attributes - + Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\AttributesAnonymizers Magento\Config\Model\Config\Backend\Serialized\ArraySerialized @@ -238,7 +238,7 @@ - + Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\AttributesAnonymizers Magento\Config\Model\Config\Backend\Serialized\ArraySerialized @@ -247,7 +247,7 @@ gdpr/anonymize/order_attributes - + Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\AttributesAnonymizers Magento\Config\Model\Config\Backend\Serialized\ArraySerialized @@ -256,7 +256,7 @@ gdpr/anonymize/order_custom_attributes - + Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\AttributesAnonymizers Magento\Config\Model\Config\Backend\Serialized\ArraySerialized @@ -268,7 +268,7 @@ - + Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\AttributesAnonymizers Magento\Config\Model\Config\Backend\Serialized\ArraySerialized @@ -277,7 +277,7 @@ gdpr/anonymize/order_address_attributes - + Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\AttributesAnonymizers Magento\Config\Model\Config\Backend\Serialized\ArraySerialized @@ -286,7 +286,7 @@ gdpr/anonymize/order_address_custom_attributes - + Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\AttributesAnonymizers Magento\Config\Model\Config\Backend\Serialized\ArraySerialized @@ -298,7 +298,7 @@ - + Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\AttributesAnonymizers Magento\Config\Model\Config\Backend\Serialized\ArraySerialized diff --git a/etc/adminhtml/system/export.xml b/etc/adminhtml/system/export.xml index 60e768a5..94d9361a 100644 --- a/etc/adminhtml/system/export.xml +++ b/etc/adminhtml/system/export.xml @@ -13,7 +13,7 @@ Opengento_Gdpr::config - + It will enable the export action to the storefront. Magento\Config\Model\Config\Source\Enabledisable @@ -28,7 +28,7 @@ gdpr/export/block_id - + Select formats of the export. Notice: At least one human and one machine readable format should be selected. Opengento\Gdpr\Model\Config\Source\ExportRenderer @@ -48,14 +48,14 @@ gdpr/export/file_name - + 1 gdpr/export/entity_schedule - + Export life time in minute before it is removed from the server. Opengento\Gdpr\Model\Config\Backend\Export @@ -65,7 +65,7 @@ gdpr/export/life_time - + 1 @@ -74,7 +74,7 @@ - + This attributes list will be exported when processed. Opengento\Gdpr\Model\Config\Source\CustomerAttributes @@ -85,7 +85,7 @@ gdpr/export/customer_attributes - + Comma-separated Opengento\Gdpr\Model\Config\Backend\Export @@ -95,7 +95,7 @@ gdpr/export/customer_custom_attributes - + Comma-separated Opengento\Gdpr\Model\Config\Backend\Export @@ -108,7 +108,7 @@ - + This attributes list will be exported when processed. Opengento\Gdpr\Model\Config\Source\CustomerAddressAttributes @@ -119,7 +119,7 @@ gdpr/export/customer_address_attributes - + Comma-separated Opengento\Gdpr\Model\Config\Backend\Export @@ -129,7 +129,7 @@ gdpr/export/customer_address_custom_attributes - + Comma-separated Opengento\Gdpr\Model\Config\Backend\Export @@ -142,7 +142,7 @@ - + Comma-separated Opengento\Gdpr\Model\Config\Backend\Export @@ -152,7 +152,7 @@ gdpr/export/quote_attributes - + Comma-separated Opengento\Gdpr\Model\Config\Backend\Export @@ -162,7 +162,7 @@ gdpr/export/quote_custom_attributes - + Comma-separated Opengento\Gdpr\Model\Config\Backend\Export @@ -175,7 +175,7 @@ - + Comma-separated Opengento\Gdpr\Model\Config\Backend\Export @@ -185,7 +185,7 @@ gdpr/export/quote_address_attributes - + Comma-separated Opengento\Gdpr\Model\Config\Backend\Export @@ -195,7 +195,7 @@ gdpr/export/quote_address_custom_attributes - + Comma-separated Opengento\Gdpr\Model\Config\Backend\Export @@ -208,7 +208,7 @@ - + Comma-separated Opengento\Gdpr\Model\Config\Backend\Export @@ -218,7 +218,7 @@ gdpr/export/order_attributes - + Comma-separated Opengento\Gdpr\Model\Config\Backend\Export @@ -228,7 +228,7 @@ gdpr/export/order_custom_attributes - + Comma-separated Opengento\Gdpr\Model\Config\Backend\Export @@ -241,7 +241,7 @@ - + Comma-separated Opengento\Gdpr\Model\Config\Backend\Export @@ -251,7 +251,7 @@ gdpr/export/order_address_attributes - + Comma-separated Opengento\Gdpr\Model\Config\Backend\Export @@ -261,7 +261,7 @@ gdpr/export/order_address_custom_attributes - + Comma-separated Opengento\Gdpr\Model\Config\Backend\Export @@ -274,7 +274,7 @@ - + Comma-separated Opengento\Gdpr\Model\Config\Backend\Export diff --git a/etc/adminhtml/system/general.xml b/etc/adminhtml/system/general.xml index e28a9bf0..6967dce5 100644 --- a/etc/adminhtml/system/general.xml +++ b/etc/adminhtml/system/general.xml @@ -13,7 +13,7 @@ Opengento_Gdpr::config - + It will enable the module features in the admin and frontend ui. Magento\Config\Model\Config\Source\Yesno diff --git a/etc/db_schema.xml b/etc/db_schema.xml index 3743380b..8c90064d 100644 --- a/etc/db_schema.xml +++ b/etc/db_schema.xml @@ -19,15 +19,15 @@ - + - + diff --git a/etc/db_schema_whitelist.json b/etc/db_schema_whitelist.json index 5fbd8e89..28ff885d 100644 --- a/etc/db_schema_whitelist.json +++ b/etc/db_schema_whitelist.json @@ -13,8 +13,8 @@ "index": { "OPENGENTO_GDPR_ERASE_ENTITY_ENTITY_ID": true, "OPENGENTO_GDPR_ERASE_ENTITY_ENTITY_TYPE": true, - "OPENGENTO_GDPR_ERASE_ENTITY_ENTITY_TYPE_ENTITY_ID": true, - "OPENGENTO_GDPR_ERASE_ENTITY_SCHEDULED_AT_STATE_STATUS": true + "OPENGENTO_GDPR_ERASE_ENTITY_IDENTITY": true, + "OPENGENTO_GDPR_ERASE_ENTITY_SCHEDULED_PROCESS": true }, "constraint": { "PRIMARY": true, @@ -35,7 +35,7 @@ "index": { "OPENGENTO_GDPR_EXPORT_ENTITY_ENTITY_ID": true, "OPENGENTO_GDPR_EXPORT_ENTITY_ENTITY_TYPE": true, - "OPENGENTO_GDPR_EXPORT_ENTITY_ENTITY_ID_ENTITY_TYPE": true, + "OPENGENTO_GDPR_EXPORT_ENTITY_IDENTITY": true, "OPENGENTO_GDPR_EXPORT_ENTITY_EXPORTED_AT": true, "OPENGENTO_GDPR_EXPORT_ENTITY_EXPIRED_AT": true }, diff --git a/etc/di.xml b/etc/di.xml index f3f6142a..49ff7ea0 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -1429,11 +1429,11 @@ - gdpr/notification/erasure/pending/customer/enabled - gdpr/notification/erasure/pending/customer/identity - gdpr/notification/erasure/pending/customer/copy_to - gdpr/notification/erasure/pending/customer/copy_method - gdpr/notification/erasure/pending/customer/template + gdpr/notification/erase_pending_enabled + gdpr/notification/erase_pending_identity + gdpr/notification/erase_pending_copy_to + gdpr/notification/erase_pending_copy_method + gdpr/notification/erase_pending_template @@ -1447,11 +1447,11 @@ - gdpr/notification/erasure/succeeded/customer/enabled - gdpr/notification/erasure/succeeded/customer/identity - gdpr/notification/erasure/succeeded/customer/copy_to - gdpr/notification/erasure/succeeded/customer/copy_method - gdpr/notification/erasure/succeeded/customer/template + gdpr/notification/erase_succeeded_enabled + gdpr/notification/erase_succeeded_identity + gdpr/notification/erase_succeeded_copy_to + gdpr/notification/erase_succeeded_copy_method + gdpr/notification/erase_succeeded_template @@ -1465,11 +1465,11 @@ - gdpr/notification/erasure/canceled/customer/enabled - gdpr/notification/erasure/canceled/customer/identity - gdpr/notification/erasure/canceled/customer/copy_to - gdpr/notification/erasure/canceled/customer/copy_method - gdpr/notification/erasure/canceled/customer/template + gdpr/notification/erase_canceled_enabled + gdpr/notification/erase_canceled_identity + gdpr/notification/erase_canceled_copy_to + gdpr/notification/erase_canceled_copy_method + gdpr/notification/erase_canceled_template @@ -1484,11 +1484,11 @@ - gdpr/notification/erasure/pending/order/enabled - gdpr/notification/erasure/pending/order/identity - gdpr/notification/erasure/pending/order/copy_to - gdpr/notification/erasure/pending/order/copy_method - gdpr/notification/erasure/pending/order/template + gdpr/notification/erase_pending_enabled + gdpr/notification/erase_pending_identity + gdpr/notification/erase_pending_copy_to + gdpr/notification/erase_pending_copy_method + gdpr/notification/erase_pending_guest_template @@ -1502,11 +1502,11 @@ - gdpr/notification/erasure/succeeded/order/enabled - gdpr/notification/erasure/succeeded/order/identity - gdpr/notification/erasure/succeeded/order/copy_to - gdpr/notification/erasure/succeeded/order/copy_method - gdpr/notification/erasure/succeeded/order/template + gdpr/notification/erase_succeeded_enabled + gdpr/notification/erase_succeeded_identity + gdpr/notification/erase_succeeded_copy_to + gdpr/notification/erase_succeeded_copy_method + gdpr/notification/erase_succeeded_guest_template @@ -1520,11 +1520,11 @@ - gdpr/notification/erasure/canceled/order/enabled - gdpr/notification/erasure/canceled/order/identity - gdpr/notification/erasure/canceled/order/copy_to - gdpr/notification/erasure/canceled/order/copy_method - gdpr/notification/erasure/canceled/order/template + gdpr/notification/erase_canceled_enabled + gdpr/notification/erase_canceled_identity + gdpr/notification/erase_canceled_copy_to + gdpr/notification/erase_canceled_copy_method + gdpr/notification/erase_canceled_guest_template @@ -1558,11 +1558,11 @@ - gdpr/notification/export/pending/customer/enabled - gdpr/notification/export/pending/customer/identity - gdpr/notification/export/pending/customer/copy_to - gdpr/notification/export/pending/customer/copy_method - gdpr/notification/export/pending/customer/template + gdpr/notification/export_pending_enabled + gdpr/notification/export_pending_identity + gdpr/notification/export_pending_copy_to + gdpr/notification/export_pending_copy_method + gdpr/notification/export_pending_template @@ -1576,11 +1576,11 @@ - gdpr/notification/export/ready/customer/enabled - gdpr/notification/export/ready/customer/identity - gdpr/notification/export/ready/customer/copy_to - gdpr/notification/export/ready/customer/copy_method - gdpr/notification/export/ready/customer/template + gdpr/notification/export_ready_enabled + gdpr/notification/export_ready_identity + gdpr/notification/export_ready_copy_to + gdpr/notification/export_ready_copy_method + gdpr/notification/export_ready_template @@ -1595,11 +1595,11 @@ - gdpr/notification/export/pending/order/enabled - gdpr/notification/export/pending/order/identity - gdpr/notification/export/pending/order/copy_to - gdpr/notification/export/pending/order/copy_method - gdpr/notification/export/pending/order/template + gdpr/notification/export_pending_enabled + gdpr/notification/export_pending_identity + gdpr/notification/export_pending_copy_to + gdpr/notification/export_pending_copy_method + gdpr/notification/export_pending_guest_template @@ -1613,11 +1613,11 @@ - gdpr/notification/export/ready/order/enabled - gdpr/notification/export/ready/order/identity - gdpr/notification/export/ready/order/copy_to - gdpr/notification/export/ready/order/copy_method - gdpr/notification/export/ready/order/template + gdpr/notification/export_ready_enabled + gdpr/notification/export_ready_identity + gdpr/notification/export_ready_copy_to + gdpr/notification/export_ready_copy_method + gdpr/notification/export_ready_guest_template diff --git a/view/adminhtml/layout/sales_order_view.xml b/view/adminhtml/layout/sales_order_view.xml index 17478eb6..8da82ce7 100644 --- a/view/adminhtml/layout/sales_order_view.xml +++ b/view/adminhtml/layout/sales_order_view.xml @@ -8,8 +8,8 @@ - - + + diff --git a/view/adminhtml/ui_component/customer_form.xml b/view/adminhtml/ui_component/customer_form.xml index e7eb29e6..ccd5a5d5 100644 --- a/view/adminhtml/ui_component/customer_form.xml +++ b/view/adminhtml/ui_component/customer_form.xml @@ -8,8 +8,8 @@
-