diff --git a/Api/Data/EraseEntityInterface.php b/Api/Data/EraseEntityInterface.php index bbd19c1..ad210df 100644 --- a/Api/Data/EraseEntityInterface.php +++ b/Api/Data/EraseEntityInterface.php @@ -10,12 +10,11 @@ use Magento\Framework\Api\ExtensibleDataInterface; /** - * Interface EraseEntityInterface * @api */ interface EraseEntityInterface extends ExtensibleDataInterface { - /**#@+ + /** * Constants for fields keys */ public const ID = 'erase_id'; @@ -26,143 +25,58 @@ interface EraseEntityInterface extends ExtensibleDataInterface public const STATUS = 'status'; public const MESSAGE = 'message'; public const ERASED_AT = 'erased_at'; - /**#@-*/ - /**#@+ + /** * Constants for State values */ public const STATE_PENDING = 'pending'; public const STATE_PROCESSING = 'processing'; public const STATE_COMPLETE = 'complete'; - /**#@-*/ - /**#@+ + /** * Constants for Status values */ public const STATUS_READY = 'ready'; public const STATUS_RUNNING = 'running'; public const STATUS_FAILED = 'failed'; public const STATUS_SUCCEED = 'succeed'; - /**#@-*/ - /** - * Retrieve the erase ID - * - * @return int - */ public function getEraseId(): int; - /** - * Set the erase ID - * - * @param int $eraseId - * @return \Opengento\Gdpr\Api\Data\EraseEntityInterface - */ public function setEraseId(int $eraseId): EraseEntityInterface; - /** - * Retrieve the entity ID - * - * @return int - */ public function getEntityId(): int; /** * Set the entity ID * * @param int $entityId - * @return \Opengento\Gdpr\Api\Data\EraseEntityInterface + * @return EraseEntityInterface * @todo force type in php7.4 */ public function setEntityId($entityId): EraseEntityInterface; - /** - * Retrieve the entity type - * - * @return string - */ public function getEntityType(): string; - /** - * Set the entity type - * - * @param string $entityType - * @return \Opengento\Gdpr\Api\Data\EraseEntityInterface - */ public function setEntityType(string $entityType): EraseEntityInterface; - /** - * Retrieve the scheduled at - * - * @return string - */ public function getScheduledAt(): string; - /** - * Set the schedule at - * - * @param string $scheduledAt - * @return \Opengento\Gdpr\Api\Data\EraseEntityInterface - */ public function setScheduledAt(string $scheduledAt): EraseEntityInterface; - /** - * Retrieve the state - * - * @return string - */ public function getState(): string; - /** - * Set the state - * - * @param string $state - * @return \Opengento\Gdpr\Api\Data\EraseEntityInterface - */ public function setState(string $state): EraseEntityInterface; - /** - * Retrieve the status - * - * @return string - */ public function getStatus(): string; - /** - * Set the status - * - * @param string $status - * @return \Opengento\Gdpr\Api\Data\EraseEntityInterface - */ public function setStatus(string $status): EraseEntityInterface; - /** - * Retrieve the error message - * - * @return string|null - */ public function getMessage(): ?string; - /** - * Set the error message - * - * @param string|null $message - * @return \Opengento\Gdpr\Api\Data\EraseEntityInterface - */ public function setMessage(?string $message): EraseEntityInterface; - /** - * Retrieve the erased at if it exists - * - * @return string|null - */ public function getErasedAt(): ?string; - /** - * Set the erased at - * - * @param string $erasedAt - * @return \Opengento\Gdpr\Api\Data\EraseEntityInterface - */ public function setErasedAt(string $erasedAt): EraseEntityInterface; } diff --git a/Api/Data/EraseEntitySearchResultsInterface.php b/Api/Data/EraseEntitySearchResultsInterface.php index 0f62f80..09295fb 100644 --- a/Api/Data/EraseEntitySearchResultsInterface.php +++ b/Api/Data/EraseEntitySearchResultsInterface.php @@ -10,7 +10,6 @@ use Magento\Framework\Api\SearchResultsInterface; /** - * Interface EraseEntitySearchResultsInterface * @api */ interface EraseEntitySearchResultsInterface extends SearchResultsInterface @@ -18,15 +17,15 @@ interface EraseEntitySearchResultsInterface extends SearchResultsInterface /** * Retrieve the erase entity schedulers list * - * @return \Opengento\Gdpr\Api\Data\EraseEntityInterface[] + * @return EraseEntityInterface[] */ public function getItems(): array; /** * Set the erase entity schedulers list * - * @param \Opengento\Gdpr\Api\Data\EraseEntityInterface[] $items - * @return \Opengento\Gdpr\Api\Data\EraseEntitySearchResultsInterface + * @param EraseEntityInterface[] $items + * @return EraseEntitySearchResultsInterface */ public function setItems(array $items): EraseEntitySearchResultsInterface; } diff --git a/Api/Data/ExportEntityInterface.php b/Api/Data/ExportEntityInterface.php index 6371131..560a753 100644 --- a/Api/Data/ExportEntityInterface.php +++ b/Api/Data/ExportEntityInterface.php @@ -8,12 +8,11 @@ namespace Opengento\Gdpr\Api\Data; /** - * Interface ExportEntityInterface * @api */ interface ExportEntityInterface { - /**#@+ + /** * Constants for fields keys */ public const ID = 'export_id'; @@ -24,126 +23,43 @@ interface ExportEntityInterface public const CREATED_AT = 'created_at'; public const EXPORTED_AT = 'exported_at'; public const EXPIRED_AT = 'expired_at'; - /**#@-*/ - /** - * Retrieve the export ID - * - * @return int - */ public function getExportId(): int; - /** - * Set the export ID - * - * @param int $exportId - * @return ExportEntityInterface - */ public function setExportId(int $exportId): ExportEntityInterface; - /** - * Retrieve the entity ID to export - * - * @return int - */ public function getEntityId(): int; /** - * Set the entity ID to export + * Set the entity ID * * @param int $entityId * @return ExportEntityInterface + * @todo force type in php7.4 */ public function setEntityId($entityId): ExportEntityInterface; - /** - * Retrieve the entity type to export - * - * @return string - */ public function getEntityType(): string; - /** - * Set the entity type to export - * - * @param string $entityType - * @return ExportEntityInterface - * @todo force type in php7.4 - */ public function setEntityType(string $entityType): ExportEntityInterface; - /** - * Retrieve the file name to export the data to - * - * @return string - */ public function getFileName(): string; - /** - * Set the file name to export the data to - * - * @param string $filename - * @return ExportEntityInterface - */ public function setFileName(string $filename): ExportEntityInterface; - /** - * Retrieve the export file absolute path - * - * @return string|null - */ public function getFilePath(): ?string; - /** - * Set the export file absolute path - * - * @param string $filePath - * @return ExportEntityInterface - */ public function setFilePath(string $filePath): ExportEntityInterface; - /** - * Retrieve the created at date of the export - * - * @return string - */ public function getCreatedAt(): string; - /** - * Set the created at date of the export - * - * @param string $createdAt - * @return ExportEntityInterface - */ public function setCreatedAt(string $createdAt): ExportEntityInterface; - /** - * Retrieve the last exported at date - * - * @return string|null - */ public function getExportedAt(): ?string; - /** - * Set the last exported at date - * - * @param string $exportedAt - * @return ExportEntityInterface - */ public function setExportedAt(string $exportedAt): ExportEntityInterface; - /** - * Retrieve the date expiration of the export - * - * @return string - */ public function getExpiredAt(): string; - /** - * Set the expiration date of the export - * - * @param string $expiredAt - * @return ExportEntityInterface - */ public function setExpiredAt(string $expiredAt): ExportEntityInterface; } diff --git a/Api/Data/ExportEntitySearchResultsInterface.php b/Api/Data/ExportEntitySearchResultsInterface.php index e8ab102..29dc3a7 100644 --- a/Api/Data/ExportEntitySearchResultsInterface.php +++ b/Api/Data/ExportEntitySearchResultsInterface.php @@ -10,7 +10,6 @@ use Magento\Framework\Api\SearchResultsInterface; /** - * Interface ExportEntitySearchResultsInterface * @api */ interface ExportEntitySearchResultsInterface extends SearchResultsInterface @@ -18,15 +17,15 @@ interface ExportEntitySearchResultsInterface extends SearchResultsInterface /** * Retrieve the export entities list * - * @return \Opengento\Gdpr\Api\Data\ExportEntityInterface[] + * @return ExportEntityInterface[] */ public function getItems(): array; /** * Set the export entities list * - * @param \Opengento\Gdpr\Api\Data\ExportEntityInterface[] $items - * @return \Opengento\Gdpr\Api\Data\ExportEntitySearchResultsInterface + * @param ExportEntityInterface[] $items + * @return ExportEntitySearchResultsInterface */ public function setItems(array $items): ExportEntitySearchResultsInterface; } diff --git a/Api/EraseEntityCheckerInterface.php b/Api/EraseEntityCheckerInterface.php index 9fe3431..92420b6 100644 --- a/Api/EraseEntityCheckerInterface.php +++ b/Api/EraseEntityCheckerInterface.php @@ -8,44 +8,15 @@ namespace Opengento\Gdpr\Api; /** - * Interface EraseEntityCheckerInterface * @api */ interface EraseEntityCheckerInterface { - /** - * Check if an erase entity scheduler already exists for this entity - * - * @param int $entityId - * @param string $entityType - * @return bool - */ public function exists(int $entityId, string $entityType): bool; - /** - * Check if an erase entity scheduler can be created for this entity - * - * @param int $entityId - * @param string $entityType - * @return bool - */ public function canCreate(int $entityId, string $entityType): bool; - /** - * Check if an erase entity scheduler can be canceled - * - * @param int $entityId - * @param string $entityType - * @return bool - */ public function canCancel(int $entityId, string $entityType): bool; - /** - * Check if an erase entity scheduler can be processed - * - * @param int $entityId - * @param string $entityType - * @return bool - */ public function canProcess(int $entityId, string $entityType): bool; } diff --git a/Api/EraseEntityManagementInterface.php b/Api/EraseEntityManagementInterface.php index 290e78c..71beba0 100644 --- a/Api/EraseEntityManagementInterface.php +++ b/Api/EraseEntityManagementInterface.php @@ -7,10 +7,13 @@ namespace Opengento\Gdpr\Api; +use Magento\Framework\Exception\CouldNotDeleteException; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\NoSuchEntityException; use Opengento\Gdpr\Api\Data\EraseEntityInterface; /** - * Interface EraseEntityManagementInterface * @api */ interface EraseEntityManagementInterface @@ -20,9 +23,9 @@ interface EraseEntityManagementInterface * * @param int $entityId * @param string $entityType - * @return \Opengento\Gdpr\Api\Data\EraseEntityInterface - * @throws \Magento\Framework\Exception\CouldNotSaveException - * @throws \Magento\Framework\Exception\LocalizedException + * @return EraseEntityInterface + * @throws CouldNotSaveException + * @throws LocalizedException */ public function create(int $entityId, string $entityType): EraseEntityInterface; @@ -32,9 +35,9 @@ public function create(int $entityId, string $entityType): EraseEntityInterface; * @param int $entityId * @param string $entityType * @return bool - * @throws \Magento\Framework\Exception\NoSuchEntityException - * @throws \Magento\Framework\Exception\CouldNotDeleteException - * @throws \Magento\Framework\Exception\LocalizedException + * @throws NoSuchEntityException + * @throws CouldNotDeleteException + * @throws LocalizedException * * @todo should not be responsible of the deletion (cancel != delete) */ @@ -43,10 +46,10 @@ public function cancel(int $entityId, string $entityType): bool; /** * Run and process the erase entity scheduler command * - * @param \Opengento\Gdpr\Api\Data\EraseEntityInterface $entity - * @return \Opengento\Gdpr\Api\Data\EraseEntityInterface - * @throws \Magento\Framework\Exception\NoSuchEntityException - * @throws \Magento\Framework\Exception\LocalizedException + * @param EraseEntityInterface $entity + * @return EraseEntityInterface + * @throws NoSuchEntityException + * @throws LocalizedException */ public function process(EraseEntityInterface $entity): EraseEntityInterface; } diff --git a/Api/EraseEntityRepositoryInterface.php b/Api/EraseEntityRepositoryInterface.php index edddff7..8dba84b 100644 --- a/Api/EraseEntityRepositoryInterface.php +++ b/Api/EraseEntityRepositoryInterface.php @@ -9,10 +9,14 @@ use Magento\Framework\Api\SearchCriteriaInterface; use Magento\Framework\Api\SearchResultsInterface; +use Magento\Framework\Exception\CouldNotDeleteException; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\NoSuchEntityException; use Opengento\Gdpr\Api\Data\EraseEntityInterface; +use Opengento\Gdpr\Api\Data\EraseEntitySearchResultsInterface; /** - * Interface EraseEntityRepositoryInterface * @api */ interface EraseEntityRepositoryInterface @@ -20,9 +24,9 @@ interface EraseEntityRepositoryInterface /** * Save erase entity scheduler * - * @param \Opengento\Gdpr\Api\Data\EraseEntityInterface $entity - * @return \Opengento\Gdpr\Api\Data\EraseEntityInterface - * @throws \Magento\Framework\Exception\CouldNotSaveException + * @param EraseEntityInterface $entity + * @return EraseEntityInterface + * @throws CouldNotSaveException */ public function save(EraseEntityInterface $entity): EraseEntityInterface; @@ -30,8 +34,8 @@ public function save(EraseEntityInterface $entity): EraseEntityInterface; * Retrieve erase entity scheduler by ID * * @param int $entityId - * @return \Opengento\Gdpr\Api\Data\EraseEntityInterface - * @throws \Magento\Framework\Exception\NoSuchEntityException + * @return EraseEntityInterface + * @throws NoSuchEntityException */ public function getById(int $entityId): EraseEntityInterface; @@ -40,27 +44,27 @@ public function getById(int $entityId): EraseEntityInterface; * * @param int $entityId * @param string $entityType - * @return \Opengento\Gdpr\Api\Data\EraseEntityInterface - * @throws \Magento\Framework\Exception\NoSuchEntityException + * @return EraseEntityInterface + * @throws NoSuchEntityException */ public function getByEntity(int $entityId, string $entityType): EraseEntityInterface; /** * Retrieve erase entity schedulers list by search filter criteria * - * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria - * @return \Opengento\Gdpr\Api\Data\EraseEntitySearchResultsInterface - * @throws \Magento\Framework\Exception\LocalizedException + * @param SearchCriteriaInterface $searchCriteria + * @return EraseEntitySearchResultsInterface + * @throws LocalizedException */ public function getList(SearchCriteriaInterface $searchCriteria): SearchResultsInterface; /** * Delete erase entity scheduler * - * @param \Opengento\Gdpr\Api\Data\EraseEntityInterface $entity + * @param EraseEntityInterface $entity * @return bool true on success - * @throws \Magento\Framework\Exception\NoSuchEntityException - * @throws \Magento\Framework\Exception\CouldNotDeleteException + * @throws NoSuchEntityException + * @throws CouldNotDeleteException */ public function delete(EraseEntityInterface $entity): bool; } diff --git a/Api/EraseSalesInformationInterface.php b/Api/EraseSalesInformationInterface.php index dd8f307..d22a8a5 100644 --- a/Api/EraseSalesInformationInterface.php +++ b/Api/EraseSalesInformationInterface.php @@ -10,26 +10,11 @@ use Opengento\Gdpr\Api\Data\EraseEntityInterface; /** - * Interface EraseSalesInformationInterface * @api */ interface EraseSalesInformationInterface { - /** - * Schedule the sales information erasure for an entity - * - * @param int $entityId - * @param string $entityType - * @param \DateTime $lastActive - * @return \Opengento\Gdpr\Api\Data\EraseEntityInterface - */ public function scheduleEraseEntity(int $entityId, string $entityType, \DateTime $lastActive): EraseEntityInterface; - /** - * Check if the date time is under the sales information lifetime limit - * - * @param \DateTime $lastActive - * @return bool - */ public function isAlive(\DateTime $lastActive): bool; } diff --git a/Api/ExportEntityCheckerInterface.php b/Api/ExportEntityCheckerInterface.php index 4a28964..58a559a 100644 --- a/Api/ExportEntityCheckerInterface.php +++ b/Api/ExportEntityCheckerInterface.php @@ -8,26 +8,11 @@ namespace Opengento\Gdpr\Api; /** - * Interface ExportEntityCheckerInterface * @api */ interface ExportEntityCheckerInterface { - /** - * Check if an export entity already exists for this entity - * - * @param int $entityId - * @param string $entityType - * @return bool - */ public function exists(int $entityId, string $entityType): bool; - /** - * Check if the document is exported and ready - * - * @param int $entityId - * @param string $entityType - * @return bool - */ public function isExported(int $entityId, string $entityType): bool; } diff --git a/Api/ExportEntityManagementInterface.php b/Api/ExportEntityManagementInterface.php index 7cb9310..e5f4f8e 100644 --- a/Api/ExportEntityManagementInterface.php +++ b/Api/ExportEntityManagementInterface.php @@ -8,10 +8,11 @@ namespace Opengento\Gdpr\Api; use Magento\Framework\Exception\AlreadyExistsException; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Exception\LocalizedException; use Opengento\Gdpr\Api\Data\ExportEntityInterface; /** - * Interface ExportEntityManagementInterface * @api */ interface ExportEntityManagementInterface @@ -24,18 +25,18 @@ interface ExportEntityManagementInterface * @param null|string $fileName [optional] * @return ExportEntityInterface * @throws AlreadyExistsException - * @throws \Magento\Framework\Exception\CouldNotSaveException - * @throws \Magento\Framework\Exception\LocalizedException + * @throws CouldNotSaveException + * @throws LocalizedException */ public function create(int $entityId, string $entityType, ?string $fileName = null): ExportEntityInterface; /** * Export all data related to a given entity to the file * - * @param \Opengento\Gdpr\Api\Data\ExportEntityInterface $exportEntity + * @param ExportEntityInterface $exportEntity * @return string - * @throws \Magento\Framework\Exception\CouldNotSaveException - * @throws \Magento\Framework\Exception\LocalizedException + * @throws CouldNotSaveException + * @throws LocalizedException */ public function export(ExportEntityInterface $exportEntity): string; } diff --git a/Api/ExportEntityRepositoryInterface.php b/Api/ExportEntityRepositoryInterface.php index bc3978a..8111a76 100644 --- a/Api/ExportEntityRepositoryInterface.php +++ b/Api/ExportEntityRepositoryInterface.php @@ -9,10 +9,14 @@ use Magento\Framework\Api\SearchCriteriaInterface; use Magento\Framework\Api\SearchResultsInterface; +use Magento\Framework\Exception\CouldNotDeleteException; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\NoSuchEntityException; use Opengento\Gdpr\Api\Data\ExportEntityInterface; +use Opengento\Gdpr\Api\Data\ExportEntitySearchResultsInterface; /** - * Interface ExportEntityRepositoryInterface * @api */ interface ExportEntityRepositoryInterface @@ -20,9 +24,9 @@ interface ExportEntityRepositoryInterface /** * Save export entity * - * @param \Opengento\Gdpr\Api\Data\ExportEntityInterface $entity - * @return \Opengento\Gdpr\Api\Data\ExportEntityInterface - * @throws \Magento\Framework\Exception\CouldNotSaveException + * @param ExportEntityInterface $entity + * @return ExportEntityInterface + * @throws CouldNotSaveException */ public function save(ExportEntityInterface $entity): ExportEntityInterface; @@ -30,8 +34,8 @@ public function save(ExportEntityInterface $entity): ExportEntityInterface; * Retrieve export entity by ID * * @param int $entityId - * @return \Opengento\Gdpr\Api\Data\ExportEntityInterface - * @throws \Magento\Framework\Exception\NoSuchEntityException + * @return ExportEntityInterface + * @throws NoSuchEntityException */ public function getById(int $entityId): ExportEntityInterface; @@ -40,27 +44,27 @@ public function getById(int $entityId): ExportEntityInterface; * * @param int $entityId * @param string $entityType - * @return \Opengento\Gdpr\Api\Data\ExportEntityInterface - * @throws \Magento\Framework\Exception\NoSuchEntityException + * @return ExportEntityInterface + * @throws NoSuchEntityException */ public function getByEntity(int $entityId, string $entityType): ExportEntityInterface; /** * Retrieve export entity list by search filter criteria * - * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria - * @return \Opengento\Gdpr\Api\Data\ExportEntitySearchResultsInterface - * @throws \Magento\Framework\Exception\LocalizedException + * @param SearchCriteriaInterface $searchCriteria + * @return ExportEntitySearchResultsInterface + * @throws LocalizedException */ public function getList(SearchCriteriaInterface $searchCriteria): SearchResultsInterface; /** * Delete export entity * - * @param \Opengento\Gdpr\Api\Data\ExportEntityInterface $entity + * @param ExportEntityInterface $entity * @return bool true on success - * @throws \Magento\Framework\Exception\NoSuchEntityException - * @throws \Magento\Framework\Exception\CouldNotDeleteException + * @throws NoSuchEntityException + * @throws CouldNotDeleteException */ public function delete(ExportEntityInterface $entity): bool; } diff --git a/Block/Adminhtml/Config/Form/Field/AttributesAnonymizers.php b/Block/Adminhtml/Config/Form/Field/AttributesAnonymizers.php index 65813da..b493c9d 100644 --- a/Block/Adminhtml/Config/Form/Field/AttributesAnonymizers.php +++ b/Block/Adminhtml/Config/Form/Field/AttributesAnonymizers.php @@ -9,21 +9,16 @@ use Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray; use Magento\Framework\DataObject; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Phrase; use Magento\Framework\View\Element\Html\Select; -/** - * Class AttributesAnonymizers - */ final class AttributesAnonymizers extends AbstractFieldArray { private const ANONYMIZERS_SELECT = '\Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\Select\Anonymizers'; /** - * Retrieve the anonymizers select renderer - * - * @return \Magento\Framework\View\Element\Html\Select - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ public function getAnonymizersSelectRenderer(): Select { @@ -43,7 +38,7 @@ public function getAnonymizersSelectRenderer(): Select /** * @inheritdoc - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ protected function _prepareToRender(): void { @@ -67,7 +62,7 @@ protected function _prepareToRender(): void /** * @inheritdoc - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ protected function _prepareArrayRow(DataObject $row): void { diff --git a/Block/Adminhtml/Config/Form/Field/EraseComponentsProcessors.php b/Block/Adminhtml/Config/Form/Field/EraseComponentsProcessors.php index b1f6a66..3852270 100644 --- a/Block/Adminhtml/Config/Form/Field/EraseComponentsProcessors.php +++ b/Block/Adminhtml/Config/Form/Field/EraseComponentsProcessors.php @@ -9,22 +9,17 @@ use Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray; use Magento\Framework\DataObject; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Phrase; use Magento\Framework\View\Element\Html\Select; use Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\Select\EraseComponents; -/** - * Class EraseComponentsProcessors - */ final class EraseComponentsProcessors extends AbstractFieldArray { private const ERASE_PROCESSORS_SELECT = '\Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\Select\EraseProcessors'; /** - * Retrieve the erase components select renderer - * - * @return \Opengento\Gdpr\Block\Adminhtml\Config\Form\Field\Select\EraseComponents - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ public function getEraseComponentsSelectRenderer(): EraseComponents { @@ -43,10 +38,7 @@ public function getEraseComponentsSelectRenderer(): EraseComponents } /** - * Retrieve the erase processors select renderer - * - * @return \Magento\Framework\View\Element\Html\Select - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ public function getEraseProcessorsSelectRenderer(): Select { @@ -66,7 +58,7 @@ public function getEraseProcessorsSelectRenderer(): Select /** * @inheritdoc - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ protected function _prepareToRender(): void { @@ -90,7 +82,7 @@ protected function _prepareToRender(): void /** * @inheritdoc - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ protected function _prepareArrayRow(DataObject $row): void { diff --git a/Block/Adminhtml/Config/Form/Field/Select/EraseComponents.php b/Block/Adminhtml/Config/Form/Field/Select/EraseComponents.php index 3c9265b..41c3eec 100644 --- a/Block/Adminhtml/Config/Form/Field/Select/EraseComponents.php +++ b/Block/Adminhtml/Config/Form/Field/Select/EraseComponents.php @@ -9,46 +9,29 @@ use Magento\Framework\View\Element\Context; use Magento\Framework\View\Element\Html\Select; -use Opengento\Gdpr\Model\Config\Source\EraseComponents as EraseComponentsSrouce; +use Opengento\Gdpr\Model\Config\Source\EraseComponents as EraseComponentsSource; -/** - * Class EraseComponents - */ final class EraseComponents extends Select { /** - * @var \Opengento\Gdpr\Model\Config\Source\EraseComponents + * @var EraseComponentsSource */ private $eraseComponentSource; - /** - * @param \Magento\Framework\View\Element\Context $context - * @param \Opengento\Gdpr\Model\Config\Source\EraseComponents $eraseComponentSource - * @param array $data - */ public function __construct( Context $context, - EraseComponentsSrouce $eraseComponentSource, + EraseComponentsSource $eraseComponentSource, array $data = [] ) { $this->eraseComponentSource = $eraseComponentSource; parent::__construct($context, $data); } - /** - * Set the input name - * - * @param string $value - * @return $this - */ - public function setInputName($value): self + public function setInputName(string $inputName): self { - return $this->setData('name', $value); + return $this->setData('name', $inputName); } - /** - * @inheritdoc - */ protected function _toHtml(): string { if (!$this->getOptions()) { diff --git a/Block/Adminhtml/Config/Form/Field/Select/OptionSourceSelect.php b/Block/Adminhtml/Config/Form/Field/Select/OptionSourceSelect.php index c230498..7ba9704 100644 --- a/Block/Adminhtml/Config/Form/Field/Select/OptionSourceSelect.php +++ b/Block/Adminhtml/Config/Form/Field/Select/OptionSourceSelect.php @@ -11,21 +11,13 @@ use Magento\Framework\View\Element\Context; use Magento\Framework\View\Element\Html\Select; -/** - * Class OptionSourceSelect - */ final class OptionSourceSelect extends Select { /** - * @var \Magento\Framework\Data\OptionSourceInterface + * @var OptionSourceInterface */ private $optionSource; - /** - * @param \Magento\Framework\View\Element\Context $context - * @param \Magento\Framework\Data\OptionSourceInterface $optionSource - * @param array $data - */ public function __construct( Context $context, OptionSourceInterface $optionSource, @@ -35,20 +27,11 @@ public function __construct( parent::__construct($context, $data); } - /** - * Set the input name - * - * @param string $value - * @return $this - */ - public function setInputName($value): self + public function setInputName(string $inputName): self { - return $this->setData('name', $value); + return $this->setData('name', $inputName); } - /** - * @inheritdoc - */ protected function _toHtml(): string { if (!$this->getOptions()) { diff --git a/Block/Adminhtml/Customer/Edit/EraseButton.php b/Block/Adminhtml/Customer/Edit/EraseButton.php index 088f7bc..8a78d4f 100644 --- a/Block/Adminhtml/Customer/Edit/EraseButton.php +++ b/Block/Adminhtml/Customer/Edit/EraseButton.php @@ -15,27 +15,18 @@ use Opengento\Gdpr\Api\EraseEntityCheckerInterface; use Opengento\Gdpr\Model\Config; -/** - * Class EraseButton - */ final class EraseButton extends GenericButton implements ButtonProviderInterface { /** - * @var \Opengento\Gdpr\Api\EraseEntityCheckerInterface + * @var EraseEntityCheckerInterface */ private $eraseCustomerChecker; /** - * @var \Opengento\Gdpr\Model\Config + * @var Config */ private $config; - /** - * @param \Magento\Backend\Block\Widget\Context $context - * @param \Magento\Framework\Registry $registry - * @param \Opengento\Gdpr\Api\EraseEntityCheckerInterface $eraseCustomerChecker - * @param \Opengento\Gdpr\Model\Config $config - */ public function __construct( Context $context, Registry $registry, @@ -47,9 +38,6 @@ public function __construct( parent::__construct($context, $registry); } - /** - * @inheritdoc - */ public function getButtonData(): array { $customerId = $this->getCustomerId(); diff --git a/Block/Adminhtml/Customer/Edit/ExportButton.php b/Block/Adminhtml/Customer/Edit/ExportButton.php index 09b4d5a..0240691 100644 --- a/Block/Adminhtml/Customer/Edit/ExportButton.php +++ b/Block/Adminhtml/Customer/Edit/ExportButton.php @@ -14,21 +14,13 @@ use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; use Opengento\Gdpr\Model\Config; -/** - * Class ExportButton - */ final class ExportButton extends GenericButton implements ButtonProviderInterface { /** - * @var \Opengento\Gdpr\Model\Config + * @var Config */ private $config; - /** - * @param \Magento\Backend\Block\Widget\Context $context - * @param \Magento\Framework\Registry $registry - * @param \Opengento\Gdpr\Model\Config $config - */ public function __construct( Context $context, Registry $registry, @@ -38,9 +30,6 @@ public function __construct( parent::__construct($context, $registry); } - /** - * @inheritdoc - */ public function getButtonData(): array { $customerId = $this->getCustomerId(); diff --git a/Block/Adminhtml/Order/Edit/EraseButton.php b/Block/Adminhtml/Order/Edit/EraseButton.php index 8c25748..08aa97f 100644 --- a/Block/Adminhtml/Order/Edit/EraseButton.php +++ b/Block/Adminhtml/Order/Edit/EraseButton.php @@ -9,24 +9,18 @@ use Magento\Backend\Block\AbstractBlock; use Magento\Backend\Block\Context; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Phrase; +use Magento\Sales\Block\Adminhtml\Order\View; use Opengento\Gdpr\Api\EraseEntityCheckerInterface; -/** - * Class EraseButton - */ final class EraseButton extends AbstractBlock { /** - * @var \Opengento\Gdpr\Api\EraseEntityCheckerInterface + * @var EraseEntityCheckerInterface */ private $eraseEntityChecker; - /** - * @param \Magento\Backend\Block\Context $context - * @param \Opengento\Gdpr\Api\EraseEntityCheckerInterface $eraseEntityChecker - * @param array $data - */ public function __construct( Context $context, EraseEntityCheckerInterface $eraseEntityChecker, @@ -43,13 +37,13 @@ public function __construct( /** * @inheritdoc - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ protected function _construct(): void { parent::_construct(); - /** @var \Magento\Sales\Block\Adminhtml\Order\View $orderView */ + /** @var View $orderView */ $orderView = $this->getLayout()->getBlock('sales_order_edit'); $orderId = (int) $orderView->getOrderId(); diff --git a/Block/Adminhtml/Order/Edit/ExportButton.php b/Block/Adminhtml/Order/Edit/ExportButton.php index 75ce175..a060375 100644 --- a/Block/Adminhtml/Order/Edit/ExportButton.php +++ b/Block/Adminhtml/Order/Edit/ExportButton.php @@ -9,22 +9,12 @@ use Magento\Backend\Block\AbstractBlock; use Magento\Backend\Block\Context; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Phrase; +use Magento\Sales\Block\Adminhtml\Order\View; -/** - * Class ExportButton - */ final class ExportButton extends AbstractBlock { - /** - * @var \Magento\Framework\AuthorizationInterface - */ - protected $_authorization; - - /** - * @param \Magento\Backend\Block\Context $context - * @param array $data - */ public function __construct( Context $context, array $data = [] @@ -39,13 +29,13 @@ public function __construct( /** * @inheritdoc - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ protected function _construct(): void { parent::_construct(); - /** @var \Magento\Sales\Block\Adminhtml\Order\View $orderView */ + /** @var View $orderView */ $orderView = $this->getLayout()->getBlock('sales_order_edit'); $orderId = (int) $orderView->getOrderId(); diff --git a/Block/Messages/PrivacyMessagePopup.php b/Block/Messages/PrivacyMessagePopup.php index 6f8941f..ba89777 100644 --- a/Block/Messages/PrivacyMessagePopup.php +++ b/Block/Messages/PrivacyMessagePopup.php @@ -15,35 +15,25 @@ use Magento\Framework\View\Element\Template\Context; use Opengento\Gdpr\Model\Config; -/** - * Class PrivacyMessagePopup - */ final class PrivacyMessagePopup extends Template { public const COOKIE_NAME = 'cookies-policy'; /** - * @var \Opengento\Gdpr\Model\Config + * @var Config */ private $config; /** - * @var \Magento\Cms\Helper\Page + * @var HelperPage */ private $helperPage; /** - * @var \Magento\Framework\Serialize\Serializer\Json + * @var Json */ private $jsonSerializer; - /** - * @param \Magento\Framework\View\Element\Template\Context $context - * @param \Opengento\Gdpr\Model\Config $config - * @param \Magento\Cms\Helper\Page $helperPage - * @param \Magento\Framework\Serialize\Serializer\Json $jsonSerializer - * @param array $data - */ public function __construct( Context $context, Config $config, @@ -57,34 +47,18 @@ public function __construct( parent::__construct($context, $data); } - /** - * @inheritdoc - */ public function getJsLayout(): string { $this->jsLayout['components']['enhanced-privacy-cookie-policy']['config'] = [ 'cookieName' => self::COOKIE_NAME, 'learnMore' => $this->helperPage->getPageUrl($this->config->getPrivacyInformationPageId()), - 'notificationText' => $this->getCookieDisclosureInformation(), + 'notificationText' => $this->getCookieDisclosureInformationHtml(), ]; return $this->jsonSerializer->serialize($this->jsLayout); } - /** - * @inheritdoc - */ - protected function _toHtml(): string - { - return $this->config->isCookieDisclosureEnabled() ? parent::_toHtml() : ''; - } - - /** - * Retrieve the cookie disclosure information html - * - * @return string - */ - private function getCookieDisclosureInformation(): string + public function getCookieDisclosureInformationHtml(): string { if (!$this->hasData('cookie_disclosure_information')) { try { @@ -101,4 +75,9 @@ private function getCookieDisclosureInformation(): string return (string) $this->_getData('cookie_disclosure_information'); } + + protected function _toHtml(): string + { + return $this->config->isCookieDisclosureEnabled() ? parent::_toHtml() : ''; + } } diff --git a/Console/Command/EraseCommand.php b/Console/Command/EraseCommand.php index f026fdd..4eedda0 100644 --- a/Console/Command/EraseCommand.php +++ b/Console/Command/EraseCommand.php @@ -18,39 +18,29 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -/** - * Class EraseCommand - */ class EraseCommand extends Command { - /**#@+ + /** * Input Variables Names */ private const INPUT_ARGUMENT_ENTITY_ID = 'entity_id'; private const INPUT_ARGUMENT_ENTITY_TYPE = 'entity_type'; - /**#@-*/ /** - * @var \Magento\Framework\App\State + * @var State */ private $appState; /** - * @var \Magento\Framework\Registry + * @var Registry */ private $registry; /** - * @var \Opengento\Gdpr\Api\EraseEntityManagementInterface + * @var EraseEntityManagementInterface */ private $eraseManagement; - /** - * @param \Magento\Framework\App\State $appState - * @param \Magento\Framework\Registry $registry - * @param \Opengento\Gdpr\Api\EraseEntityManagementInterface $eraseManagement - * @param string $name - */ public function __construct( State $appState, Registry $registry, @@ -63,9 +53,6 @@ public function __construct( parent::__construct($name); } - /** - * @inheritdoc - */ protected function configure(): void { parent::configure(); @@ -87,7 +74,7 @@ protected function configure(): void /** * @inheritdoc - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ protected function execute(InputInterface $input, OutputInterface $output): int { diff --git a/Console/Command/ExportCommand.php b/Console/Command/ExportCommand.php index f6bd183..06e0eb6 100644 --- a/Console/Command/ExportCommand.php +++ b/Console/Command/ExportCommand.php @@ -10,6 +10,7 @@ use Magento\Framework\App\Area; use Magento\Framework\App\State; use Magento\Framework\Console\Cli; +use Magento\Framework\Exception\LocalizedException; use Opengento\Gdpr\Api\ExportEntityManagementInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; @@ -17,34 +18,25 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -/** - * Class ExportCommand - */ class ExportCommand extends Command { - /**#@+ + /** * Input Variables Names */ private const INPUT_ARGUMENT_ENTITY_ID = 'entity_id'; private const INPUT_ARGUMENT_ENTITY_TYPE = 'entity_type'; private const INPUT_OPTION_FILENAME = 'filename'; - /**#@-*/ /** - * @var \Magento\Framework\App\State + * @var State */ private $appState; /** - * @var \Opengento\Gdpr\Api\ExportEntityManagementInterface + * @var ExportEntityManagementInterface */ private $exportManagement; - /** - * @param \Magento\Framework\App\State $appState - * @param \Opengento\Gdpr\Api\ExportEntityManagementInterface $exportManagement - * @param string $name - */ public function __construct( State $appState, ExportEntityManagementInterface $exportManagement, @@ -55,9 +47,6 @@ public function __construct( parent::__construct($name); } - /** - * @inheritdoc - */ protected function configure(): void { parent::configure(); @@ -86,7 +75,7 @@ protected function configure(): void /** * @inheritdoc - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ protected function execute(InputInterface $input, OutputInterface $output): int { diff --git a/Controller/AbstractAction.php b/Controller/AbstractAction.php index 09bbaca..37f5794 100644 --- a/Controller/AbstractAction.php +++ b/Controller/AbstractAction.php @@ -9,24 +9,20 @@ use Magento\Framework\App\Action\Action; use Magento\Framework\App\Action\Context; +use Magento\Framework\App\ResponseInterface; +use Magento\Framework\Controller\Result\Forward; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Controller\ResultInterface; +use Magento\Framework\Exception\NotFoundException; use Opengento\Gdpr\Model\Config; -/** - * Class AbstractAction - */ abstract class AbstractAction extends Action { /** - * @var \Opengento\Gdpr\Model\Config + * @var Config */ protected $config; - /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Opengento\Gdpr\Model\Config $config - */ public function __construct( Context $context, Config $config @@ -35,9 +31,6 @@ public function __construct( parent::__construct($context); } - /** - * @inheritdoc - */ public function execute() { if ($this->isAllowed()) { @@ -50,29 +43,19 @@ public function execute() /** * Execute action based on request and return result * - * @return \Magento\Framework\Controller\ResultInterface|\Magento\Framework\App\ResponseInterface - * @throws \Magento\Framework\Exception\NotFoundException + * @return ResultInterface|ResponseInterface + * @throws NotFoundException */ abstract protected function executeAction(); - /** - * Check if the execution of the action is allowed - * - * @return bool - */ protected function isAllowed(): bool { return $this->config->isModuleEnabled(); } - /** - * Create a result forward to 404 - * - * @return \Magento\Framework\Controller\ResultInterface - */ protected function forwardNoRoute(): ResultInterface { - /** @var \Magento\Framework\Controller\Result\Forward $resultForward */ + /** @var Forward $resultForward */ $resultForward = $this->resultFactory->create(ResultFactory::TYPE_FORWARD); return $resultForward->forward('no_route'); diff --git a/Controller/AbstractGuest.php b/Controller/AbstractGuest.php index 019a5be..f528801 100644 --- a/Controller/AbstractGuest.php +++ b/Controller/AbstractGuest.php @@ -14,27 +14,18 @@ use Magento\Sales\Controller\AbstractController\OrderLoaderInterface; use Opengento\Gdpr\Model\Config; -/** - * Class AbstractGuest - */ abstract class AbstractGuest extends AbstractAction { /** - * @var \Magento\Sales\Controller\AbstractController\OrderLoaderInterface + * @var OrderLoaderInterface */ protected $orderLoader; /** - * @var \Magento\Framework\Registry + * @var Registry */ protected $registry; - /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Opengento\Gdpr\Model\Config $config - * @param \Magento\Sales\Controller\AbstractController\OrderLoaderInterface $orderLoader - * @param \Magento\Framework\Registry $registry - */ public function __construct( Context $context, Config $config, @@ -46,9 +37,6 @@ public function __construct( parent::__construct($context, $config); } - /** - * @inheritdoc - */ public function execute() { if (($result = $this->orderLoader->load($this->getRequest())) instanceof ResultInterface) { @@ -61,11 +49,6 @@ public function execute() return parent::execute(); } - /** - * Retrieve the current guest order ID - * - * @return int - */ protected function retrieveOrderId(): int { $order = $this->registry->registry('current_order'); diff --git a/Controller/AbstractPrivacy.php b/Controller/AbstractPrivacy.php index 855a6e4..d2d5f31 100644 --- a/Controller/AbstractPrivacy.php +++ b/Controller/AbstractPrivacy.php @@ -7,9 +7,6 @@ namespace Opengento\Gdpr\Controller; -/** - * Controller AbstractPrivacy - */ abstract class AbstractPrivacy extends AbstractAction { } diff --git a/Controller/Adminhtml/AbstractAction.php b/Controller/Adminhtml/AbstractAction.php index 42e1015..9d9ec12 100644 --- a/Controller/Adminhtml/AbstractAction.php +++ b/Controller/Adminhtml/AbstractAction.php @@ -9,24 +9,20 @@ use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; +use Magento\Backend\Model\View\Result\Forward; +use Magento\Framework\App\ResponseInterface; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Controller\ResultInterface; +use Magento\Framework\Exception\NotFoundException; use Opengento\Gdpr\Model\Config; -/** - * Class AbstractAction - */ abstract class AbstractAction extends Action { /** - * @var \Opengento\Gdpr\Model\Config + * @var Config */ protected $config; - /** - * @param \Magento\Backend\App\Action\Context $context - * @param \Opengento\Gdpr\Model\Config $config - */ public function __construct( Context $context, Config $config @@ -35,9 +31,6 @@ public function __construct( parent::__construct($context); } - /** - * @inheritdoc - */ public function execute() { if ($this->isAllowed()) { @@ -50,29 +43,19 @@ public function execute() /** * Execute action based on request and return result * - * @return \Magento\Framework\Controller\ResultInterface|\Magento\Framework\App\ResponseInterface - * @throws \Magento\Framework\Exception\NotFoundException + * @return ResultInterface|ResponseInterface + * @throws NotFoundException */ abstract protected function executeAction(); - /** - * Check if the execution of the action is allowed - * - * @return bool - */ protected function isAllowed(): bool { return $this->config->isModuleEnabled(); } - /** - * Create a result forward to 404 - * - * @return \Magento\Framework\Controller\ResultInterface - */ protected function forwardNoRoute(): ResultInterface { - /** @var \Magento\Backend\Model\View\Result\Forward $resultForward */ + /** @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 1e60275..3e3a3c0 100644 --- a/Controller/Adminhtml/Guest/Erase.php +++ b/Controller/Adminhtml/Guest/Erase.php @@ -8,6 +8,7 @@ namespace Opengento\Gdpr\Controller\Adminhtml\Guest; use Magento\Backend\App\Action\Context; +use Magento\Backend\Model\View\Result\Redirect; use Magento\Framework\App\Action\HttpPostActionInterface; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Exception\LocalizedException; @@ -16,23 +17,15 @@ use Opengento\Gdpr\Controller\Adminhtml\AbstractAction; use Opengento\Gdpr\Model\Config; -/** - * Class Erase - */ class Erase extends AbstractAction implements HttpPostActionInterface { public const ADMIN_RESOURCE = 'Opengento_Gdpr::order_erase'; /** - * @var \Opengento\Gdpr\Api\EraseEntityManagementInterface + * @var EraseEntityManagementInterface */ private $eraseManagement; - /** - * @param \Magento\Backend\App\Action\Context $context - * @param \Opengento\Gdpr\Model\Config $config - * @param \Opengento\Gdpr\Api\EraseEntityManagementInterface $eraseManagement - */ public function __construct( Context $context, Config $config, @@ -42,9 +35,6 @@ public function __construct( parent::__construct($context, $config); } - /** - * @inheritdoc - */ protected function executeAction() { try { @@ -58,7 +48,7 @@ protected function executeAction() $this->messageManager->addExceptionMessage($e, new Phrase('An error occurred on the server.')); } - /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('sales/order/index'); diff --git a/Controller/Adminhtml/Guest/Export.php b/Controller/Adminhtml/Guest/Export.php index 3949425..b6c134d 100644 --- a/Controller/Adminhtml/Guest/Export.php +++ b/Controller/Adminhtml/Guest/Export.php @@ -8,6 +8,7 @@ namespace Opengento\Gdpr\Controller\Adminhtml\Guest; use Magento\Backend\App\Action\Context; +use Magento\Backend\Model\View\Result\Redirect; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\Response\Http\FileFactory; use Magento\Framework\Controller\ResultFactory; @@ -17,15 +18,12 @@ use Opengento\Gdpr\Model\Config; use Opengento\Gdpr\Model\Export\ExportEntityData; -/** - * Class Export - */ class Export extends AbstractAction { public const ADMIN_RESOURCE = 'Opengento_Gdpr::order_export'; /** - * @var \Magento\Framework\App\Response\Http\FileFactory + * @var FileFactory */ private $fileFactory; @@ -34,12 +32,6 @@ class Export extends AbstractAction */ private $exportEntityData; - /** - * @param Context $context - * @param Config $config - * @param FileFactory $fileFactory - * @param ExportEntityData $exportEntityData - */ public function __construct( Context $context, Config $config, @@ -51,9 +43,6 @@ public function __construct( parent::__construct($context, $config); } - /** - * @inheritdoc - */ protected function executeAction() { try { @@ -74,7 +63,7 @@ protected function executeAction() $this->messageManager->addExceptionMessage($e, new Phrase('An error occurred on the server.')); } - /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setRefererOrBaseUrl(); diff --git a/Controller/Adminhtml/Privacy/Erase.php b/Controller/Adminhtml/Privacy/Erase.php index 92ff104..7a27d9f 100644 --- a/Controller/Adminhtml/Privacy/Erase.php +++ b/Controller/Adminhtml/Privacy/Erase.php @@ -8,6 +8,7 @@ namespace Opengento\Gdpr\Controller\Adminhtml\Privacy; use Magento\Backend\App\Action\Context; +use Magento\Backend\Model\View\Result\Redirect; use Magento\Framework\App\Action\HttpPostActionInterface; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Exception\LocalizedException; @@ -16,23 +17,15 @@ use Opengento\Gdpr\Controller\Adminhtml\AbstractAction; use Opengento\Gdpr\Model\Config; -/** - * Class Erase - */ class Erase extends AbstractAction implements HttpPostActionInterface { public const ADMIN_RESOURCE = 'Opengento_Gdpr::customer_erase'; /** - * @var \Opengento\Gdpr\Api\EraseEntityManagementInterface + * @var EraseEntityManagementInterface */ private $eraseManagement; - /** - * @param \Magento\Backend\App\Action\Context $context - * @param \Opengento\Gdpr\Model\Config $config - * @param \Opengento\Gdpr\Api\EraseEntityManagementInterface $eraseManagement - */ public function __construct( Context $context, Config $config, @@ -42,9 +35,6 @@ public function __construct( parent::__construct($context, $config); } - /** - * @inheritdoc - */ protected function executeAction() { try { @@ -58,7 +48,7 @@ protected function executeAction() $this->messageManager->addExceptionMessage($e, new Phrase('An error occurred on the server.')); } - /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('customer/index'); diff --git a/Controller/Adminhtml/Privacy/Export.php b/Controller/Adminhtml/Privacy/Export.php index 42164ea..71b9855 100644 --- a/Controller/Adminhtml/Privacy/Export.php +++ b/Controller/Adminhtml/Privacy/Export.php @@ -8,6 +8,7 @@ namespace Opengento\Gdpr\Controller\Adminhtml\Privacy; use Magento\Backend\App\Action\Context; +use Magento\Backend\Model\View\Result\Redirect; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\Response\Http\FileFactory; use Magento\Framework\Controller\ResultFactory; @@ -17,15 +18,12 @@ use Opengento\Gdpr\Model\Config; use Opengento\Gdpr\Model\Export\ExportEntityData; -/** - * Class Export - */ class Export extends AbstractAction { public const ADMIN_RESOURCE = 'Opengento_Gdpr::customer_export'; /** - * @var \Magento\Framework\App\Response\Http\FileFactory + * @var FileFactory */ private $fileFactory; @@ -34,12 +32,6 @@ class Export extends AbstractAction */ private $exportEntityData; - /** - * @param Context $context - * @param Config $config - * @param FileFactory $fileFactory - * @param ExportEntityData $exportEntityData - */ public function __construct( Context $context, Config $config, @@ -51,9 +43,6 @@ public function __construct( parent::__construct($context, $config); } - /** - * @inheritdoc - */ protected function executeAction() { try { @@ -74,7 +63,7 @@ protected function executeAction() $this->messageManager->addExceptionMessage($e, new Phrase('An error occurred on the server.')); } - /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setRefererOrBaseUrl(); diff --git a/Controller/Adminhtml/Privacy/MassErase.php b/Controller/Adminhtml/Privacy/MassErase.php index 535d11c..953788a 100644 --- a/Controller/Adminhtml/Privacy/MassErase.php +++ b/Controller/Adminhtml/Privacy/MassErase.php @@ -8,6 +8,7 @@ namespace Opengento\Gdpr\Controller\Adminhtml\Privacy; use Magento\Backend\App\Action\Context; +use Magento\Backend\Model\View\Result\Redirect; use Magento\Customer\Controller\Adminhtml\Index\AbstractMassAction; use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory; use Magento\Eav\Model\Entity\Collection\AbstractCollection; @@ -17,24 +18,15 @@ use Magento\Ui\Component\MassAction\Filter; use Opengento\Gdpr\Api\EraseEntityManagementInterface; -/** - * Class MassErase - */ class MassErase extends AbstractMassAction { public const ADMIN_RESOURCE = 'Opengento_Gdpr::customer_erase'; /** - * @var \Opengento\Gdpr\Api\EraseEntityManagementInterface + * @var EraseEntityManagementInterface */ private $eraseManagement; - /** - * @param \Magento\Backend\App\Action\Context $context - * @param \Magento\Ui\Component\MassAction\Filter $filter - * @param \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory $collectionFactory - * @param \Opengento\Gdpr\Api\EraseEntityManagementInterface $eraseManagement - */ public function __construct( Context $context, Filter $filter, @@ -45,9 +37,6 @@ public function __construct( parent::__construct($context, $filter, $collectionFactory); } - /** - * @inheritdoc - */ protected function massAction(AbstractCollection $collection) { $customerErased = 0; @@ -72,7 +61,7 @@ protected function massAction(AbstractCollection $collection) ); } - /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('customer/index/index'); diff --git a/Controller/Adminhtml/Privacy/MassExport.php b/Controller/Adminhtml/Privacy/MassExport.php index 5cafc7f..11323aa 100644 --- a/Controller/Adminhtml/Privacy/MassExport.php +++ b/Controller/Adminhtml/Privacy/MassExport.php @@ -8,6 +8,7 @@ namespace Opengento\Gdpr\Controller\Adminhtml\Privacy; use Magento\Backend\App\Action\Context; +use Magento\Backend\Model\View\Result\Redirect; use Magento\Customer\Controller\Adminhtml\Index\AbstractMassAction; use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory; use Magento\Eav\Model\Entity\Collection\AbstractCollection; @@ -20,20 +21,17 @@ use Opengento\Gdpr\Model\Archive\MoveToArchive; use Opengento\Gdpr\Model\Export\ExportEntityData; -/** - * Class MassExport - */ class MassExport extends AbstractMassAction { public const ADMIN_RESOURCE = 'Opengento_Gdpr::customer_export'; /** - * @var \Magento\Framework\App\Response\Http\FileFactory + * @var FileFactory */ private $fileFactory; /** - * @var \Opengento\Gdpr\Model\Archive\MoveToArchive + * @var MoveToArchive */ private $moveToArchive; @@ -42,14 +40,6 @@ class MassExport extends AbstractMassAction */ private $exportEntityData; - /** - * @param Context $context - * @param Filter $filter - * @param CollectionFactory $collectionFactory - * @param FileFactory $fileFactory - * @param MoveToArchive $moveToArchive - * @param ExportEntityData $exportEntityData - */ public function __construct( Context $context, Filter $filter, @@ -64,9 +54,6 @@ public function __construct( parent::__construct($context, $filter, $collectionFactory); } - /** - * @inheritdoc - */ protected function massAction(AbstractCollection $collection) { $archiveFileName = 'customers_privacy_data.zip'; @@ -96,7 +83,7 @@ protected function massAction(AbstractCollection $collection) $this->messageManager->addExceptionMessage($e, new Phrase('An error occurred on the server.')); } - /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setPath('customer/index/index'); diff --git a/Controller/Guest/Download.php b/Controller/Guest/Download.php index 6352f21..22a7f3d 100755 --- a/Controller/Guest/Download.php +++ b/Controller/Guest/Download.php @@ -10,23 +10,22 @@ use Magento\Framework\App\Action\Context; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\Response\Http\FileFactory; +use Magento\Framework\Controller\Result\Redirect; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Phrase; use Magento\Framework\Registry; +use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Controller\AbstractController\OrderLoaderInterface; use Opengento\Gdpr\Api\ExportEntityRepositoryInterface; use Opengento\Gdpr\Controller\AbstractGuest; use Opengento\Gdpr\Model\Config; -/** - * Class Download Export - */ class Download extends AbstractGuest { /** - * @var \Magento\Framework\App\Response\Http\FileFactory + * @var FileFactory */ private $fileFactory; @@ -35,14 +34,6 @@ class Download extends AbstractGuest */ private $exportRepository; - /** - * @param Context $context - * @param Config $config - * @param FileFactory $fileFactory - * @param ExportEntityRepositoryInterface $exportRepository - * @param OrderLoaderInterface $orderLoader - * @param Registry $registry - */ public function __construct( Context $context, Config $config, @@ -56,21 +47,15 @@ public function __construct( parent::__construct($context, $config, $orderLoader, $registry); } - /** - * @inheritdoc - */ protected function isAllowed(): bool { return parent::isAllowed() && $this->config->isExportEnabled(); } - /** - * @inheritdoc - */ protected function executeAction() { try { - /** @var \Magento\Sales\Api\Data\OrderInterface $order */ + /** @var OrderInterface $order */ $order = $this->registry->registry('current_order'); return $this->fileFactory->create( @@ -92,7 +77,7 @@ protected function executeAction() $this->messageManager->addExceptionMessage($e, new Phrase('Something went wrong, please try again later!')); } - /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ + /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setRefererOrBaseUrl(); diff --git a/Controller/Guest/Erase.php b/Controller/Guest/Erase.php index d15e3f5..ecb275c 100644 --- a/Controller/Guest/Erase.php +++ b/Controller/Guest/Erase.php @@ -8,6 +8,7 @@ namespace Opengento\Gdpr\Controller\Guest; use Magento\Framework\App\Action\Context; +use Magento\Framework\Controller\Result\Redirect; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Phrase; @@ -17,23 +18,13 @@ use Opengento\Gdpr\Controller\AbstractGuest; use Opengento\Gdpr\Model\Config; -/** - * Class Erase - */ class Erase extends AbstractGuest { /** - * @var \Opengento\Gdpr\Api\EraseEntityManagementInterface + * @var EraseEntityManagementInterface */ private $eraseManagement; - /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Opengento\Gdpr\Model\Config $config - * @param \Magento\Sales\Controller\AbstractController\OrderLoaderInterface $orderLoader - * @param \Opengento\Gdpr\Api\EraseEntityManagementInterface $eraseManagement - * @param \Magento\Framework\Registry $registry - */ public function __construct( Context $context, Config $config, @@ -45,20 +36,14 @@ public function __construct( parent::__construct($context, $config, $orderLoader, $registry); } - /** - * @inheritdoc - */ protected function isAllowed(): bool { return parent::isAllowed() && $this->config->isErasureEnabled(); } - /** - * @inheritdoc - */ protected function executeAction() { - /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ + /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $resultRedirect->setRefererOrBaseUrl(); diff --git a/Controller/Guest/Export.php b/Controller/Guest/Export.php index eb2dcc9..03d6c93 100755 --- a/Controller/Guest/Export.php +++ b/Controller/Guest/Export.php @@ -8,6 +8,7 @@ namespace Opengento\Gdpr\Controller\Guest; use Magento\Framework\App\Action\Context; +use Magento\Framework\Controller\Result\Redirect; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Exception\AlreadyExistsException; use Magento\Framework\Exception\LocalizedException; @@ -18,23 +19,13 @@ use Opengento\Gdpr\Controller\AbstractGuest; use Opengento\Gdpr\Model\Config; -/** - * Class Export - */ class Export extends AbstractGuest { /** - * @var \Opengento\Gdpr\Api\ExportEntityManagementInterface + * @var ExportEntityManagementInterface */ private $exportManagement; - /** - * @param Context $context - * @param Config $config - * @param ExportEntityManagementInterface $exportManagement - * @param OrderLoaderInterface $orderLoader - * @param Registry $registry - */ public function __construct( Context $context, Config $config, @@ -46,17 +37,11 @@ public function __construct( parent::__construct($context, $config, $orderLoader, $registry); } - /** - * @inheritdoc - */ protected function isAllowed(): bool { return parent::isAllowed() && $this->config->isExportEnabled(); } - /** - * @inheritdoc - */ protected function executeAction() { try { @@ -70,7 +55,7 @@ protected function executeAction() $this->messageManager->addExceptionMessage($e, new Phrase('Something went wrong, please try again later!')); } - /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ + /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setRefererOrBaseUrl(); diff --git a/Controller/Guest/UndoErase.php b/Controller/Guest/UndoErase.php index 5da5d00..b43359c 100644 --- a/Controller/Guest/UndoErase.php +++ b/Controller/Guest/UndoErase.php @@ -8,6 +8,7 @@ namespace Opengento\Gdpr\Controller\Guest; use Magento\Framework\App\Action\Context; +use Magento\Framework\Controller\Result\Redirect; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Phrase; @@ -17,23 +18,13 @@ use Opengento\Gdpr\Controller\AbstractGuest; use Opengento\Gdpr\Model\Config; -/** - * Class UndoErase - */ class UndoErase extends AbstractGuest { /** - * @var \Opengento\Gdpr\Api\EraseEntityManagementInterface + * @var EraseEntityManagementInterface */ private $eraseManagement; - /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Opengento\Gdpr\Model\Config $config - * @param \Magento\Sales\Controller\AbstractController\OrderLoaderInterface $orderLoader - * @param \Opengento\Gdpr\Api\EraseEntityManagementInterface $eraseManagement - * @param \Magento\Framework\Registry $registry - */ public function __construct( Context $context, Config $config, @@ -45,20 +36,14 @@ public function __construct( parent::__construct($context, $config, $orderLoader, $registry); } - /** - * @inheritdoc - */ protected function isAllowed(): bool { return parent::isAllowed() && $this->config->isErasureEnabled(); } - /** - * @inheritdoc - */ protected function executeAction() { - /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ + /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $resultRedirect->setRefererOrBaseUrl(); diff --git a/Controller/Privacy/Download.php b/Controller/Privacy/Download.php index 5a5e924..d430028 100755 --- a/Controller/Privacy/Download.php +++ b/Controller/Privacy/Download.php @@ -11,6 +11,7 @@ use Magento\Framework\App\Action\Context; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\Response\Http\FileFactory; +use Magento\Framework\Controller\Result\Redirect; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Exception\NoSuchEntityException; @@ -19,13 +20,10 @@ use Opengento\Gdpr\Controller\AbstractPrivacy; use Opengento\Gdpr\Model\Config; -/** - * Action Download Export - */ class Download extends AbstractPrivacy { /** - * @var \Magento\Framework\App\Response\Http\FileFactory + * @var FileFactory */ private $fileFactory; @@ -35,17 +33,10 @@ class Download extends AbstractPrivacy private $exportRepository; /** - * @var \Magento\Customer\Model\Session + * @var Session */ private $customerSession; - /** - * @param Context $context - * @param Config $config - * @param FileFactory $fileFactory - * @param ExportEntityRepositoryInterface $exportRepository - * @param Session $customerSession - */ public function __construct( Context $context, Config $config, @@ -59,17 +50,11 @@ public function __construct( parent::__construct($context, $config); } - /** - * @inheritdoc - */ protected function isAllowed(): bool { return parent::isAllowed() && $this->config->isExportEnabled(); } - /** - * @inheritdoc - */ protected function executeAction() { try { @@ -94,7 +79,7 @@ protected function executeAction() $this->messageManager->addExceptionMessage($e, new Phrase('Something went wrong, please try again later!')); } - /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ + /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setRefererOrBaseUrl(); diff --git a/Controller/Privacy/Erase.php b/Controller/Privacy/Erase.php index 3e2ef21..c5d8492 100755 --- a/Controller/Privacy/Erase.php +++ b/Controller/Privacy/Erase.php @@ -9,33 +9,25 @@ use Magento\Customer\Model\Session; use Magento\Framework\App\Action\Context; +use Magento\Framework\Controller\Result\Redirect; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Phrase; use Opengento\Gdpr\Api\EraseEntityCheckerInterface; use Opengento\Gdpr\Controller\AbstractPrivacy; use Opengento\Gdpr\Model\Config; -/** - * Action Index Erase - */ class Erase extends AbstractPrivacy { /** - * @var \Magento\Customer\Model\Session + * @var Session */ private $session; /** - * @var \Opengento\Gdpr\Api\EraseEntityCheckerInterface + * @var EraseEntityCheckerInterface */ private $eraseCustomerChecker; - /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Opengento\Gdpr\Model\Config $config - * @param \Magento\Customer\Model\Session $session - * @param \Opengento\Gdpr\Api\EraseEntityCheckerInterface $eraseCustomerChecker - */ public function __construct( Context $context, Config $config, @@ -47,22 +39,16 @@ public function __construct( parent::__construct($context, $config); } - /** - * @inheritdoc - */ protected function isAllowed(): bool { return parent::isAllowed() && $this->config->isErasureEnabled(); } - /** - * @inheritdoc - */ protected function executeAction() { if ($this->eraseCustomerChecker->exists((int) $this->session->getCustomerId(), 'customer')) { $this->messageManager->addErrorMessage(new Phrase('Your account is already being removed.')); - /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ + /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $resultRedirect->setRefererOrBaseUrl(); diff --git a/Controller/Privacy/ErasePost.php b/Controller/Privacy/ErasePost.php index 23ecc14..5685b5b 100755 --- a/Controller/Privacy/ErasePost.php +++ b/Controller/Privacy/ErasePost.php @@ -10,6 +10,7 @@ use Magento\Customer\Model\AuthenticationInterface; use Magento\Customer\Model\Session; use Magento\Framework\App\Action\Context; +use Magento\Framework\Controller\Result\Redirect; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Data\Form\FormKey\Validator; use Magento\Framework\Exception\InvalidEmailOrPasswordException; @@ -20,39 +21,28 @@ use Opengento\Gdpr\Controller\AbstractPrivacy; use Opengento\Gdpr\Model\Config; -/** - * Class ErasePost - */ class ErasePost extends AbstractPrivacy { /** - * @var \Magento\Framework\Data\Form\FormKey\Validator + * @var Validator */ private $formKeyValidator; /** - * @var \Magento\Customer\Model\AuthenticationInterface + * @var AuthenticationInterface */ private $authentication; /** - * @var \Magento\Customer\Model\Session + * @var Session */ private $session; /** - * @var \Opengento\Gdpr\Api\EraseEntityManagementInterface + * @var EraseEntityManagementInterface */ private $eraseManagement; - /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Opengento\Gdpr\Model\Config $config - * @param \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator - * @param \Magento\Customer\Model\AuthenticationInterface $authentication - * @param \Magento\Customer\Model\Session $session - * @param \Opengento\Gdpr\Api\EraseEntityManagementInterface $eraseManagement - */ public function __construct( Context $context, Config $config, @@ -68,20 +58,14 @@ public function __construct( parent::__construct($context, $config); } - /** - * @inheritdoc - */ protected function isAllowed(): bool { return parent::isAllowed() && $this->config->isErasureEnabled(); } - /** - * @inheritdoc - */ protected function executeAction() { - /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ + /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $resultRedirect->setPath('customer/privacy/settings'); diff --git a/Controller/Privacy/Export.php b/Controller/Privacy/Export.php index f9653eb..4142222 100755 --- a/Controller/Privacy/Export.php +++ b/Controller/Privacy/Export.php @@ -9,6 +9,7 @@ use Magento\Customer\Model\Session; use Magento\Framework\App\Action\Context; +use Magento\Framework\Controller\Result\Redirect; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Exception\AlreadyExistsException; use Magento\Framework\Exception\LocalizedException; @@ -17,27 +18,18 @@ use Opengento\Gdpr\Controller\AbstractPrivacy; use Opengento\Gdpr\Model\Config; -/** - * Action Prepare Export - */ class Export extends AbstractPrivacy { /** - * @var \Opengento\Gdpr\Api\ExportEntityManagementInterface + * @var ExportEntityManagementInterface */ private $exportManagement; /** - * @var \Magento\Customer\Model\Session + * @var Session */ private $customerSession; - /** - * @param Context $context - * @param Config $config - * @param ExportEntityManagementInterface $exportManagement - * @param Session $customerSession - */ public function __construct( Context $context, Config $config, @@ -49,17 +41,11 @@ public function __construct( parent::__construct($context, $config); } - /** - * @inheritdoc - */ protected function isAllowed(): bool { return parent::isAllowed() && $this->config->isExportEnabled(); } - /** - * @inheritdoc - */ protected function executeAction() { try { @@ -73,7 +59,7 @@ protected function executeAction() $this->messageManager->addExceptionMessage($e, new Phrase('Something went wrong, please try again later!')); } - /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ + /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setRefererOrBaseUrl(); diff --git a/Controller/Privacy/Settings.php b/Controller/Privacy/Settings.php index 7716e78..9246aad 100755 --- a/Controller/Privacy/Settings.php +++ b/Controller/Privacy/Settings.php @@ -10,14 +10,8 @@ use Magento\Framework\Controller\ResultFactory; use Opengento\Gdpr\Controller\AbstractPrivacy; -/** - * Action Index Settings - */ class Settings extends AbstractPrivacy { - /** - * @inheritdoc - */ protected function executeAction() { return $this->resultFactory->create(ResultFactory::TYPE_PAGE); diff --git a/Controller/Privacy/UndoErase.php b/Controller/Privacy/UndoErase.php index 7ce2993..e7f1f40 100755 --- a/Controller/Privacy/UndoErase.php +++ b/Controller/Privacy/UndoErase.php @@ -9,6 +9,7 @@ use Magento\Customer\Model\Session; use Magento\Framework\App\Action\Context; +use Magento\Framework\Controller\Result\Redirect; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Phrase; @@ -16,27 +17,18 @@ use Opengento\Gdpr\Controller\AbstractPrivacy; use Opengento\Gdpr\Model\Config; -/** - * Action Undo Erase - */ class UndoErase extends AbstractPrivacy { /** - * @var \Magento\Customer\Model\Session + * @var Session */ private $session; /** - * @var \Opengento\Gdpr\Api\EraseEntityManagementInterface + * @var EraseEntityManagementInterface */ private $eraseManagement; - /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Opengento\Gdpr\Model\Config $config - * @param \Magento\Customer\Model\Session $session - * @param \Opengento\Gdpr\Api\EraseEntityManagementInterface $eraseManagement - */ public function __construct( Context $context, Config $config, @@ -48,20 +40,14 @@ public function __construct( parent::__construct($context, $config); } - /** - * @inheritdoc - */ protected function isAllowed(): bool { return parent::isAllowed() && $this->config->isErasureEnabled(); } - /** - * @inheritdoc - */ protected function executeAction() { - /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ + /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); try { diff --git a/Cron/EraseEntity.php b/Cron/EraseEntity.php index 8f18686..a734077 100755 --- a/Cron/EraseEntity.php +++ b/Cron/EraseEntity.php @@ -18,55 +18,43 @@ use Opengento\Gdpr\Model\Config; use Psr\Log\LoggerInterface; -/** - * Class EraseEntity - */ final class EraseEntity { /** - * @var \Psr\Log\LoggerInterface + * @var LoggerInterface */ private $logger; /** - * @var \Opengento\Gdpr\Model\Config + * @var Config */ private $config; /** - * @var \Magento\Framework\Registry + * @var Registry */ private $registry; /** - * @var \Opengento\Gdpr\Api\EraseEntityManagementInterface + * @var EraseEntityManagementInterface */ private $eraseManagement; /** - * @var \Opengento\Gdpr\Api\EraseEntityRepositoryInterface + * @var EraseEntityRepositoryInterface */ private $eraseEntityRepository; /** - * @var \Magento\Framework\Api\SearchCriteriaBuilder + * @var SearchCriteriaBuilder */ private $searchCriteriaBuilder; /** - * @var \Magento\Framework\Stdlib\DateTime\DateTime + * @var DateTime */ private $dateTime; - /** - * @param \Psr\Log\LoggerInterface $logger - * @param \Opengento\Gdpr\Model\Config $config - * @param \Magento\Framework\Registry $registry - * @param \Opengento\Gdpr\Api\EraseEntityManagementInterface $eraseManagement - * @param \Opengento\Gdpr\Api\EraseEntityRepositoryInterface $eraseEntityRepository - * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder - * @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime - */ public function __construct( LoggerInterface $logger, Config $config, @@ -87,8 +75,6 @@ public function __construct( /** * Process erase of all scheduled entities - * - * @return void */ public function execute(): void { @@ -96,7 +82,7 @@ public function execute(): void $oldValue = $this->registry->registry('isSecureArea'); $this->registry->register('isSecureArea', true, true); - /** @var \Opengento\Gdpr\Api\Data\EraseEntityInterface $eraseEntity */ + /** @var EraseEntityInterface $eraseEntity */ foreach ($this->retrieveEraseEntityList()->getItems() as $eraseEntity) { try { // todo disable individual check: use mass validator @@ -110,11 +96,6 @@ public function execute(): void } } - /** - * Retrieve erase entity scheduler list - * - * @return \Magento\Framework\Api\SearchResultsInterface - */ private function retrieveEraseEntityList(): SearchResultsInterface { $this->searchCriteriaBuilder->addFilter( diff --git a/Cron/EraseEntityScheduler.php b/Cron/EraseEntityScheduler.php index 9c04b0b..fd35ef0 100644 --- a/Cron/EraseEntityScheduler.php +++ b/Cron/EraseEntityScheduler.php @@ -12,28 +12,25 @@ use Opengento\Gdpr\Model\Erase\EraseEntityScheduler as EraseEntitySchedulerService; use Psr\Log\LoggerInterface; -/** - * Class EraseEntityScheduler - */ final class EraseEntityScheduler { /** - * @var \Psr\Log\LoggerInterface + * @var LoggerInterface */ private $logger; /** - * @var \Opengento\Gdpr\Model\Config + * @var Config */ private $config; /** - * @var \Opengento\Gdpr\Model\Erase\EraseEntityScheduler + * @var EraseEntitySchedulerService */ private $eraseEntityScheduler; /** - * @var \Magento\Framework\Api\FilterBuilder + * @var FilterBuilder */ private $filterBuilder; @@ -44,9 +41,9 @@ final class EraseEntityScheduler /** * @param \Psr\Log\LoggerInterface $logger - * @param \Opengento\Gdpr\Model\Config $config - * @param \Opengento\Gdpr\Model\Erase\EraseEntityScheduler $eraseEntityScheduler - * @param \Magento\Framework\Api\FilterBuilder $filterBuilder + * @param Config $config + * @param EraseEntitySchedulerService $eraseEntityScheduler + * @param FilterBuilder $filterBuilder * @param string[] $entityTypes */ public function __construct( @@ -65,8 +62,6 @@ public function __construct( /** * Schedule entities to erase - * - * @return void */ public function execute(): void { diff --git a/Cron/ExportEntity.php b/Cron/ExportEntity.php index 73aae14..c145c4e 100644 --- a/Cron/ExportEntity.php +++ b/Cron/ExportEntity.php @@ -14,9 +14,6 @@ use Opengento\Gdpr\Model\Config; use Psr\Log\LoggerInterface; -/** - * Class ExportEntity - */ final class ExportEntity { /** @@ -44,13 +41,6 @@ final class ExportEntity */ private $searchCriteriaBuilder; - /** - * @param LoggerInterface $logger - * @param Config $config - * @param ExportEntityRepositoryInterface $exportEntityRepository - * @param ExportEntityManagementInterface $exportEntityManagement - * @param SearchCriteriaBuilder $searchCriteriaBuilder - */ public function __construct( LoggerInterface $logger, Config $config, diff --git a/Cron/ExportEntityExpired.php b/Cron/ExportEntityExpired.php index b9f9a7d..716a29b 100644 --- a/Cron/ExportEntityExpired.php +++ b/Cron/ExportEntityExpired.php @@ -14,9 +14,6 @@ use Opengento\Gdpr\Model\Config; use Psr\Log\LoggerInterface; -/** - * Class ExportEntityExpired - */ final class ExportEntityExpired { /** @@ -39,12 +36,6 @@ final class ExportEntityExpired */ private $searchCriteriaBuilder; - /** - * @param LoggerInterface $logger - * @param Config $config - * @param ExportEntityRepositoryInterface $exportEntityRepository - * @param SearchCriteriaBuilder $searchCriteriaBuilder - */ public function __construct( LoggerInterface $logger, Config $config, diff --git a/Model/Archive/MoveToArchive.php b/Model/Archive/MoveToArchive.php index 8cf9a3b..27c170d 100644 --- a/Model/Archive/MoveToArchive.php +++ b/Model/Archive/MoveToArchive.php @@ -9,29 +9,23 @@ use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\Archive\ArchiveInterface; +use Magento\Framework\Exception\FileSystemException; use Magento\Framework\Exception\NotFoundException; use Magento\Framework\Filesystem; use Magento\Framework\Phrase; -/** - * Class MoveToArchive - */ final class MoveToArchive { /** - * @var \Magento\Framework\Archive\ArchiveInterface + * @var ArchiveInterface */ private $archive; /** - * @var \Magento\Framework\Filesystem + * @var Filesystem */ private $filesystem; - /** - * @param \Magento\Framework\Archive\ArchiveInterface $archive - * @param \Magento\Framework\Filesystem $filesystem - */ public function __construct( ArchiveInterface $archive, Filesystem $filesystem @@ -41,13 +35,11 @@ public function __construct( } /** - * Pack the source - * * @param string $source * @param string $destination * @return string - * @throws \Magento\Framework\Exception\FileSystemException - * @throws \Magento\Framework\Exception\NotFoundException + * @throws FileSystemException + * @throws NotFoundException */ public function prepareArchive(string $source, string $destination): string { diff --git a/Model/Archive/Zip.php b/Model/Archive/Zip.php index 6ae2d06..9e3ba2d 100644 --- a/Model/Archive/Zip.php +++ b/Model/Archive/Zip.php @@ -18,19 +18,15 @@ final class Zip implements ArchiveInterface { /** - * @var \Magento\Framework\Filesystem + * @var Filesystem */ private $filesystem; /** - * @var \Magento\Framework\Archive\Zip + * @var ArchiveZip */ private $zip; - /** - * @param \Magento\Framework\Filesystem $filesystem - * @param \Magento\Framework\Archive\Zip $zip - */ public function __construct( Filesystem $filesystem, ArchiveZip $zip @@ -39,9 +35,6 @@ public function __construct( $this->zip = $zip; } - /** - * @inheritdoc - */ public function pack($source, $destination): string { $directoryRead = $this->filesystem->getDirectoryReadByPath($source); @@ -54,9 +47,6 @@ public function pack($source, $destination): string return $destination; } - /** - * @inheritdoc - */ public function unpack($source, $destination): string { return $this->zip->unpack($source, $destination); diff --git a/Model/Config.php b/Model/Config.php index 12014cf..4d3e02c 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -11,11 +11,11 @@ use Magento\Store\Model\ScopeInterface; /** - * Class Config + * @todo split config */ final class Config { - /**#@+ + /** * Scope Config: Data Settings Paths */ public const CONFIG_PATH_GENERAL_ENABLED = 'gdpr/general/enabled'; @@ -36,27 +36,18 @@ final class Config public const CONFIG_PATH_EXPORT_RENDERERS = 'gdpr/export/renderers'; public const CONFIG_PATH_COOKIE_DISCLOSURE_ENABLED = 'gdpr/cookie/enabled'; public const CONFIG_PATH_COOKIE_INFORMATION_BLOCK = 'gdpr/cookie/block_id'; - /**#@-*/ /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface + * @var ScopeConfigInterface */ private $scopeConfig; - /** - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - */ public function __construct( ScopeConfigInterface $scopeConfig ) { $this->scopeConfig = $scopeConfig; } - /** - * Check if the current module is enabled - * - * @return bool - */ public function isModuleEnabled(): bool { return $this->scopeConfig->isSetFlag( @@ -65,11 +56,6 @@ public function isModuleEnabled(): bool ); } - /** - * Retrieve the privacy information page ID - * - * @return string - */ public function getPrivacyInformationPageId(): string { return (string) $this->scopeConfig->getValue( @@ -78,11 +64,6 @@ public function getPrivacyInformationPageId(): string ); } - /** - * Retrieve the privacy information block ID - * - * @return string - */ public function getPrivacyInformationBlockId(): string { return (string) $this->scopeConfig->getValue( @@ -91,11 +72,6 @@ public function getPrivacyInformationBlockId(): string ); } - /** - * Check if the erasure is enabled - * - * @return bool - */ public function isErasureEnabled(): bool { return $this->scopeConfig->isSetFlag( @@ -106,8 +82,6 @@ public function isErasureEnabled(): bool /** * Check if the customer can be removed if he has no orders - * - * @return bool */ public function isCustomerRemovedNoOrders(): bool { @@ -119,8 +93,6 @@ public function isCustomerRemovedNoOrders(): bool /** * Retrieve the erasure delay in minutes before execution - * - * @return int */ public function getErasureDelay(): int { @@ -132,8 +104,6 @@ public function getErasureDelay(): int /** * Retrieve the maximum age for the entities before the erasure - * - * @return int */ public function getErasureMaxAge(): int { @@ -145,8 +115,6 @@ public function getErasureMaxAge(): int /** * Retrieve the maximum age for the sales information before the erasure - * - * @return int */ public function getErasureSalesMaxAge(): int { @@ -157,8 +125,6 @@ public function getErasureSalesMaxAge(): int } /** - * Retrieve the allowed order states to erase - * * @return string[] */ public function getAllowedStatesToErase(): array @@ -169,11 +135,6 @@ public function getAllowedStatesToErase(): array )); } - /** - * Retrieve the erasure information block ID - * - * @return string - */ public function getErasureInformationBlockId(): string { return (string) $this->scopeConfig->getValue( @@ -182,11 +143,6 @@ public function getErasureInformationBlockId(): string ); } - /** - * Retrieve the anonymize information block ID - * - * @return string - */ public function getAnonymizeInformationBlockId(): string { return (string) $this->scopeConfig->getValue( @@ -195,11 +151,6 @@ public function getAnonymizeInformationBlockId(): string ); } - /** - * Check if the export is enabled - * - * @return bool - */ public function isExportEnabled(): bool { return $this->scopeConfig->isSetFlag( @@ -208,11 +159,6 @@ public function isExportEnabled(): bool ); } - /** - * Retrieve the export file name - * - * @return string - */ public function getExportFileName(): string { return (string) $this->scopeConfig->getValue( @@ -223,8 +169,6 @@ public function getExportFileName(): string /** * Retrieve the export file life time in minutes - * - * @return int */ public function getExportLifetime(): int { @@ -234,11 +178,6 @@ public function getExportLifetime(): int ); } - /** - * Retrieve the export information block ID - * - * @return string - */ public function getExportInformationBlockId(): string { return (string) $this->scopeConfig->getValue( @@ -247,11 +186,6 @@ public function getExportInformationBlockId(): string ); } - /** - * Retrieve the export renderer codes - * - * @return array - */ public function getExportRendererCodes(): array { return \explode(',', (string) $this->scopeConfig->getValue( @@ -260,11 +194,6 @@ public function getExportRendererCodes(): array )); } - /** - * Check if the cookie disclosure is enabled - * - * @return bool - */ public function isCookieDisclosureEnabled(): bool { return $this->scopeConfig->isSetFlag( @@ -273,11 +202,6 @@ public function isCookieDisclosureEnabled(): bool ); } - /** - * Retrieve the cookie disclosure information block ID - * - * @return string - */ public function getCookieDisclosureInformationBlockId(): string { return (string) $this->scopeConfig->getValue( diff --git a/Model/Config/Source/EraseComponents.php b/Model/Config/Source/EraseComponents.php index 7d9c50f..4e87046 100644 --- a/Model/Config/Source/EraseComponents.php +++ b/Model/Config/Source/EraseComponents.php @@ -11,13 +11,10 @@ use Magento\Framework\ObjectManager\ConfigInterface; use Magento\Framework\Phrase; -/** - * Class EraseComponents - */ final class EraseComponents implements OptionSourceInterface { /** - * @var \Magento\Framework\ObjectManager\ConfigInterface + * @var ConfigInterface */ private $objectManagerConfig; @@ -33,10 +30,6 @@ final class EraseComponents implements OptionSourceInterface */ private $options; - /** - * @param \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig - * @param string $processorResolverFactoryClassName - */ public function __construct( ConfigInterface $objectManagerConfig, string $processorResolverFactoryClassName @@ -45,9 +38,6 @@ public function __construct( $this->processorResolverFactoryClassName = $processorResolverFactoryClassName; } - /** - * @inheritdoc - */ public function toOptionArray(): array { if (!$this->options) { @@ -60,16 +50,16 @@ public function toOptionArray(): array } /** - * Retrieve the delegate processors - * * @return string[] */ private function retrieveDelegateProcessors(): array { $delegateProcessors = []; + /** @var string[] $resolvers */ + $resolvers = $this->retrieveArgument($this->processorResolverFactoryClassName, 'processorResolvers', []); - foreach ($this->retrieveArgument($this->processorResolverFactoryClassName, 'processorResolvers', []) as $processor) { - $processorPool = $this->retrieveArgument($processor, 'processorPool'); + foreach ($resolvers as $resolver) { + $processorPool = $this->retrieveArgument($resolver, 'processorPool'); if ($processorPool) { $delegateProcessors[] = $this->retrieveArgument($processorPool, 'array', []); @@ -84,7 +74,7 @@ private function retrieveDelegateProcessors(): array * * @param string $className * @param string $argumentName - * @param null $defaultValue + * @param mixed $defaultValue * @return mixed */ private function retrieveArgument(string $className, string $argumentName, $defaultValue = null) diff --git a/Model/Config/Source/OrderPendingStates.php b/Model/Config/Source/OrderPendingStates.php index ba330ac..6afdc41 100644 --- a/Model/Config/Source/OrderPendingStates.php +++ b/Model/Config/Source/OrderPendingStates.php @@ -10,13 +10,10 @@ use Magento\Framework\Data\OptionSourceInterface; use Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory; -/** - * Class OrderPendingStates - */ final class OrderPendingStates implements OptionSourceInterface { /** - * @var \Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory + * @var CollectionFactory */ private $collectionFactory; @@ -25,18 +22,12 @@ final class OrderPendingStates implements OptionSourceInterface */ private $options; - /** - * @param \Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory $collectionFactory - */ public function __construct( CollectionFactory $collectionFactory ) { $this->collectionFactory = $collectionFactory; } - /** - * @inheritdoc - */ public function toOptionArray(): array { return $this->options ?? $this->options = $this->collectionFactory->create()->joinStates()->toOptionArray(); diff --git a/Model/Config/Source/VirtualArrayArgumentList.php b/Model/Config/Source/VirtualArrayArgumentList.php index 2f53990..51fdc08 100644 --- a/Model/Config/Source/VirtualArrayArgumentList.php +++ b/Model/Config/Source/VirtualArrayArgumentList.php @@ -11,13 +11,10 @@ use Magento\Framework\ObjectManager\ConfigInterface; use Magento\Framework\Phrase; -/** - * Class VirtualArrayArgumentList - */ final class VirtualArrayArgumentList implements OptionSourceInterface { /** - * @var \Magento\Framework\ObjectManager\ConfigInterface + * @var ConfigInterface */ private $objectManagerConfig; @@ -36,11 +33,6 @@ final class VirtualArrayArgumentList implements OptionSourceInterface */ private $options; - /** - * @param \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig - * @param string $className - * @param string $argumentName - */ public function __construct( ConfigInterface $objectManagerConfig, string $className, @@ -51,9 +43,6 @@ public function __construct( $this->argumentName = $argumentName; } - /** - * @inheritdoc - */ public function toOptionArray(): array { if (!$this->options) { diff --git a/Model/Config/Source/VirtualCustomerAttributes.php b/Model/Config/Source/VirtualCustomerAttributes.php index 93c1345..cb2ca1b 100644 --- a/Model/Config/Source/VirtualCustomerAttributes.php +++ b/Model/Config/Source/VirtualCustomerAttributes.php @@ -11,13 +11,10 @@ use Magento\Framework\Data\OptionSourceInterface; use Magento\Framework\Exception\LocalizedException; -/** - * Class VirtualCustomerAttributes - */ final class VirtualCustomerAttributes implements OptionSourceInterface { /** - * @var \Magento\Customer\Api\MetadataInterface + * @var MetadataInterface */ private $metadata; @@ -26,10 +23,6 @@ final class VirtualCustomerAttributes implements OptionSourceInterface */ private $options; - /** - * @param \Magento\Customer\Api\MetadataInterface $metadata - * @param array $options - */ public function __construct( MetadataInterface $metadata, array $options = [] @@ -38,9 +31,6 @@ public function __construct( $this->options = $this->loadOptions($options); } - /** - * @inheritdoc - */ public function toOptionArray(): array { return $this->options; @@ -49,7 +39,7 @@ public function toOptionArray(): array /** * Load an prepare customer address attributes options * - * @param array $defaultOptions + * @param array $defaultOptions [optional] * @return array */ public function loadOptions(array $defaultOptions = []): array diff --git a/Model/Config/Source/VirtualEntityAttributes.php b/Model/Config/Source/VirtualEntityAttributes.php index f768767..381fc6c 100644 --- a/Model/Config/Source/VirtualEntityAttributes.php +++ b/Model/Config/Source/VirtualEntityAttributes.php @@ -18,7 +18,7 @@ final class VirtualEntityAttributes implements OptionSourceInterface { /** - * @var \Magento\Framework\Model\EntitySnapshot\AttributeProviderInterface + * @var AttributeProviderInterface */ private $attributeProvider; @@ -32,10 +32,6 @@ final class VirtualEntityAttributes implements OptionSourceInterface */ private $options; - /** - * @param \Magento\Framework\Model\EntitySnapshot\AttributeProviderInterface $attributeProvider - * @param string $entityType - */ public function __construct( AttributeProviderInterface $attributeProvider, string $entityType @@ -45,9 +41,6 @@ public function __construct( $this->options = []; } - /** - * @inheritdoc - */ public function toOptionArray(): array { if (!$this->options) { diff --git a/Model/Customer/Anonymize/AccountBlocker.php b/Model/Customer/Anonymize/AccountBlocker.php index ae259b2..369ae6d 100644 --- a/Model/Customer/Anonymize/AccountBlocker.php +++ b/Model/Customer/Anonymize/AccountBlocker.php @@ -8,9 +8,13 @@ namespace Opengento\Gdpr\Model\Customer\Anonymize; use Magento\Customer\Model\CustomerRegistry; +use Magento\Customer\Model\ResourceModel\Visitor\Collection; use Magento\Customer\Model\ResourceModel\Visitor\CollectionFactory as VisitorCollectionFactory; +use Magento\Customer\Model\Visitor; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\Encryption\EncryptorInterface; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Intl\DateTimeFactory; use Magento\Framework\Math\Random; use Magento\Framework\Session\Config; @@ -18,55 +22,43 @@ use Magento\Framework\Stdlib\DateTime; use Magento\Store\Model\ScopeInterface; -/** - * Class AccountBlocker - */ final class AccountBlocker { /** - * @var \Magento\Customer\Model\CustomerRegistry + * @var CustomerRegistry */ private $customerRegistry; /** - * @var \Magento\Framework\Session\SaveHandlerInterface + * @var SaveHandlerInterface */ private $saveHandler; /** - * @var \Magento\Customer\Model\ResourceModel\Visitor\CollectionFactory + * @var VisitorCollectionFactory */ private $visitorCollectionFactory; /** - * @var \Magento\Framework\Encryption\EncryptorInterface + * @var EncryptorInterface */ private $encryptor; /** - * @var \Magento\Framework\Intl\DateTimeFactory + * @var DateTimeFactory */ private $dateTimeFactory; /** - * @var \Magento\Framework\Math\Random + * @var Random */ private $mathRandom; /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface + * @var ScopeConfigInterface */ private $scopeConfig; - /** - * @param \Magento\Customer\Model\CustomerRegistry $customerRegistry - * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor - * @param \Magento\Framework\Session\SaveHandlerInterface $saveHandler - * @param \Magento\Customer\Model\ResourceModel\Visitor\CollectionFactory $visitorCollectionFactory - * @param \Magento\Framework\Intl\DateTimeFactory $dateTimeFactory - * @param \Magento\Framework\Math\Random $mathRandom - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - */ public function __construct( CustomerRegistry $customerRegistry, EncryptorInterface $encryptor, @@ -86,12 +78,10 @@ public function __construct( } /** - * Invalid a customer account - * * @param int $customerId * @return bool - * @throws \Magento\Framework\Exception\NoSuchEntityException - * @throws \Magento\Framework\Exception\LocalizedException + * @throws NoSuchEntityException + * @throws LocalizedException */ public function invalid(int $customerId): bool { @@ -99,12 +89,10 @@ public function invalid(int $customerId): bool } /** - * Reset the customer password to unknown password - * * @param int $customerId * @return bool - * @throws \Magento\Framework\Exception\NoSuchEntityException - * @throws \Magento\Framework\Exception\LocalizedException + * @throws NoSuchEntityException + * @throws LocalizedException */ private function resetPassword(int $customerId): bool { @@ -117,8 +105,6 @@ private function resetPassword(int $customerId): bool } /** - * Close all sessions related to the customer - * * @param int $customerId * @return bool */ @@ -128,12 +114,12 @@ private function closeSessions(int $customerId): bool $dateTime = $this->dateTimeFactory->create(); $time = $dateTime->setTimestamp($dateTime->getTimestamp() - $sessionLifetime); - /** @var \Magento\Customer\Model\ResourceModel\Visitor\Collection $visitorCollection */ + /** @var Collection $visitorCollection */ $visitorCollection = $this->visitorCollectionFactory->create(); $visitorCollection->addFieldToFilter('customer_id', ['eq' => $customerId]); $visitorCollection->addFieldToFilter('last_visit_at', ['from' => $time->format(DateTime::DATETIME_PHP_FORMAT)]); - /** @var \Magento\Customer\Model\Visitor $visitor */ + /** @var Visitor $visitor */ foreach ($visitorCollection->getItems() as $visitor) { $this->saveHandler->destroy($visitor->getData('session_id')); } diff --git a/Model/Customer/Anonymize/Processor/CustomerAddressDataProcessor.php b/Model/Customer/Anonymize/Processor/CustomerAddressDataProcessor.php index fa47ec7..fd23a67 100644 --- a/Model/Customer/Anonymize/Processor/CustomerAddressDataProcessor.php +++ b/Model/Customer/Anonymize/Processor/CustomerAddressDataProcessor.php @@ -9,34 +9,27 @@ use Magento\Customer\Api\AddressRepositoryInterface; use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Framework\Exception\LocalizedException; use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -/** - * Class CustomerAddressDataProcessor - */ final class CustomerAddressDataProcessor implements ProcessorInterface { /** - * @var \Opengento\Gdpr\Service\Anonymize\AnonymizerInterface + * @var AnonymizerInterface */ private $anonymizer; /** - * @var \Magento\Customer\Api\AddressRepositoryInterface + * @var AddressRepositoryInterface */ private $customerAddressRepository; /** - * @var \Magento\Framework\Api\SearchCriteriaBuilder + * @var SearchCriteriaBuilder */ private $searchCriteriaBuilder; - /** - * @param \Opengento\Gdpr\Service\Anonymize\AnonymizerInterface $anonymizer - * @param \Magento\Customer\Api\AddressRepositoryInterface $customerAddressRepository - * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder - */ public function __construct( AnonymizerInterface $anonymizer, AddressRepositoryInterface $customerAddressRepository, @@ -49,7 +42,7 @@ public function __construct( /** * @inheritdoc - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ public function execute(int $customerId): bool { diff --git a/Model/Customer/Anonymize/Processor/CustomerDataProcessor.php b/Model/Customer/Anonymize/Processor/CustomerDataProcessor.php index 1aef2cc..a395835 100644 --- a/Model/Customer/Anonymize/Processor/CustomerDataProcessor.php +++ b/Model/Customer/Anonymize/Processor/CustomerDataProcessor.php @@ -9,6 +9,7 @@ use Magento\Customer\Api\CustomerRepositoryInterface; use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Api\OrderRepositoryInterface; @@ -17,49 +18,38 @@ use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -/** - * Class CustomerDataProcessor - */ final class CustomerDataProcessor implements ProcessorInterface { /** - * @var \Opengento\Gdpr\Service\Anonymize\AnonymizerInterface + * @var AnonymizerInterface */ private $anonymizer; /** - * @var \Opengento\Gdpr\Model\Customer\Anonymize\AccountBlocker + * @var AccountBlocker */ private $accountBlocker; /** - * @var \Magento\Customer\Api\CustomerRepositoryInterface + * @var CustomerRepositoryInterface */ private $customerRepository; /** - * @var \Magento\Sales\Api\OrderRepositoryInterface + * @var OrderRepositoryInterface */ private $orderRepository; /** - * @var \Magento\Framework\Api\SearchCriteriaBuilder + * @var SearchCriteriaBuilder */ private $searchCriteriaBuilder; /** - * @var \Opengento\Gdpr\Model\Config + * @var Config */ private $config; - /** - * @param \Opengento\Gdpr\Service\Anonymize\AnonymizerInterface $anonymizer - * @param \Opengento\Gdpr\Model\Customer\Anonymize\AccountBlocker $accountBlocker - * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository - * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository - * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder - * @param \Opengento\Gdpr\Model\Config $config - */ public function __construct( AnonymizerInterface $anonymizer, AccountBlocker $accountBlocker, @@ -78,7 +68,7 @@ public function __construct( /** * @inheritdoc - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ public function execute(int $customerId): bool { diff --git a/Model/Customer/Anonymize/Processor/OrderDataProcessor.php b/Model/Customer/Anonymize/Processor/OrderDataProcessor.php index ccbf964..6a49428 100644 --- a/Model/Customer/Anonymize/Processor/OrderDataProcessor.php +++ b/Model/Customer/Anonymize/Processor/OrderDataProcessor.php @@ -7,7 +7,9 @@ namespace Opengento\Gdpr\Model\Customer\Anonymize\Processor; +use Exception; use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Sales\Api\Data\OrderAddressInterface; use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Api\OrderAddressRepositoryInterface; use Magento\Sales\Api\OrderRepositoryInterface; @@ -16,43 +18,33 @@ use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -/** - * Class OrderDataProcessor - */ final class OrderDataProcessor implements ProcessorInterface { /** - * @var \Opengento\Gdpr\Service\Anonymize\AnonymizerInterface + * @var AnonymizerInterface */ private $anonymizer; /** - * @var \Magento\Sales\Api\OrderRepositoryInterface + * @var OrderRepositoryInterface */ private $orderRepository; /** - * @var \Magento\Sales\Api\OrderAddressRepositoryInterface + * @var OrderAddressRepositoryInterface */ private $orderAddressRepository; /** - * @var \Magento\Framework\Api\SearchCriteriaBuilder + * @var SearchCriteriaBuilder */ private $searchCriteriaBuilder; /** - * @var \Opengento\Gdpr\Api\EraseSalesInformationInterface + * @var EraseSalesInformationInterface */ private $eraseSalesInformation; - /** - * @param \Opengento\Gdpr\Service\Anonymize\AnonymizerInterface $anonymizer - * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository - * @param \Magento\Sales\Api\OrderAddressRepositoryInterface $orderAddressRepository - * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder - * @param \Opengento\Gdpr\Api\EraseSalesInformationInterface $eraseSalesInformation - */ public function __construct( AnonymizerInterface $anonymizer, OrderRepositoryInterface $orderRepository, @@ -69,14 +61,14 @@ public function __construct( /** * @inheritdoc - * @throws \Exception + * @throws Exception */ public function execute(int $customerId): bool { $this->searchCriteriaBuilder->addFilter(OrderInterface::CUSTOMER_ID, $customerId); $orderList = $this->orderRepository->getList($this->searchCriteriaBuilder->create()); - /** @var \Magento\Sales\Model\Order $order */ + /** @var Order $order */ foreach ($orderList->getItems() as $order) { $lastActive = new \DateTime($order->getUpdatedAt()); if ($this->eraseSalesInformation->isAlive($lastActive)) { @@ -89,17 +81,11 @@ public function execute(int $customerId): bool return true; } - /** - * Anonymize the order entity - * - * @param \Magento\Sales\Model\Order $order - * @return void - */ private function anonymize(Order $order): void { $this->orderRepository->save($this->anonymizer->anonymize($order)); - /** @var \Magento\Sales\Api\Data\OrderAddressInterface|null $orderAddress */ + /** @var OrderAddressInterface|null $orderAddress */ foreach ([$order->getBillingAddress(), $order->getShippingAddress()] as $orderAddress) { if ($orderAddress) { $this->orderAddressRepository->save($this->anonymizer->anonymize($orderAddress)); diff --git a/Model/Customer/Anonymize/Processor/QuoteDataProcessor.php b/Model/Customer/Anonymize/Processor/QuoteDataProcessor.php index efe05f9..600053e 100644 --- a/Model/Customer/Anonymize/Processor/QuoteDataProcessor.php +++ b/Model/Customer/Anonymize/Processor/QuoteDataProcessor.php @@ -7,43 +7,36 @@ namespace Opengento\Gdpr\Model\Customer\Anonymize\Processor; +use Exception; use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Quote\Api\CartRepositoryInterface; +use Magento\Quote\Model\Quote; use Magento\Quote\Model\ResourceModel\Quote\Address; use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -/** - * Class QuoteDataProcessor - */ final class QuoteDataProcessor implements ProcessorInterface { /** - * @var \Opengento\Gdpr\Service\Anonymize\AnonymizerInterface + * @var AnonymizerInterface */ private $anonymizer; /** - * @var \Magento\Quote\Api\CartRepositoryInterface + * @var CartRepositoryInterface */ private $quoteRepository; /** - * @var \Magento\Quote\Model\ResourceModel\Quote\Address + * @var Address */ private $quoteAddressResourceModel; /** - * @var \Magento\Framework\Api\SearchCriteriaBuilder + * @var SearchCriteriaBuilder */ private $searchCriteriaBuilder; - /** - * @param \Opengento\Gdpr\Service\Anonymize\AnonymizerInterface $anonymizer - * @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository - * @param \Magento\Quote\Model\ResourceModel\Quote\Address $quoteAddressResourceModel - * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder - */ public function __construct( AnonymizerInterface $anonymizer, CartRepositoryInterface $quoteRepository, @@ -58,18 +51,18 @@ public function __construct( /** * @inheritdoc - * @throws \Exception + * @throws Exception */ public function execute(int $customerId): bool { $this->searchCriteriaBuilder->addFilter('customer_id', $customerId); $quoteList = $this->quoteRepository->getList($this->searchCriteriaBuilder->create()); - /** @var \Magento\Quote\Model\Quote $quote */ + /** @var Quote $quote */ foreach ($quoteList->getItems() as $quote) { $this->quoteRepository->save($this->anonymizer->anonymize($quote)); - /** @var \Magento\Quote\Model\Quote\Address|null $quoteAddress */ + /** @var Quote\Address|null $quoteAddress */ foreach ([$quote->getBillingAddress(), $quote->getShippingAddress()] as $quoteAddress) { if ($quoteAddress) { $this->quoteAddressResourceModel->save($this->anonymizer->anonymize($quoteAddress)); diff --git a/Model/Customer/Anonymize/Processor/SubscriberDataProcessor.php b/Model/Customer/Anonymize/Processor/SubscriberDataProcessor.php index 6c4254c..4bf35a4 100644 --- a/Model/Customer/Anonymize/Processor/SubscriberDataProcessor.php +++ b/Model/Customer/Anonymize/Processor/SubscriberDataProcessor.php @@ -7,36 +7,30 @@ namespace Opengento\Gdpr\Model\Customer\Anonymize\Processor; +use Exception; use Magento\Newsletter\Model\ResourceModel\Subscriber as ResourceSubscriber; +use Opengento\Gdpr\Model\Newsletter\Subscriber; use Opengento\Gdpr\Model\Newsletter\SubscriberFactory; use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -/** - * Class SubscriberDataProcessor - */ final class SubscriberDataProcessor implements ProcessorInterface { /** - * @var \Opengento\Gdpr\Service\Anonymize\AnonymizerInterface + * @var AnonymizerInterface */ private $anonymizer; /** - * @var \Opengento\Gdpr\Model\Newsletter\SubscriberFactory + * @var SubscriberFactory */ private $subscriberFactory; /** - * @var \Magento\Newsletter\Model\ResourceModel\Subscriber + * @var ResourceSubscriber */ private $subscriberResourceModel; - /** - * @param \Opengento\Gdpr\Service\Anonymize\AnonymizerInterface $anonymizer - * @param \Opengento\Gdpr\Model\Newsletter\SubscriberFactory $subscriberFactory - * @param \Magento\Newsletter\Model\ResourceModel\Subscriber $subscriberResourceModel - */ public function __construct( AnonymizerInterface $anonymizer, SubscriberFactory $subscriberFactory, @@ -49,11 +43,11 @@ public function __construct( /** * @inheritdoc - * @throws \Exception + * @throws Exception */ public function execute(int $customerId): bool { - /** @var \Opengento\Gdpr\Model\Newsletter\Subscriber $subscriber */ + /** @var Subscriber $subscriber */ $subscriber = $this->subscriberFactory->create(); $subscriber->loadByCustomerId($customerId); $this->anonymizer->anonymize($subscriber); diff --git a/Model/Customer/CustomerChecker.php b/Model/Customer/CustomerChecker.php index 3696521..60ade97 100644 --- a/Model/Customer/CustomerChecker.php +++ b/Model/Customer/CustomerChecker.php @@ -13,23 +13,20 @@ use Opengento\Gdpr\Model\Config; use Opengento\Gdpr\Model\Entity\EntityCheckerInterface; -/** - * Class CustomerChecker - */ final class CustomerChecker implements EntityCheckerInterface { /** - * @var \Magento\Sales\Api\OrderRepositoryInterface + * @var OrderRepositoryInterface */ private $orderRepository; /** - * @var \Magento\Framework\Api\SearchCriteriaBuilder + * @var SearchCriteriaBuilder */ private $searchCriteriaBuilder; /** - * @var \Opengento\Gdpr\Model\Config + * @var Config */ private $config; @@ -38,11 +35,6 @@ final class CustomerChecker implements EntityCheckerInterface */ private $cache; - /** - * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository - * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder - * @param \Opengento\Gdpr\Model\Config $config - */ public function __construct( OrderRepositoryInterface $orderRepository, SearchCriteriaBuilder $searchCriteriaBuilder, diff --git a/Model/Customer/Delete/Processor/CustomerAddressDataProcessor.php b/Model/Customer/Delete/Processor/CustomerAddressDataProcessor.php index abaf7ab..429ea20 100644 --- a/Model/Customer/Delete/Processor/CustomerAddressDataProcessor.php +++ b/Model/Customer/Delete/Processor/CustomerAddressDataProcessor.php @@ -9,27 +9,21 @@ use Magento\Customer\Api\AddressRepositoryInterface; use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Framework\Exception\LocalizedException; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -/** - * Class CustomerAddressDataProcessor - */ final class CustomerAddressDataProcessor implements ProcessorInterface { /** - * @var \Magento\Customer\Api\AddressRepositoryInterface + * @var AddressRepositoryInterface */ private $customerAddressRepository; /** - * @var \Magento\Framework\Api\SearchCriteriaBuilder + * @var SearchCriteriaBuilder */ private $searchCriteriaBuilder; - /** - * @param \Magento\Customer\Api\AddressRepositoryInterface $customerAddressRepository - * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder - */ public function __construct( AddressRepositoryInterface $customerAddressRepository, SearchCriteriaBuilder $searchCriteriaBuilder @@ -40,7 +34,7 @@ public function __construct( /** * @inheritdoc - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ public function execute(int $customerId): bool { diff --git a/Model/Customer/Delete/Processor/CustomerDataProcessor.php b/Model/Customer/Delete/Processor/CustomerDataProcessor.php index 227962d..c8df462 100644 --- a/Model/Customer/Delete/Processor/CustomerDataProcessor.php +++ b/Model/Customer/Delete/Processor/CustomerDataProcessor.php @@ -8,22 +8,17 @@ namespace Opengento\Gdpr\Model\Customer\Delete\Processor; use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Exception\NoSuchEntityException; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -/** - * Class CustomerDataProcessor - */ final class CustomerDataProcessor implements ProcessorInterface { /** - * @var \Magento\Customer\Api\CustomerRepositoryInterface + * @var CustomerRepositoryInterface */ private $customerRepository; - /** - * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository - */ public function __construct( CustomerRepositoryInterface $customerRepository ) { @@ -32,7 +27,7 @@ public function __construct( /** * @inheritdoc - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ public function execute(int $customerId): bool { diff --git a/Model/Customer/Delete/Processor/OrderDataProcessor.php b/Model/Customer/Delete/Processor/OrderDataProcessor.php index 94916b6..1a3b2a6 100644 --- a/Model/Customer/Delete/Processor/OrderDataProcessor.php +++ b/Model/Customer/Delete/Processor/OrderDataProcessor.php @@ -7,37 +7,30 @@ namespace Opengento\Gdpr\Model\Customer\Delete\Processor; +use Exception; use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Api\OrderRepositoryInterface; use Opengento\Gdpr\Api\EraseSalesInformationInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -/** - * Class OrderDataProcessor - */ final class OrderDataProcessor implements ProcessorInterface { /** - * @var \Magento\Sales\Api\OrderRepositoryInterface + * @var OrderRepositoryInterface */ private $orderRepository; /** - * @var \Magento\Framework\Api\SearchCriteriaBuilder + * @var SearchCriteriaBuilder */ private $searchCriteriaBuilder; /** - * @var \Opengento\Gdpr\Api\EraseSalesInformationInterface + * @var EraseSalesInformationInterface */ private $eraseSalesInformation; - /** - * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository - * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder - * @param \Opengento\Gdpr\Api\EraseSalesInformationInterface $eraseSalesInformation - */ public function __construct( OrderRepositoryInterface $orderRepository, SearchCriteriaBuilder $searchCriteriaBuilder, @@ -50,7 +43,7 @@ public function __construct( /** * @inheritdoc - * @throws \Exception + * @throws Exception */ public function execute(int $customerId): bool { diff --git a/Model/Customer/Delete/Processor/QuoteDataProcessor.php b/Model/Customer/Delete/Processor/QuoteDataProcessor.php index 366c65d..37c6275 100644 --- a/Model/Customer/Delete/Processor/QuoteDataProcessor.php +++ b/Model/Customer/Delete/Processor/QuoteDataProcessor.php @@ -11,25 +11,18 @@ use Magento\Quote\Api\CartRepositoryInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -/** - * Class QuoteDataProcessor - */ final class QuoteDataProcessor implements ProcessorInterface { /** - * @var \Magento\Quote\Api\CartRepositoryInterface + * @var CartRepositoryInterface */ private $quoteRepository; /** - * @var \Magento\Framework\Api\SearchCriteriaBuilder + * @var SearchCriteriaBuilder */ private $searchCriteriaBuilder; - /** - * @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository - * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder - */ public function __construct( CartRepositoryInterface $quoteRepository, SearchCriteriaBuilder $searchCriteriaBuilder @@ -38,9 +31,6 @@ public function __construct( $this->searchCriteriaBuilder = $searchCriteriaBuilder; } - /** - * @inheritdoc - */ public function execute(int $customerId): bool { $this->searchCriteriaBuilder->addFilter('customer_id', $customerId); diff --git a/Model/Customer/Delete/Processor/SubscriberDataProcessor.php b/Model/Customer/Delete/Processor/SubscriberDataProcessor.php index 87d318e..2074ab2 100644 --- a/Model/Customer/Delete/Processor/SubscriberDataProcessor.php +++ b/Model/Customer/Delete/Processor/SubscriberDataProcessor.php @@ -7,29 +7,24 @@ namespace Opengento\Gdpr\Model\Customer\Delete\Processor; +use Exception; use Magento\Newsletter\Model\ResourceModel\Subscriber as ResourceSubscriber; +use Magento\Newsletter\Model\Subscriber; use Magento\Newsletter\Model\SubscriberFactory; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -/** - * Class SubscriberDataProcessor - */ final class SubscriberDataProcessor implements ProcessorInterface { /** - * @var \Magento\Newsletter\Model\SubscriberFactory + * @var SubscriberFactory */ private $subscriberFactory; /** - * @var \Magento\Newsletter\Model\ResourceModel\Subscriber + * @var ResourceSubscriber */ private $subscriberResourceModel; - /** - * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory - * @param \Magento\Newsletter\Model\ResourceModel\Subscriber $subscriberResourceModel - */ public function __construct( SubscriberFactory $subscriberFactory, ResourceSubscriber $subscriberResourceModel @@ -40,11 +35,11 @@ public function __construct( /** * @inheritdoc - * @throws \Exception + * @throws Exception */ public function execute(int $customerId): bool { - /** @var \Magento\Newsletter\Model\Subscriber $subscriber */ + /** @var Subscriber $subscriber */ $subscriber = $this->subscriberFactory->create(); $subscriber->loadByCustomerId($customerId); $this->subscriberResourceModel->delete($subscriber); diff --git a/Model/Customer/Erase/Notifier.php b/Model/Customer/Erase/Notifier.php index ec7fd59..5ce8b2f 100644 --- a/Model/Customer/Erase/Notifier.php +++ b/Model/Customer/Erase/Notifier.php @@ -8,29 +8,23 @@ namespace Opengento\Gdpr\Model\Customer\Erase; use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Framework\Exception\LocalizedException; use Opengento\Gdpr\Api\Data\EraseEntityInterface; use Opengento\Gdpr\Model\Customer\Notifier\SenderInterface; use Opengento\Gdpr\Model\Erase\NotifierInterface; -/** - * Class Notifier - */ final class Notifier implements NotifierInterface { /** - * @var \Opengento\Gdpr\Model\Customer\Notifier\SenderInterface[] + * @var SenderInterface[] */ private $senders; /** - * @var \Magento\Customer\Api\CustomerRepositoryInterface + * @var CustomerRepositoryInterface */ private $customerRepository; - /** - * @param \Opengento\Gdpr\Model\Customer\Notifier\SenderInterface[] $senders - * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository - */ public function __construct( array $senders, CustomerRepositoryInterface $customerRepository @@ -43,7 +37,7 @@ public function __construct( /** * @inheritdoc - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ public function notify(EraseEntityInterface $eraseEntity): void { diff --git a/Model/Customer/Export/Notifier.php b/Model/Customer/Export/Notifier.php index ecf4220..e269818 100644 --- a/Model/Customer/Export/Notifier.php +++ b/Model/Customer/Export/Notifier.php @@ -8,28 +8,26 @@ namespace Opengento\Gdpr\Model\Customer\Export; use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Framework\Exception\LocalizedException; use Opengento\Gdpr\Api\Data\ExportEntityInterface; use Opengento\Gdpr\Model\Customer\Notifier\SenderInterface; use Opengento\Gdpr\Model\Export\NotifierInterface; -/** - * Class Notifier - */ final class Notifier implements NotifierInterface { /** - * @var \Opengento\Gdpr\Model\Customer\Notifier\SenderInterface[] + * @var SenderInterface[] */ private $senders; /** - * @var \Magento\Customer\Api\CustomerRepositoryInterface + * @var CustomerRepositoryInterface */ private $customerRepository; /** - * @param \Opengento\Gdpr\Model\Customer\Notifier\SenderInterface[] $senders - * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository + * @param SenderInterface[] $senders + * @param CustomerRepositoryInterface $customerRepository */ public function __construct( array $senders, @@ -43,7 +41,7 @@ public function __construct( /** * @inheritdoc - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ public function notify(ExportEntityInterface $exportEntity): void { diff --git a/Model/Customer/Export/Processor/CustomerAddressDataProcessor.php b/Model/Customer/Export/Processor/CustomerAddressDataProcessor.php index 9fea033..1223987 100644 --- a/Model/Customer/Export/Processor/CustomerAddressDataProcessor.php +++ b/Model/Customer/Export/Processor/CustomerAddressDataProcessor.php @@ -8,30 +8,24 @@ namespace Opengento\Gdpr\Model\Customer\Export\Processor; use Magento\Customer\Api\AddressRepositoryInterface; +use Magento\Customer\Api\Data\AddressInterface; use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Framework\Exception\LocalizedException; use Opengento\Gdpr\Model\Entity\DataCollectorInterface; use Opengento\Gdpr\Service\Export\Processor\AbstractDataProcessor; -/** - * Class CustomerAddressDataProcessor - */ final class CustomerAddressDataProcessor extends AbstractDataProcessor { /** - * @var \Magento\Customer\Api\AddressRepositoryInterface + * @var AddressRepositoryInterface */ private $addressRepository; /** - * @var \Magento\Framework\Api\SearchCriteriaBuilder + * @var SearchCriteriaBuilder */ private $searchCriteriaBuilder; - /** - * @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository - * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder - * @param \Opengento\Gdpr\Model\Entity\DataCollectorInterface $dataCollector - */ public function __construct( AddressRepositoryInterface $addressRepository, SearchCriteriaBuilder $searchCriteriaBuilder, @@ -44,14 +38,14 @@ public function __construct( /** * @inheritdoc - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ public function execute(int $customerId, array $data): array { $this->searchCriteriaBuilder->addFilter('parent_id', $customerId); $addressList = $this->addressRepository->getList($this->searchCriteriaBuilder->create()); - /** @var \Magento\Customer\Api\Data\AddressInterface $entity */ + /** @var AddressInterface $entity */ foreach ($addressList->getItems() as $entity) { $data['customer_addresses']['customer_address_id_' . $entity->getId()] = $this->collectData($entity); } diff --git a/Model/Customer/Export/Processor/CustomerDataProcessor.php b/Model/Customer/Export/Processor/CustomerDataProcessor.php index d7b7527..92d1770 100644 --- a/Model/Customer/Export/Processor/CustomerDataProcessor.php +++ b/Model/Customer/Export/Processor/CustomerDataProcessor.php @@ -8,23 +8,18 @@ namespace Opengento\Gdpr\Model\Customer\Export\Processor; use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\NoSuchEntityException; use Opengento\Gdpr\Model\Entity\DataCollectorInterface; use Opengento\Gdpr\Service\Export\Processor\AbstractDataProcessor; -/** - * Class CustomerDataProcessor - */ final class CustomerDataProcessor extends AbstractDataProcessor { /** - * @var \Magento\Customer\Api\CustomerRepositoryInterface + * @var CustomerRepositoryInterface */ private $customerRepository; - /** - * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository - * @param \Opengento\Gdpr\Model\Entity\DataCollectorInterface $dataCollector - */ public function __construct( CustomerRepositoryInterface $customerRepository, DataCollectorInterface $dataCollector @@ -35,8 +30,8 @@ public function __construct( /** * @inheritdoc - * @throws \Magento\Framework\Exception\NoSuchEntityException - * @throws \Magento\Framework\Exception\LocalizedException + * @throws NoSuchEntityException + * @throws LocalizedException */ public function execute(int $customerId, array $data): array { diff --git a/Model/Customer/Export/Processor/OrderDataProcessor.php b/Model/Customer/Export/Processor/OrderDataProcessor.php index 37ffb3e..48db9a0 100644 --- a/Model/Customer/Export/Processor/OrderDataProcessor.php +++ b/Model/Customer/Export/Processor/OrderDataProcessor.php @@ -8,31 +8,25 @@ namespace Opengento\Gdpr\Model\Customer\Export\Processor; use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Sales\Api\Data\OrderAddressInterface; use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Api\OrderRepositoryInterface; +use Magento\Sales\Model\Order; use Opengento\Gdpr\Model\Entity\DataCollectorInterface; use Opengento\Gdpr\Service\Export\Processor\AbstractDataProcessor; -/** - * Class QuoteDataProcessor - */ final class OrderDataProcessor extends AbstractDataProcessor { /** - * @var \Magento\Sales\Api\OrderRepositoryInterface + * @var OrderRepositoryInterface */ private $orderRepository; /** - * @var \Magento\Framework\Api\SearchCriteriaBuilder + * @var SearchCriteriaBuilder */ private $searchCriteriaBuilder; - /** - * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository - * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder - * @param \Opengento\Gdpr\Model\Entity\DataCollectorInterface $dataCollector - */ public function __construct( OrderRepositoryInterface $orderRepository, SearchCriteriaBuilder $searchCriteriaBuilder, @@ -43,20 +37,17 @@ public function __construct( parent::__construct($dataCollector); } - /** - * @inheritdoc - */ public function execute(int $customerId, array $data): array { $this->searchCriteriaBuilder->addFilter(OrderInterface::CUSTOMER_ID, $customerId); $orderList = $this->orderRepository->getList($this->searchCriteriaBuilder->create()); - /** @var \Magento\Sales\Model\Order $order */ + /** @var Order $order */ foreach ($orderList->getItems() as $order) { $key = 'order_id_' . $order->getEntityId(); $data['orders'][$key] = $this->collectData($order); - /** @var \Magento\Sales\Api\Data\OrderAddressInterface|null $orderAddress */ + /** @var OrderAddressInterface|null $orderAddress */ foreach ([$order->getBillingAddress(), $order->getShippingAddress()] as $orderAddress) { if ($orderAddress) { $data['orders'][$key][$orderAddress->getAddressType()] = $this->collectData($orderAddress); diff --git a/Model/Customer/Export/Processor/QuoteDataProcessor.php b/Model/Customer/Export/Processor/QuoteDataProcessor.php index 2f8c381..dec45e5 100644 --- a/Model/Customer/Export/Processor/QuoteDataProcessor.php +++ b/Model/Customer/Export/Processor/QuoteDataProcessor.php @@ -9,29 +9,23 @@ use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Quote\Api\CartRepositoryInterface; +use Magento\Quote\Model\Quote; +use Magento\Quote\Model\Quote\Address; use Opengento\Gdpr\Model\Entity\DataCollectorInterface; use Opengento\Gdpr\Service\Export\Processor\AbstractDataProcessor; -/** - * Class QuoteDataProcessor - */ final class QuoteDataProcessor extends AbstractDataProcessor { /** - * @var \Magento\Quote\Api\CartRepositoryInterface + * @var CartRepositoryInterface */ private $quoteRepository; /** - * @var \Magento\Framework\Api\SearchCriteriaBuilder + * @var SearchCriteriaBuilder */ private $searchCriteriaBuilder; - /** - * @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository - * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder - * @param \Opengento\Gdpr\Model\Entity\DataCollectorInterface $dataCollector - */ public function __construct( CartRepositoryInterface $quoteRepository, SearchCriteriaBuilder $searchCriteriaBuilder, @@ -42,20 +36,17 @@ public function __construct( parent::__construct($dataCollector); } - /** - * @inheritdoc - */ public function execute(int $customerId, array $data): array { $this->searchCriteriaBuilder->addFilter('customer_id', $customerId); $quoteList = $this->quoteRepository->getList($this->searchCriteriaBuilder->create()); - /** @var \Magento\Quote\Model\Quote $quote */ + /** @var Quote $quote */ foreach ($quoteList->getItems() as $quote) { $key = 'quote_id_' . $quote->getId(); $data['quotes'][$key] = $this->collectData($quote); - /** @var \Magento\Quote\Model\Quote\Address|null $quoteAddress */ + /** @var Address|null $quoteAddress */ foreach ([$quote->getBillingAddress(), $quote->getShippingAddress()] as $quoteAddress) { if ($quoteAddress) { $data['quotes'][$key][$quoteAddress->getAddressType()] = $this->collectData($quoteAddress); diff --git a/Model/Customer/Export/Processor/SubscriberDataProcessor.php b/Model/Customer/Export/Processor/SubscriberDataProcessor.php index 1c65231..3b97ff8 100644 --- a/Model/Customer/Export/Processor/SubscriberDataProcessor.php +++ b/Model/Customer/Export/Processor/SubscriberDataProcessor.php @@ -8,23 +8,17 @@ namespace Opengento\Gdpr\Model\Customer\Export\Processor; use Opengento\Gdpr\Model\Entity\DataCollectorInterface; +use Opengento\Gdpr\Model\Newsletter\Subscriber; use Opengento\Gdpr\Model\Newsletter\SubscriberFactory; use Opengento\Gdpr\Service\Export\Processor\AbstractDataProcessor; -/** - * Class SubscriberDataProcessor - */ final class SubscriberDataProcessor extends AbstractDataProcessor { /** - * @var \Opengento\Gdpr\Model\Newsletter\SubscriberFactory + * @var SubscriberFactory */ private $subscriberFactory; - /** - * @param \Opengento\Gdpr\Model\Newsletter\SubscriberFactory $subscriberFactory - * @param \Opengento\Gdpr\Model\Entity\DataCollectorInterface $dataCollector - */ public function __construct( SubscriberFactory $subscriberFactory, DataCollectorInterface $dataCollector @@ -33,12 +27,9 @@ public function __construct( parent::__construct($dataCollector); } - /** - * @inheritdoc - */ public function execute(int $customerId, array $data): array { - /** @var \Opengento\Gdpr\Model\Newsletter\Subscriber $subscriber */ + /** @var Subscriber $subscriber */ $subscriber = $this->subscriberFactory->create(); $subscriber->loadByCustomerId($customerId); $data['subscriber'] = $this->collectData($subscriber); diff --git a/Model/Customer/Notifier/MailSender.php b/Model/Customer/Notifier/MailSender.php index 7403555..c62e44b 100644 --- a/Model/Customer/Notifier/MailSender.php +++ b/Model/Customer/Notifier/MailSender.php @@ -10,23 +10,22 @@ use Magento\Customer\Api\Data\CustomerInterface; use Magento\Customer\Helper\View; use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\MailException; use Magento\Framework\Mail\Template\TransportBuilder; use Opengento\Gdpr\Model\Notifier\AbstractMailSender; -/** - * Class MailSender - */ final class MailSender extends AbstractMailSender implements SenderInterface { /** - * @var \Magento\Customer\Helper\View + * @var View */ private $customerViewHelper; /** - * @param \Magento\Customer\Helper\View $customerViewHelper - * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig + * @param View $customerViewHelper + * @param TransportBuilder $transportBuilder + * @param ScopeConfigInterface $scopeConfig * @param string[] $configPaths */ public function __construct( @@ -41,8 +40,8 @@ public function __construct( /** * @inheritdoc - * @throws \Magento\Framework\Exception\LocalizedException - * @throws \Magento\Framework\Exception\MailException + * @throws LocalizedException + * @throws MailException */ public function send(CustomerInterface $customer): void { diff --git a/Model/Customer/Notifier/SenderInterface.php b/Model/Customer/Notifier/SenderInterface.php index 7a48e78..603764b 100644 --- a/Model/Customer/Notifier/SenderInterface.php +++ b/Model/Customer/Notifier/SenderInterface.php @@ -10,16 +10,9 @@ use Magento\Customer\Api\Data\CustomerInterface; /** - * Interface SenderInterface * @api */ interface SenderInterface { - /** - * Send a notification to the customer - * - * @param \Magento\Customer\Api\Data\CustomerInterface $customer - * @return void - */ public function send(CustomerInterface $customer): void; } diff --git a/Model/Customer/SourceProvider/FilterModifier.php b/Model/Customer/SourceProvider/FilterModifier.php index 5ae0082..76ca3fd 100644 --- a/Model/Customer/SourceProvider/FilterModifier.php +++ b/Model/Customer/SourceProvider/FilterModifier.php @@ -9,16 +9,14 @@ use Magento\Framework\Api\Filter; use Magento\Framework\Data\Collection; +use Magento\Framework\Exception\LocalizedException; use Opengento\Gdpr\Model\Entity\SourceProvider\ModifierInterface; -/** - * Class FilterModifier - */ final class FilterModifier implements ModifierInterface { /** * @inheritdoc - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ public function apply(Collection $collection, Filter $filter): void { diff --git a/Model/Entity/DataCollector.php b/Model/Entity/DataCollector.php index 8293c1e..8bb0648 100644 --- a/Model/Entity/DataCollector.php +++ b/Model/Entity/DataCollector.php @@ -7,25 +7,18 @@ namespace Opengento\Gdpr\Model\Entity; -/** - * Class DataCollector - */ final class DataCollector implements DataCollectorInterface { /** - * @var \Opengento\Gdpr\Model\Entity\EntityIteratorInterface + * @var EntityIteratorInterface */ private $entityIterator; /** - * @var \Opengento\Gdpr\Model\Entity\DocumentInterface + * @var DocumentInterface */ private $document; - /** - * @param \Opengento\Gdpr\Model\Entity\EntityIteratorInterface $entityIterator - * @param \Opengento\Gdpr\Model\Entity\DocumentInterface $document - */ public function __construct( EntityIteratorInterface $entityIterator, DocumentInterface $document @@ -34,9 +27,6 @@ public function __construct( $this->document = $document; } - /** - * @inheritdoc - */ public function collect($entity): array { $this->entityIterator->iterate($entity); diff --git a/Model/Entity/DataCollectorGeneric.php b/Model/Entity/DataCollectorGeneric.php index f9a3489..c958542 100644 --- a/Model/Entity/DataCollectorGeneric.php +++ b/Model/Entity/DataCollectorGeneric.php @@ -7,26 +7,24 @@ namespace Opengento\Gdpr\Model\Entity; +use Exception; use Magento\Framework\EntityManager\TypeResolver; -/** - * Class DataCollectorGeneric - */ final class DataCollectorGeneric implements DataCollectorInterface { /** - * @var \Magento\Framework\EntityManager\TypeResolver + * @var TypeResolver */ private $typeResolver; /** - * @var \Opengento\Gdpr\Model\Entity\DataCollectorInterface[] + * @var DataCollectorInterface[] */ private $dataCollectors; /** - * @param \Magento\Framework\EntityManager\TypeResolver $typeResolver - * @param array $dataCollectors + * @param TypeResolver $typeResolver + * @param DataCollectorInterface[] $dataCollectors */ public function __construct( TypeResolver $typeResolver, @@ -42,7 +40,7 @@ public function __construct( /** * @inheritdoc - * @throws \Exception + * @throws Exception */ public function collect($entity): array { diff --git a/Model/Entity/DataCollectorInterface.php b/Model/Entity/DataCollectorInterface.php index 56b30bf..63ecde2 100644 --- a/Model/Entity/DataCollectorInterface.php +++ b/Model/Entity/DataCollectorInterface.php @@ -3,18 +3,16 @@ * Copyright © OpenGento, All rights reserved. * See LICENSE bundled with this library for license details. */ +declare(strict_types=1); namespace Opengento\Gdpr\Model\Entity; /** - * Interface DataCollectorInterface * @api */ interface DataCollectorInterface { /** - * Collect data from the entity object - * * @param object $entity * @return array */ diff --git a/Model/Entity/Document.php b/Model/Entity/Document.php index 5f86c37..852f056 100644 --- a/Model/Entity/Document.php +++ b/Model/Entity/Document.php @@ -7,9 +7,6 @@ namespace Opengento\Gdpr\Model\Entity; -/** - * Class Document - */ final class Document implements DocumentInterface { /** @@ -17,35 +14,24 @@ final class Document implements DocumentInterface */ private $data; - /** - * @param array $data - */ public function __construct(array $data = []) { $this->data = $data; } - /** - * @inheritdoc - */ public function setData(array $data): void { $this->data = $data; } - /** - * @inheritdoc - */ public function addData(string $key, $value): void { $this->data[$key] = $value; } - /** - * @inheritdoc - */ public function getData(): array { + /** @todo Hack: it actually empties the data after. It should'nt. */ $data = $this->data; $this->data = []; diff --git a/Model/Entity/DocumentInterface.php b/Model/Entity/DocumentInterface.php index e3ffa0f..c76d2e9 100644 --- a/Model/Entity/DocumentInterface.php +++ b/Model/Entity/DocumentInterface.php @@ -3,36 +3,18 @@ * Copyright © OpenGento, All rights reserved. * See LICENSE bundled with this library for license details. */ +declare(strict_types=1); namespace Opengento\Gdpr\Model\Entity; /** - * Interface DocumentInterface * @api */ interface DocumentInterface { - /** - * Set the document data - * - * @param array $data - * @return void - */ public function setData(array $data): void; - /** - * Append data by key to the document - * - * @param string $key - * @param mixed $value - * @return void - */ public function addData(string $key, $value): void; - /** - * Retrieve the data and empties the document - * - * @return array - */ public function getData(): array; } diff --git a/Model/Entity/EntityCheckerFactory.php b/Model/Entity/EntityCheckerFactory.php index ceaab46..303ae09 100644 --- a/Model/Entity/EntityCheckerFactory.php +++ b/Model/Entity/EntityCheckerFactory.php @@ -10,7 +10,6 @@ use Magento\Framework\ObjectManagerInterface; /** - * Class EntityCheckerFactory * @api */ final class EntityCheckerFactory @@ -21,13 +20,13 @@ final class EntityCheckerFactory private $checkers; /** - * @var \Magento\Framework\ObjectManagerInterface + * @var ObjectManagerInterface */ private $objectManager; /** * @param string[] $checkers - * @param \Magento\Framework\ObjectManagerInterface $objectManager + * @param ObjectManagerInterface $objectManager */ public function __construct( array $checkers, @@ -37,12 +36,6 @@ public function __construct( $this->objectManager = $objectManager; } - /** - * Retrieve the export processor by entity type - * - * @param string $entityType - * @return \Opengento\Gdpr\Model\Entity\EntityCheckerInterface - */ public function get(string $entityType): EntityCheckerInterface { if (!isset($this->checkers[$entityType])) { diff --git a/Model/Entity/EntityCheckerInterface.php b/Model/Entity/EntityCheckerInterface.php index b71c08c..2df798b 100644 --- a/Model/Entity/EntityCheckerInterface.php +++ b/Model/Entity/EntityCheckerInterface.php @@ -8,13 +8,12 @@ namespace Opengento\Gdpr\Model\Entity; /** - * Interface EntityCheckerInterface * @api */ interface EntityCheckerInterface { /** - * Checks wether or not the entity has pending orders within its relations + * Checks whether or not the entity has pending orders within its relations * * @param int $entityId * @return bool diff --git a/Model/Entity/EntityIterator.php b/Model/Entity/EntityIterator.php index f4df0dc..b7030b1 100644 --- a/Model/Entity/EntityIterator.php +++ b/Model/Entity/EntityIterator.php @@ -7,34 +7,27 @@ namespace Opengento\Gdpr\Model\Entity; +use Exception; use Magento\Framework\EntityManager\HydratorPool; use Magento\Framework\EntityManager\TypeResolver; -/** - * Class EntityIterator - */ final class EntityIterator implements EntityIteratorInterface { /** - * @var \Magento\Framework\EntityManager\HydratorPool + * @var HydratorPool */ private $hydratorPool; /** - * @var \Magento\Framework\EntityManager\TypeResolver + * @var TypeResolver */ private $typeResolver; /** - * @var \Opengento\Gdpr\Model\Entity\EntityValueProcessorInterface + * @var EntityValueProcessorInterface */ private $processor; - /** - * @param \Magento\Framework\EntityManager\HydratorPool $hydratorPool - * @param \Magento\Framework\EntityManager\TypeResolver $typeResolver - * @param \Opengento\Gdpr\Model\Entity\EntityValueProcessorInterface $processor - */ public function __construct( HydratorPool $hydratorPool, TypeResolver $typeResolver, @@ -47,7 +40,7 @@ public function __construct( /** * @inheritdoc - * @throws \Exception + * @throws Exception */ public function iterate($entity): void { diff --git a/Model/Entity/EntityIteratorInterface.php b/Model/Entity/EntityIteratorInterface.php index bcd0c54..40d1e97 100644 --- a/Model/Entity/EntityIteratorInterface.php +++ b/Model/Entity/EntityIteratorInterface.php @@ -3,18 +3,16 @@ * Copyright © OpenGento, All rights reserved. * See LICENSE bundled with this library for license details. */ +declare(strict_types=1); namespace Opengento\Gdpr\Model\Entity; /** - * Interface EntityIteratorInterface * @api */ interface EntityIteratorInterface { /** - * Iterate through the entity object values - * * @param object $entity * @return void */ diff --git a/Model/Entity/EntityValue/CustomAttributesProcessor.php b/Model/Entity/EntityValue/CustomAttributesProcessor.php index 5198ac6..3553e35 100644 --- a/Model/Entity/EntityValue/CustomAttributesProcessor.php +++ b/Model/Entity/EntityValue/CustomAttributesProcessor.php @@ -10,28 +10,19 @@ use Magento\Framework\Api\CustomAttributesDataInterface; use Opengento\Gdpr\Model\Entity\EntityValueProcessorInterface; -/** - * Class CustomAttributesProcessor - */ final class CustomAttributesProcessor implements EntityValueProcessorInterface { /** - * @var \Opengento\Gdpr\Model\Entity\EntityValueProcessorInterface + * @var EntityValueProcessorInterface */ private $processor; - /** - * @param \Opengento\Gdpr\Model\Entity\EntityValueProcessorInterface $processor - */ public function __construct( EntityValueProcessorInterface $processor ) { $this->processor = $processor; } - /** - * @inheritdoc - */ public function process($entity, string $key, $values): void { if ($this->isValid($entity, $key, $values)) { @@ -42,7 +33,7 @@ public function process($entity, string $key, $values): void } /** - * Check wether the entity object and the value key are valid + * Check whether the entity object and the value key are valid * * @param object $entity * @param string $key diff --git a/Model/Entity/EntityValue/ExtensibleDataProcessor.php b/Model/Entity/EntityValue/ExtensibleDataProcessor.php index e80392d..c2d8430 100644 --- a/Model/Entity/EntityValue/ExtensibleDataProcessor.php +++ b/Model/Entity/EntityValue/ExtensibleDataProcessor.php @@ -10,28 +10,19 @@ use Magento\Framework\Api\ExtensibleDataInterface; use Opengento\Gdpr\Model\Entity\EntityValueProcessorInterface; -/** - * Class ExtensibleDataProcessor - */ final class ExtensibleDataProcessor implements EntityValueProcessorInterface { /** - * @var \Opengento\Gdpr\Model\Entity\EntityValueProcessorInterface + * @var EntityValueProcessorInterface */ private $processor; - /** - * @param \Opengento\Gdpr\Model\Entity\EntityValueProcessorInterface $processor - */ public function __construct( EntityValueProcessorInterface $processor ) { $this->processor = $processor; } - /** - * @inheritdoc - */ public function process($entity, string $key, $values): void { if ($this->isValid($entity, $key, $values)) { @@ -42,7 +33,7 @@ public function process($entity, string $key, $values): void } /** - * Check wether the entity object and the value key are valid + * Check whether the entity object and the value key are valid * * @param object $entity * @param string $key diff --git a/Model/Entity/EntityValue/StrategyProcessor.php b/Model/Entity/EntityValue/StrategyProcessor.php index 905c050..1638cda 100644 --- a/Model/Entity/EntityValue/StrategyProcessor.php +++ b/Model/Entity/EntityValue/StrategyProcessor.php @@ -9,18 +9,15 @@ use Opengento\Gdpr\Model\Entity\EntityValueProcessorInterface; -/** - * Class StrategyProcessor - */ final class StrategyProcessor implements EntityValueProcessorInterface { /** - * @var \Opengento\Gdpr\Model\Entity\EntityValueProcessorInterface[] + * @var EntityValueProcessorInterface[] */ private $processors; /** - * @param \Opengento\Gdpr\Model\Entity\EntityValueProcessorInterface[] $processors + * @param EntityValueProcessorInterface[] $processors */ public function __construct( array $processors @@ -32,9 +29,6 @@ public function __construct( $this->processors = \array_combine(\array_keys($processors), $this->processors); } - /** - * @inheritdoc - */ public function process($entity, string $key, $value): void { ($this->processors[$key] ?? $this->processors['default'])->process($entity, $key, $value); diff --git a/Model/Entity/EntityValueProcessorInterface.php b/Model/Entity/EntityValueProcessorInterface.php index 60da55d..88c75c3 100644 --- a/Model/Entity/EntityValueProcessorInterface.php +++ b/Model/Entity/EntityValueProcessorInterface.php @@ -3,18 +3,16 @@ * Copyright © OpenGento, All rights reserved. * See LICENSE bundled with this library for license details. */ +declare(strict_types=1); namespace Opengento\Gdpr\Model\Entity; /** - * Interface EntityValueProcessorInterface * @api */ interface EntityValueProcessorInterface { /** - * Process the entity by passing it a value and its key - * * @param object $entity * @param string $key * @param mixed $value diff --git a/Model/Entity/Metadata.php b/Model/Entity/Metadata.php index f894a81..462ccfe 100644 --- a/Model/Entity/Metadata.php +++ b/Model/Entity/Metadata.php @@ -9,13 +9,10 @@ use Magento\Framework\App\Config\ScopeConfigInterface; -/** - * Class Metadata - */ final class Metadata implements MetadataInterface { /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface + * @var ScopeConfigInterface */ private $scopeConfig; @@ -29,11 +26,6 @@ final class Metadata implements MetadataInterface */ private $scopeType; - /** - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param string $configPath - * @param string $scopeType - */ public function __construct( ScopeConfigInterface $scopeConfig, string $configPath, @@ -44,9 +36,6 @@ public function __construct( $this->scopeType = $scopeType; } - /** - * @inheritdoc - */ public function getAttributes(?string $scopeCode = null): array { return \explode(',', $this->scopeConfig->getValue($this->configPath, $this->scopeType, $scopeCode) ?? ''); diff --git a/Model/Entity/MetadataInterface.php b/Model/Entity/MetadataInterface.php index c311f37..ef95eb2 100644 --- a/Model/Entity/MetadataInterface.php +++ b/Model/Entity/MetadataInterface.php @@ -3,11 +3,11 @@ * Copyright © OpenGento, All rights reserved. * See LICENSE bundled with this library for license details. */ +declare(strict_types=1); namespace Opengento\Gdpr\Model\Entity; /** - * Interface MetadataInterface * @api */ interface MetadataInterface @@ -15,7 +15,7 @@ interface MetadataInterface /** * Retrieve the registered attributes * - * @param string|null $scopeCode + * @param string|null $scopeCode [optional] Current scope will be used. * @return string[] */ public function getAttributes(?string $scopeCode = null): array; diff --git a/Model/Entity/SourceProvider/FilterModifier.php b/Model/Entity/SourceProvider/FilterModifier.php index 5bcf79f..fc13c06 100644 --- a/Model/Entity/SourceProvider/FilterModifier.php +++ b/Model/Entity/SourceProvider/FilterModifier.php @@ -9,10 +9,8 @@ use Magento\Framework\Api\Filter; use Magento\Framework\Data\Collection; +use Magento\Framework\Exception\LocalizedException; -/** - * Class FilterModifier - */ final class FilterModifier implements ModifierInterface { /** @@ -25,10 +23,6 @@ final class FilterModifier implements ModifierInterface */ private $fieldToFilter; - /** - * @param string $filterIdentifier - * @param string $fieldToFilter - */ public function __construct( string $filterIdentifier, string $fieldToFilter @@ -39,7 +33,7 @@ public function __construct( /** * @inheritdoc - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ public function apply(Collection $collection, Filter $filter): void { diff --git a/Model/Entity/SourceProvider/ModifierComposite.php b/Model/Entity/SourceProvider/ModifierComposite.php index 5c77204..ab0e62f 100644 --- a/Model/Entity/SourceProvider/ModifierComposite.php +++ b/Model/Entity/SourceProvider/ModifierComposite.php @@ -17,12 +17,12 @@ final class ModifierComposite implements ModifierInterface { /** - * @var \Opengento\Gdpr\Model\Entity\SourceProvider\ModifierInterface[] + * @var ModifierInterface[] */ private $modifiers; /** - * @param \Opengento\Gdpr\Model\Entity\SourceProvider\ModifierInterface[] $modifiers + * @param ModifierInterface[] $modifiers */ public function __construct( array $modifiers @@ -32,9 +32,6 @@ public function __construct( })(...\array_values($modifiers)); } - /** - * @inheritdoc - */ public function apply(Collection $collection, Filter $filter): void { foreach ($this->modifiers as $modifier) { diff --git a/Model/Entity/SourceProvider/ModifierFactory.php b/Model/Entity/SourceProvider/ModifierFactory.php index 293a981..5d7df4d 100644 --- a/Model/Entity/SourceProvider/ModifierFactory.php +++ b/Model/Entity/SourceProvider/ModifierFactory.php @@ -10,7 +10,6 @@ use Magento\Framework\ObjectManagerInterface; /** - * Class ModifierFactory * @api */ final class ModifierFactory @@ -21,13 +20,13 @@ final class ModifierFactory private $modifiers; /** - * @var \Magento\Framework\ObjectManagerInterface + * @var ObjectManagerInterface */ private $objectManager; /** * @param string[] $modifiers - * @param \Magento\Framework\ObjectManagerInterface $objectManager + * @param ObjectManagerInterface $objectManager */ public function __construct( array $modifiers, @@ -37,12 +36,6 @@ public function __construct( $this->objectManager = $objectManager; } - /** - * Retrieve the source provider modifier by entity type - * - * @param string $entityType - * @return \Opengento\Gdpr\Model\Entity\SourceProvider\ModifierInterface - */ public function get(string $entityType): ModifierInterface { return $this->objectManager->get($this->modifiers[$entityType] ?? $this->modifiers['default']); diff --git a/Model/Entity/SourceProvider/ModifierInterface.php b/Model/Entity/SourceProvider/ModifierInterface.php index 35cfe07..dcf4993 100644 --- a/Model/Entity/SourceProvider/ModifierInterface.php +++ b/Model/Entity/SourceProvider/ModifierInterface.php @@ -11,17 +11,9 @@ use Magento\Framework\Data\Collection; /** - * Interface ModifierInterface * @api */ interface ModifierInterface { - /** - * Apply custom filter on the source provider instance - * - * @param \Magento\Framework\Data\Collection $collection - * @param \Magento\Framework\Api\Filter $filter - * @return void - */ public function apply(Collection $collection, Filter $filter): void; } diff --git a/Model/Entity/SourceProviderFactory.php b/Model/Entity/SourceProviderFactory.php index 473e6e9..bd48af7 100644 --- a/Model/Entity/SourceProviderFactory.php +++ b/Model/Entity/SourceProviderFactory.php @@ -11,7 +11,6 @@ use Magento\Framework\ObjectManagerInterface; /** - * Class SourceProviderFactory * @api */ final class SourceProviderFactory @@ -22,13 +21,13 @@ final class SourceProviderFactory private $sourceProviders; /** - * @var \Magento\Framework\ObjectManagerInterface + * @var ObjectManagerInterface */ private $objectManager; /** * @param string[] $sourceProviders - * @param \Magento\Framework\ObjectManagerInterface $objectManager + * @param ObjectManagerInterface $objectManager */ public function __construct( array $sourceProviders, @@ -38,12 +37,6 @@ public function __construct( $this->objectManager = $objectManager; } - /** - * Create a new source provider by entity type - * - * @param string $entityType - * @return \Magento\Framework\Data\Collection - */ public function create(string $entityType): Collection { if (!isset($this->sourceProviders[$entityType])) { diff --git a/Model/Erase/EraseEntityScheduler.php b/Model/Erase/EraseEntityScheduler.php index 95112ac..6e3e64f 100644 --- a/Model/Erase/EraseEntityScheduler.php +++ b/Model/Erase/EraseEntityScheduler.php @@ -7,36 +7,31 @@ namespace Opengento\Gdpr\Model\Erase; +use Generator; use Magento\Framework\Api\Filter; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Exception\LocalizedException; use Opengento\Gdpr\Api\EraseEntityManagementInterface; use Opengento\Gdpr\Model\Entity\SourceProvider\ModifierFactory; use Opengento\Gdpr\Model\Entity\SourceProviderFactory; -/** - * Class EraseEntityScheduler - */ final class EraseEntityScheduler { /** - * @var \Opengento\Gdpr\Model\Entity\SourceProviderFactory + * @var SourceProviderFactory */ private $sourceProviderFactory; /** - * @var \Opengento\Gdpr\Model\Entity\SourceProvider\ModifierFactory + * @var ModifierFactory */ private $sourceProviderModifierFactory; /** - * @var \Opengento\Gdpr\Api\EraseEntityManagementInterface + * @var EraseEntityManagementInterface */ private $eraseManagement; - /** - * @param \Opengento\Gdpr\Model\Entity\SourceProviderFactory $sourceProviderFactory - * @param \Opengento\Gdpr\Model\Entity\SourceProvider\ModifierFactory $sourceProviderModifierFactory - * @param \Opengento\Gdpr\Api\EraseEntityManagementInterface $eraseManagement - */ public function __construct( SourceProviderFactory $sourceProviderFactory, ModifierFactory $sourceProviderModifierFactory, @@ -48,15 +43,17 @@ public function __construct( } /** - * Schedule filtered entities to erase - * * @param string[] $entityTypes - * @param \Magento\Framework\Api\Filter $filter - * @throws \Magento\Framework\Exception\CouldNotSaveException - * @throws \Magento\Framework\Exception\LocalizedException + * @param Filter $filter + * @throws CouldNotSaveException + * @throws LocalizedException */ public function schedule(array $entityTypes, Filter $filter): void { + /** + * @var string $entityType + * @var string[] $entityIds + */ foreach ($this->collectEntityIds($entityTypes, $filter) as $entityType => $entityIds) { foreach ($entityIds as $entityId) { $this->eraseManagement->create((int) $entityId, $entityType); @@ -65,13 +62,11 @@ public function schedule(array $entityTypes, Filter $filter): void } /** - * Collect available entity ids by entity type - * * @param string[] $entityTypes - * @param \Magento\Framework\Api\Filter $filter - * @return \Generator + * @param Filter $filter + * @return Generator */ - private function collectEntityIds(array $entityTypes, Filter $filter): \Generator + private function collectEntityIds(array $entityTypes, Filter $filter): Generator { foreach ($entityTypes as $entityType) { $source = $this->sourceProviderFactory->create($entityType); diff --git a/Model/Erase/EraseSalesInformation.php b/Model/Erase/EraseSalesInformation.php index a6ab7ac..602b54f 100644 --- a/Model/Erase/EraseSalesInformation.php +++ b/Model/Erase/EraseSalesInformation.php @@ -7,6 +7,8 @@ namespace Opengento\Gdpr\Model\Erase; +use Exception; +use Magento\Framework\Exception\CouldNotSaveException; use Magento\Framework\Stdlib\DateTime; use Opengento\Gdpr\Api\Data\EraseEntityInterface; use Opengento\Gdpr\Api\Data\EraseEntityInterfaceFactory; @@ -14,31 +16,23 @@ use Opengento\Gdpr\Api\EraseSalesInformationInterface; use Opengento\Gdpr\Model\Config; -/** - * Class EraseSalesInformation - */ final class EraseSalesInformation implements EraseSalesInformationInterface { /** - * @var \Opengento\Gdpr\Api\Data\EraseEntityInterfaceFactory + * @var EraseEntityInterfaceFactory */ private $eraseEntityFactory; /** - * @var \Opengento\Gdpr\Api\EraseEntityRepositoryInterface + * @var EraseEntityRepositoryInterface */ private $eraseEntityRepository; /** - * @var \Opengento\Gdpr\Model\Config + * @var Config */ private $config; - /** - * @param \Opengento\Gdpr\Api\Data\EraseEntityInterfaceFactory $eraseEntityFactory - * @param \Opengento\Gdpr\Api\EraseEntityRepositoryInterface $eraseEntityRepository - * @param \Opengento\Gdpr\Model\Config $config - */ public function __construct( EraseEntityInterfaceFactory $eraseEntityFactory, EraseEntityRepositoryInterface $eraseEntityRepository, @@ -51,14 +45,14 @@ public function __construct( /** * @inheritdoc - * @throws \Magento\Framework\Exception\CouldNotSaveException + * @throws CouldNotSaveException */ public function scheduleEraseEntity(int $entityId, string $entityType, \DateTime $lastActive): EraseEntityInterface { $dateTime = \DateTimeImmutable::createFromMutable($lastActive); $scheduleAt = $dateTime->modify('+' . $this->config->getErasureSalesMaxAge() . + 'days'); - /** @var \Opengento\Gdpr\Api\Data\EraseEntityInterface $eraseEntity */ + /** @var EraseEntityInterface $eraseEntity */ $eraseEntity = $this->eraseEntityFactory->create(); $eraseEntity->setEntityId($entityId); $eraseEntity->setEntityType($entityType); @@ -73,7 +67,7 @@ public function scheduleEraseEntity(int $entityId, string $entityType, \DateTime /** * @inheritdoc - * @throws \Exception + * @throws Exception */ public function isAlive(\DateTime $dateTime): bool { diff --git a/Model/Erase/Notifier/EraseEntityManagement.php b/Model/Erase/Notifier/EraseEntityManagement.php index 8def9eb..53d78af 100644 --- a/Model/Erase/Notifier/EraseEntityManagement.php +++ b/Model/Erase/Notifier/EraseEntityManagement.php @@ -12,31 +12,23 @@ use Opengento\Gdpr\Api\EraseEntityRepositoryInterface; use Opengento\Gdpr\Model\Erase\NotifierFactory; -/** - * Class EraseEntityManagement - */ final class EraseEntityManagement implements EraseEntityManagementInterface { /** - * @var \Opengento\Gdpr\Api\EraseEntityRepositoryInterface + * @var EraseEntityRepositoryInterface */ private $eraseRepository; /** - * @var \Opengento\Gdpr\Api\EraseEntityManagementInterface + * @var EraseEntityManagementInterface */ private $eraseManagement; /** - * @var \Opengento\Gdpr\Model\Erase\NotifierFactory + * @var NotifierFactory */ private $eraseNotifierFactory; - /** - * @param \Opengento\Gdpr\Api\EraseEntityRepositoryInterface $eraseRepository - * @param \Opengento\Gdpr\Api\EraseEntityManagementInterface $eraseManagement - * @param \Opengento\Gdpr\Model\Erase\NotifierFactory $eraseNotifierFactory - */ public function __construct( EraseEntityRepositoryInterface $eraseRepository, EraseEntityManagementInterface $eraseManagement, @@ -47,9 +39,6 @@ public function __construct( $this->eraseNotifierFactory = $eraseNotifierFactory; } - /** - * @inheritdoc - */ public function create(int $entityId, string $entityType): EraseEntityInterface { $entity = $this->eraseManagement->create($entityId, $entityType); @@ -58,9 +47,6 @@ public function create(int $entityId, string $entityType): EraseEntityInterface return $entity; } - /** - * @inheritdoc - */ public function process(EraseEntityInterface $entity): EraseEntityInterface { $entity = $this->eraseManagement->process($entity); @@ -69,9 +55,6 @@ public function process(EraseEntityInterface $entity): EraseEntityInterface return $entity; } - /** - * @inheritdoc - */ public function cancel(int $entityId, string $entityType): bool { $entity = $this->eraseRepository->getByEntity($entityId, $entityType); diff --git a/Model/Erase/NotifierFactory.php b/Model/Erase/NotifierFactory.php index 7cb52e0..69d9b13 100644 --- a/Model/Erase/NotifierFactory.php +++ b/Model/Erase/NotifierFactory.php @@ -10,7 +10,6 @@ use Magento\Framework\ObjectManagerInterface; /** - * Class NotifierFactory * @api */ final class NotifierFactory @@ -21,13 +20,13 @@ final class NotifierFactory private $notifiers; /** - * @var \Magento\Framework\ObjectManagerInterface + * @var ObjectManagerInterface */ private $objectManager; /** * @param string[] $notifiers - * @param \Magento\Framework\ObjectManagerInterface $objectManager + * @param ObjectManagerInterface $objectManager */ public function __construct( array $notifiers, @@ -37,13 +36,6 @@ public function __construct( $this->objectManager = $objectManager; } - /** - * Retrieve the notifier instance by action and entity type - * - * @param string $action - * @param string $entityType - * @return \Opengento\Gdpr\Model\Erase\NotifierInterface - */ public function get(string $action, string $entityType): NotifierInterface { if (!isset($this->notifiers[$action][$entityType])) { diff --git a/Model/Erase/NotifierInterface.php b/Model/Erase/NotifierInterface.php index 58fb23c..4765d66 100644 --- a/Model/Erase/NotifierInterface.php +++ b/Model/Erase/NotifierInterface.php @@ -10,16 +10,9 @@ use Opengento\Gdpr\Api\Data\EraseEntityInterface; /** - * Interface NotifierInterface * @api */ interface NotifierInterface { - /** - * Notify the user of the erase action - * - * @param \Opengento\Gdpr\Api\Data\EraseEntityInterface $eraseEntity - * @return void - */ public function notify(EraseEntityInterface $eraseEntity): void; } diff --git a/Model/EraseEntity.php b/Model/EraseEntity.php index eccadd7..55433d2 100755 --- a/Model/EraseEntity.php +++ b/Model/EraseEntity.php @@ -11,152 +11,90 @@ use Opengento\Gdpr\Api\Data\EraseEntityInterface; use Opengento\Gdpr\Model\ResourceModel\EraseEntity as EraseEntityResource; -/** - * Class EraseEntity - */ class EraseEntity extends AbstractExtensibleModel implements EraseEntityInterface { - /** - * @inheritdoc - */ - protected $_eventPrefix = 'opengento_gdpr_erase_entity'; - - /** - * @inheritdoc - */ - protected $_eventObject = 'erase_entity'; - - /** - * @inheritdoc - */ protected function _construct(): void { + $this->_eventPrefix = 'opengento_gdpr_erase_entity'; + $this->_eventObject = 'erase_entity'; $this->_init(EraseEntityResource::class); } - /** - * @inheritdoc - */ public function getEraseId(): int { return (int) $this->getId(); } - /** - * @inheritdoc - */ public function setEraseId(int $eraseId): EraseEntityInterface { return $this->setId($eraseId); } - /** - * @inheritdoc - */ public function getEntityId(): int { return (int) $this->_getData(self::ENTITY_ID); } - /** - * @inheritdoc - */ public function setEntityId($entityId): EraseEntityInterface { return $this->setData(self::ENTITY_ID, $entityId); } - /** - * @inheritdoc - */ public function getEntityType(): string { return (string) $this->_getData(self::ENTITY_TYPE); } - /** - * @inheritdoc - */ public function setEntityType(string $entityType): EraseEntityInterface { return $this->setData(self::ENTITY_TYPE, $entityType); } - /** - * @inheritdoc - */ public function getScheduledAt(): string { return (string) $this->_getData(self::SCHEDULED_AT); } - /** - * @inheritdoc - */ public function setScheduledAt(string $scheduledAt): EraseEntityInterface { return $this->setData(self::SCHEDULED_AT, $scheduledAt); } - /** - * @inheritdoc - */ public function getState(): string { return (string) $this->_getData(self::STATE); } - /** - * @inheritdoc - */ public function setState(string $state): EraseEntityInterface { return $this->setData(self::STATE, $state); } - /** - * @inheritdoc - */ public function getStatus(): string { return (string) $this->_getData(self::STATUS); } - /** - * @inheritdoc - */ public function setStatus(string $status): EraseEntityInterface { return $this->setData(self::STATUS, $status); } - /** - * @inheritdoc - */ public function getMessage(): ?string { return $this->_getData(self::MESSAGE) === null ? null : (string) $this->_getData(self::MESSAGE); } - /** - * @inheritdoc - */ public function setMessage(?string $message): EraseEntityInterface { return $this->setData(self::MESSAGE, $message); } - /** - * @inheritdoc - */ public function getErasedAt(): string { return (string) $this->_getData(self::ERASED_AT); } - /** - * @inheritdoc - */ public function setErasedAt(string $erasedAt): EraseEntityInterface { return $this->setData(self::ERASED_AT, $erasedAt); diff --git a/Model/EraseEntityChecker.php b/Model/EraseEntityChecker.php index a769f7a..d84987a 100644 --- a/Model/EraseEntityChecker.php +++ b/Model/EraseEntityChecker.php @@ -13,25 +13,18 @@ use Opengento\Gdpr\Api\EraseEntityRepositoryInterface; use Opengento\Gdpr\Model\Entity\EntityCheckerFactory; -/** - * Class EraseEntityChecker - */ final class EraseEntityChecker implements EraseEntityCheckerInterface { /** - * @var \Opengento\Gdpr\Api\EraseEntityRepositoryInterface + * @var EraseEntityRepositoryInterface */ private $eraseEntityRepository; /** - * @var \Opengento\Gdpr\Model\Entity\EntityCheckerFactory + * @var EntityCheckerFactory */ private $entityCheckerFactory; - /** - * @param \Opengento\Gdpr\Api\EraseEntityRepositoryInterface $eraseEntityRepository - * @param \Opengento\Gdpr\Model\Entity\EntityCheckerFactory $entityCheckerFactory - */ public function __construct( EraseEntityRepositoryInterface $eraseEntityRepository, EntityCheckerFactory $entityCheckerFactory @@ -40,9 +33,6 @@ public function __construct( $this->entityCheckerFactory = $entityCheckerFactory; } - /** - * @inheritdoc - */ public function exists(int $entityId, string $entityType): bool { try { @@ -52,9 +42,6 @@ public function exists(int $entityId, string $entityType): bool } } - /** - * @inheritdoc - */ public function canCreate(int $entityId, string $entityType): bool { $entityChecker = $this->entityCheckerFactory->get($entityType); @@ -62,9 +49,6 @@ public function canCreate(int $entityId, string $entityType): bool return !$this->exists($entityId, $entityType) && $entityChecker->canErase($entityId); } - /** - * @inheritdoc - */ public function canCancel(int $entityId, string $entityType): bool { try { @@ -77,9 +61,6 @@ public function canCancel(int $entityId, string $entityType): bool && $entity->getStatus() === EraseEntityInterface::STATUS_READY; } - /** - * @inheritdoc - */ public function canProcess(int $entityId, string $entityType): bool { try { diff --git a/Model/EraseEntityManagement.php b/Model/EraseEntityManagement.php index da0cbf5..4eae369 100644 --- a/Model/EraseEntityManagement.php +++ b/Model/EraseEntityManagement.php @@ -7,6 +7,8 @@ namespace Opengento\Gdpr\Model; +use Exception; +use Magento\Framework\Exception\CouldNotSaveException; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Phrase; use Magento\Framework\Stdlib\DateTime as DateTimeFormat; @@ -18,49 +20,38 @@ use Opengento\Gdpr\Api\EraseEntityRepositoryInterface; use Opengento\Gdpr\Service\Erase\ProcessorFactory; -/** - * Class EraseEntityManagement - */ final class EraseEntityManagement implements EraseEntityManagementInterface { /** - * @var \Opengento\Gdpr\Api\Data\EraseEntityInterfaceFactory + * @var EraseEntityInterfaceFactory */ private $eraseEntityFactory; /** - * @var \Opengento\Gdpr\Api\EraseEntityRepositoryInterface + * @var EraseEntityRepositoryInterface */ private $eraseEntityRepository; /** - * @var \Opengento\Gdpr\Api\EraseEntityCheckerInterface + * @var EraseEntityCheckerInterface */ private $eraseEntityChecker; /** - * @var \Opengento\Gdpr\Service\Erase\ProcessorFactory + * @var ProcessorFactory */ private $eraseProcessorFactory; /** - * @var \Opengento\Gdpr\Model\Config + * @var Config */ private $config; /** - * @var \Magento\Framework\Stdlib\DateTime\DateTime + * @var DateTime */ private $localeDate; - /** - * @param \Opengento\Gdpr\Api\Data\EraseEntityInterfaceFactory $eraseEntityFactory - * @param \Opengento\Gdpr\Api\EraseEntityRepositoryInterface $eraseEntityRepository - * @param \Opengento\Gdpr\Api\EraseEntityCheckerInterface $eraseEntityChecker - * @param \Opengento\Gdpr\Service\Erase\ProcessorFactory $eraseProcessorFactory - * @param \Opengento\Gdpr\Model\Config $config - * @param \Magento\Framework\Stdlib\DateTime\DateTime $localeDate - */ public function __construct( EraseEntityInterfaceFactory $eraseEntityFactory, EraseEntityRepositoryInterface $eraseEntityRepository, @@ -77,9 +68,6 @@ public function __construct( $this->localeDate = $localeDate; } - /** - * @inheritdoc - */ public function create(int $entityId, string $entityType): EraseEntityInterface { if (!$this->eraseEntityChecker->canCreate($entityId, $entityType)) { @@ -90,7 +78,7 @@ public function create(int $entityId, string $entityType): EraseEntityInterface ); } - /** @var \Opengento\Gdpr\Api\Data\EraseEntityInterface $entity */ + /** @var EraseEntityInterface $entity */ $entity = $this->eraseEntityFactory->create(); $entity->setEntityId($entityId); $entity->setEntityType($entityType); @@ -101,9 +89,6 @@ public function create(int $entityId, string $entityType): EraseEntityInterface return $this->eraseEntityRepository->save($entity); } - /** - * @inheritdoc - */ public function cancel(int $entityId, string $entityType): bool { if (!$this->eraseEntityChecker->canCancel($entityId, $entityType)) { @@ -115,7 +100,7 @@ public function cancel(int $entityId, string $entityType): bool /** * @inheritdoc - * @throws \Exception + * @throws Exception */ public function process(EraseEntityInterface $entity): EraseEntityInterface { @@ -136,18 +121,16 @@ public function process(EraseEntityInterface $entity): EraseEntityInterface } return $this->fail($entity); - } catch (\Exception $e) { + } catch (Exception $e) { $this->fail($entity, $e->getMessage()); throw $e; } } /** - * Erasure has succeeded - * - * @param \Opengento\Gdpr\Api\Data\EraseEntityInterface $entity - * @return \Opengento\Gdpr\Api\Data\EraseEntityInterface - * @throws \Magento\Framework\Exception\CouldNotSaveException + * @param EraseEntityInterface $entity + * @return EraseEntityInterface + * @throws CouldNotSaveException */ private function success(EraseEntityInterface $entity): EraseEntityInterface { @@ -160,12 +143,10 @@ private function success(EraseEntityInterface $entity): EraseEntityInterface } /** - * Erasure has failed - * - * @param \Opengento\Gdpr\Api\Data\EraseEntityInterface $entity - * @param string|null $message - * @return \Opengento\Gdpr\Api\Data\EraseEntityInterface - * @throws \Magento\Framework\Exception\CouldNotSaveException + * @param EraseEntityInterface $entity + * @param string|null $message [optional] + * @return EraseEntityInterface + * @throws CouldNotSaveException */ private function fail(EraseEntityInterface $entity, ?string $message = null): EraseEntityInterface { @@ -176,11 +157,6 @@ private function fail(EraseEntityInterface $entity, ?string $message = null): Er return $this->eraseEntityRepository->save($entity); } - /** - * Retrieve the final scheduled at date from config - * - * @return string - */ private function retrieveScheduledAt(): string { return $this->localeDate->gmtDate( diff --git a/Model/EraseEntityRepository.php b/Model/EraseEntityRepository.php index 54f9054..75deaa9 100644 --- a/Model/EraseEntityRepository.php +++ b/Model/EraseEntityRepository.php @@ -16,58 +16,50 @@ use Magento\Framework\Phrase; use Opengento\Gdpr\Api\Data\EraseEntityInterface; use Opengento\Gdpr\Api\Data\EraseEntityInterfaceFactory; +use Opengento\Gdpr\Api\Data\EraseEntitySearchResultsInterface; use Opengento\Gdpr\Api\Data\EraseEntitySearchResultsInterfaceFactory; use Opengento\Gdpr\Api\EraseEntityRepositoryInterface; use Opengento\Gdpr\Model\ResourceModel\EraseEntity as EraseEntityResource; +use Opengento\Gdpr\Model\ResourceModel\EraseEntity\Collection; use Opengento\Gdpr\Model\ResourceModel\EraseEntity\CollectionFactory; -/** - * Class EraseEntityRepository - */ final class EraseEntityRepository implements EraseEntityRepositoryInterface { /** - * @var \Opengento\Gdpr\Model\ResourceModel\EraseEntity + * @var EraseEntityResource */ private $eraseEntityResource; /** - * @var \Opengento\Gdpr\Api\Data\EraseEntityInterfaceFactory + * @var EraseEntityInterfaceFactory */ private $eraseCustomerFactory; /** - * @var \Opengento\Gdpr\Model\ResourceModel\EraseEntity\CollectionFactory + * @var CollectionFactory */ private $collectionFactory; /** - * @var \Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface + * @var CollectionProcessorInterface */ private $collectionProcessor; /** - * @var \Opengento\Gdpr\Api\Data\EraseEntitySearchResultsInterfaceFactory + * @var EraseEntitySearchResultsInterfaceFactory */ private $searchResultsFactory; /** - * @var \Opengento\Gdpr\Api\Data\EraseEntityInterface[] + * @var EraseEntityInterface[] */ private $instances = []; /** - * @var \Opengento\Gdpr\Api\Data\EraseEntityInterface[] + * @var EraseEntityInterface[] */ private $instancesByEntity = []; - /** - * @param \Opengento\Gdpr\Model\ResourceModel\EraseEntity $eraseEntityResource - * @param \Opengento\Gdpr\Api\Data\EraseEntityInterfaceFactory $eraseCustomerFactory - * @param \Opengento\Gdpr\Model\ResourceModel\EraseEntity\CollectionFactory $collectionFactory - * @param \Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface $collectionProcessor - * @param \Opengento\Gdpr\Api\Data\EraseEntitySearchResultsInterfaceFactory $searchResultsFactory - */ public function __construct( EraseEntityResource $eraseEntityResource, EraseEntityInterfaceFactory $eraseCustomerFactory, @@ -82,9 +74,6 @@ public function __construct( $this->searchResultsFactory = $searchResultsFactory; } - /** - * @inheritdoc - */ public function save(EraseEntityInterface $entity): EraseEntityInterface { try { @@ -97,13 +86,10 @@ public function save(EraseEntityInterface $entity): EraseEntityInterface return $entity; } - /** - * @inheritdoc - */ public function getById(int $entityId, bool $forceReload = false): EraseEntityInterface { if ($forceReload || !isset($this->instances[$entityId])) { - /** @var \Opengento\Gdpr\Api\Data\EraseEntityInterface $entity */ + /** @var EraseEntityInterface $entity */ $entity = $this->eraseCustomerFactory->create(); $this->eraseEntityResource->load($entity, $entityId, EraseEntityInterface::ID); @@ -117,13 +103,10 @@ public function getById(int $entityId, bool $forceReload = false): EraseEntityIn return $this->instances[$entityId]; } - /** - * @inheritdoc - */ public function getByEntity(int $entityId, string $entityType, bool $forceReload = false): EraseEntityInterface { if ($forceReload || !isset($this->instancesByEntity[$entityId])) { - /** @var \Opengento\Gdpr\Api\Data\EraseEntityInterface $entity */ + /** @var EraseEntityInterface $entity */ $entity = $this->eraseCustomerFactory->create(); $this->eraseEntityResource->load( $entity, @@ -143,17 +126,14 @@ public function getByEntity(int $entityId, string $entityType, bool $forceReload return $this->instancesByEntity[$entityType . '_' . $entityId]; } - /** - * @inheritdoc - */ public function getList(SearchCriteriaInterface $searchCriteria): SearchResultsInterface { - /** @var \Opengento\Gdpr\Model\ResourceModel\EraseEntity\Collection $collection */ + /** @var Collection $collection */ $collection = $this->collectionFactory->create(); $this->collectionProcessor->process($searchCriteria, $collection); - /** @var \Opengento\Gdpr\Api\Data\EraseEntitySearchResultsInterface $searchResults */ + /** @var EraseEntitySearchResultsInterface $searchResults */ $searchResults = $this->searchResultsFactory->create(); $searchResults->setSearchCriteria($searchCriteria); $searchResults->setItems($collection->getItems()); @@ -162,9 +142,6 @@ public function getList(SearchCriteriaInterface $searchCriteria): SearchResultsI return $searchResults; } - /** - * @inheritdoc - */ public function delete(EraseEntityInterface $entity): bool { try { @@ -180,24 +157,12 @@ public function delete(EraseEntityInterface $entity): bool return true; } - /** - * Register the entity into the registry - * - * @param \Opengento\Gdpr\Api\Data\EraseEntityInterface $entity - * @return void - */ private function register(EraseEntityInterface $entity): void { $this->instances[$entity->getEntityId()] = $entity; $this->instancesByEntity[$entity->getEntityType() . '_' . $entity->getEntityId()] = $entity; } - /** - * Remove the entity from the registry - * - * @param \Opengento\Gdpr\Api\Data\EraseEntityInterface $entity - * @return void - */ private function remove(EraseEntityInterface $entity): void { unset( diff --git a/Model/Export/ExportEntityData.php b/Model/Export/ExportEntityData.php index 73480b5..66c9cfc 100644 --- a/Model/Export/ExportEntityData.php +++ b/Model/Export/ExportEntityData.php @@ -7,13 +7,16 @@ namespace Opengento\Gdpr\Model\Export; +use Magento\Framework\Exception\AlreadyExistsException; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Exception\NoSuchEntityException; use Opengento\Gdpr\Api\ExportEntityCheckerInterface; use Opengento\Gdpr\Api\ExportEntityManagementInterface; use Opengento\Gdpr\Api\ExportEntityRepositoryInterface; /** - * Class ExportEntityData + * @api */ final class ExportEntityData { @@ -32,11 +35,6 @@ final class ExportEntityData */ private $exportEntityChecker; - /** - * @param ExportEntityRepositoryInterface $exportEntityRepository - * @param ExportEntityManagementInterface $exportEntityManagement - * @param ExportEntityCheckerInterface $exportEntityChecker - */ public function __construct( ExportEntityRepositoryInterface $exportEntityRepository, ExportEntityManagementInterface $exportEntityManagement, @@ -53,9 +51,9 @@ public function __construct( * @param int $entityId * @param string $entityType * @return string - * @throws \Magento\Framework\Exception\AlreadyExistsException - * @throws \Magento\Framework\Exception\CouldNotSaveException - * @throws \Magento\Framework\Exception\LocalizedException + * @throws AlreadyExistsException + * @throws CouldNotSaveException + * @throws LocalizedException */ public function export(int $entityId, string $entityType): string { diff --git a/Model/Export/Notifier/ExportEntityManagement.php b/Model/Export/Notifier/ExportEntityManagement.php index 2d24147..b26f88f 100644 --- a/Model/Export/Notifier/ExportEntityManagement.php +++ b/Model/Export/Notifier/ExportEntityManagement.php @@ -11,25 +11,18 @@ use Opengento\Gdpr\Api\ExportEntityManagementInterface; use Opengento\Gdpr\Model\Export\NotifierFactory; -/** - * Class ExportEntityManagement - */ final class ExportEntityManagement implements ExportEntityManagementInterface { /** - * @var \Opengento\Gdpr\Api\ExportEntityManagementInterface + * @var ExportEntityManagementInterface */ private $exportManagement; /** - * @var \Opengento\Gdpr\Model\Export\NotifierFactory + * @var NotifierFactory */ private $exportNotifierFactory; - /** - * @param \Opengento\Gdpr\Api\ExportEntityManagementInterface $exportManagement - * @param \Opengento\Gdpr\Model\Export\NotifierFactory $exportNotifierFactory - */ public function __construct( ExportEntityManagementInterface $exportManagement, NotifierFactory $exportNotifierFactory @@ -38,17 +31,11 @@ public function __construct( $this->exportNotifierFactory = $exportNotifierFactory; } - /** - * @inheritdoc - */ public function create(int $entityId, string $entityType, ?string $fileName = null): ExportEntityInterface { return $this->exportManagement->create($entityId, $entityType); } - /** - * @inheritdoc - */ public function export(ExportEntityInterface $exportEntity): string { $export = $this->exportManagement->export($exportEntity); diff --git a/Model/Export/NotifierFactory.php b/Model/Export/NotifierFactory.php index 2d9328c..c920302 100644 --- a/Model/Export/NotifierFactory.php +++ b/Model/Export/NotifierFactory.php @@ -10,7 +10,6 @@ use Magento\Framework\ObjectManagerInterface; /** - * Class NotifierFactory * @api */ final class NotifierFactory @@ -21,13 +20,13 @@ final class NotifierFactory private $notifiers; /** - * @var \Magento\Framework\ObjectManagerInterface + * @var ObjectManagerInterface */ private $objectManager; /** * @param string[] $notifiers - * @param \Magento\Framework\ObjectManagerInterface $objectManager + * @param ObjectManagerInterface $objectManager */ public function __construct( array $notifiers, @@ -37,13 +36,6 @@ public function __construct( $this->objectManager = $objectManager; } - /** - * Retrieve the notifier instance by action and entity type - * - * @param string $action - * @param string $entityType - * @return \Opengento\Gdpr\Model\Export\NotifierInterface - */ public function get(string $action, string $entityType): NotifierInterface { if (!isset($this->notifiers[$action][$entityType])) { diff --git a/Model/Export/NotifierInterface.php b/Model/Export/NotifierInterface.php index 1656ee1..637beec 100644 --- a/Model/Export/NotifierInterface.php +++ b/Model/Export/NotifierInterface.php @@ -10,16 +10,9 @@ use Opengento\Gdpr\Api\Data\ExportEntityInterface; /** - * Interface NotifierInterface * @api */ interface NotifierInterface { - /** - * Notify the user of the export action - * - * @param \Opengento\Gdpr\Api\Data\ExportEntityInterface $exportEntity - * @return void - */ public function notify(ExportEntityInterface $exportEntity): void; } diff --git a/Model/ExportEntity.php b/Model/ExportEntity.php index 8be4d1d..2a6a9bb 100644 --- a/Model/ExportEntity.php +++ b/Model/ExportEntity.php @@ -11,152 +11,90 @@ use Opengento\Gdpr\Api\Data\ExportEntityInterface; use Opengento\Gdpr\Model\ResourceModel\ExportEntity as EraseEntityResource; -/** - * Class ExportEntity - */ class ExportEntity extends AbstractExtensibleModel implements ExportEntityInterface { - /** - * @inheritdoc - */ - protected $_eventPrefix = 'opengento_gdpr_export_entity'; - - /** - * @inheritdoc - */ - protected $_eventObject = 'export_entity'; - - /** - * @inheritdoc - */ protected function _construct(): void { + $this->_eventPrefix = 'opengento_gdpr_export_entity'; + $this->_eventObject = 'export_entity'; $this->_init(EraseEntityResource::class); } - /** - * @inheritdoc - */ public function getExportId(): int { return (int) $this->getId(); } - /** - * @inheritdoc - */ public function setExportId(int $exportId): ExportEntityInterface { return $this->setId($exportId); } - /** - * @inheritdoc - */ public function getEntityId(): int { return (int) $this->_getData(self::ENTITY_ID); } - /** - * @inheritdoc - */ public function setEntityId($entityId): ExportEntityInterface { return $this->setData(self::ENTITY_ID, $entityId); } - /** - * @inheritdoc - */ public function getEntityType(): string { return (string) $this->_getData(self::ENTITY_TYPE); } - /** - * @inheritdoc - */ public function setEntityType(string $entityType): ExportEntityInterface { return $this->setData(self::ENTITY_TYPE, $entityType); } - /** - * @inheritdoc - */ public function getFileName(): string { return (string) $this->_getData(self::FILE_NAME); } - /** - * @inheritdoc - */ public function setFileName(string $filename): ExportEntityInterface { return $this->setData(self::FILE_NAME, $filename); } - /** - * @inheritdoc - */ public function getFilePath(): ?string { return $this->_getData(self::FILE_PATH) === null ? null : (string) $this->_getData(self::FILE_PATH); } - /** - * @inheritdoc - */ public function setFilePath(string $filePath): ExportEntityInterface { return $this->setData(self::FILE_PATH, $filePath); } - /** - * @inheritdoc - */ public function getCreatedAt(): string { return (string) $this->_getData(self::CREATED_AT); } - /** - * @inheritdoc - */ public function setCreatedAt(string $createdAt): ExportEntityInterface { return $this->setData(self::CREATED_AT, $createdAt); } - /** - * @inheritdoc - */ public function getExportedAt(): ?string { return $this->_getData(self::EXPORTED_AT) === null ? null : (string) $this->_getData(self::EXPORTED_AT); } - /** - * @inheritdoc - */ public function setExportedAt(string $exportedAt): ExportEntityInterface { return $this->setData(self::EXPORTED_AT, $exportedAt); } - /** - * @inheritdoc - */ public function getExpiredAt(): string { return (string) $this->_getData(self::EXPIRED_AT); } - /** - * @inheritdoc - */ public function setExpiredAt(string $expiredAt): ExportEntityInterface { return $this->setData(self::EXPIRED_AT, $expiredAt); diff --git a/Model/ExportEntityChecker.php b/Model/ExportEntityChecker.php index caee037..8c82a19 100644 --- a/Model/ExportEntityChecker.php +++ b/Model/ExportEntityChecker.php @@ -11,28 +11,19 @@ use Opengento\Gdpr\Api\ExportEntityCheckerInterface; use Opengento\Gdpr\Api\ExportEntityRepositoryInterface; -/** - * Class ExportEntityChecker - */ final class ExportEntityChecker implements ExportEntityCheckerInterface { /** - * @var \Opengento\Gdpr\Api\ExportEntityRepositoryInterface + * @var ExportEntityRepositoryInterface */ private $exportEntityRepository; - /** - * @param \Opengento\Gdpr\Api\ExportEntityRepositoryInterface $exportEntityRepository - */ public function __construct( ExportEntityRepositoryInterface $exportEntityRepository ) { $this->exportEntityRepository = $exportEntityRepository; } - /** - * @inheritdoc - */ public function exists(int $entityId, string $entityType): bool { try { @@ -42,9 +33,6 @@ public function exists(int $entityId, string $entityType): bool } } - /** - * @inheritdoc - */ public function isExported(int $entityId, string $entityType): bool { try { diff --git a/Model/ExportEntityManagement.php b/Model/ExportEntityManagement.php index 9515b3b..569390e 100644 --- a/Model/ExportEntityManagement.php +++ b/Model/ExportEntityManagement.php @@ -7,8 +7,11 @@ namespace Opengento\Gdpr\Model; +use Exception; use Magento\Framework\Exception\AlreadyExistsException; +use Magento\Framework\Exception\FileSystemException; use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\NotFoundException; use Magento\Framework\Phrase; use Magento\Framework\Stdlib\DateTime; use Opengento\Gdpr\Api\Data\ExportEntityInterface; @@ -22,9 +25,6 @@ use function sha1; use const DIRECTORY_SEPARATOR; -/** - * Class ExportEntityManagement - */ final class ExportEntityManagement implements ExportEntityManagementInterface { /** @@ -43,34 +43,25 @@ final class ExportEntityManagement implements ExportEntityManagementInterface private $exportEntityChecker; /** - * @var \Opengento\Gdpr\Service\Export\ProcessorFactory + * @var ProcessorFactory */ private $exportProcessorFactory; /** - * @var \Opengento\Gdpr\Service\Export\RendererFactory + * @var RendererFactory */ private $exportRendererFactory; /** - * @var \Opengento\Gdpr\Model\Archive\MoveToArchive + * @var MoveToArchive */ private $archive; /** - * @var \Opengento\Gdpr\Model\Config + * @var Config */ private $config; - /** - * @param \Opengento\Gdpr\Api\Data\ExportEntityInterfaceFactory $exportEntityFactory - * @param \Opengento\Gdpr\Api\ExportEntityRepositoryInterface $exportEntityRepository - * @param \Opengento\Gdpr\Api\ExportEntityCheckerInterface $exportEntityChecker - * @param \Opengento\Gdpr\Service\Export\ProcessorFactory $exportProcessorFactory - * @param \Opengento\Gdpr\Service\Export\RendererFactory $exportRendererFactory - * @param \Opengento\Gdpr\Model\Archive\MoveToArchive $archive - * @param \Opengento\Gdpr\Model\Config $config - */ public function __construct( ExportEntityInterfaceFactory $exportEntityFactory, ExportEntityRepositoryInterface $exportEntityRepository, @@ -89,9 +80,6 @@ public function __construct( $this->config = $config; } - /** - * @inheritdoc - */ public function create(int $entityId, string $entityType, ?string $fileName = null): ExportEntityInterface { if ($this->exportEntityChecker->exists($entityId, $entityType)) { @@ -115,9 +103,9 @@ public function create(int $entityId, string $entityType, ?string $fileName = nu /** * @inheritdoc - * @throws \Magento\Framework\Exception\FileSystemException - * @throws \Magento\Framework\Exception\NotFoundException - * @throws \Exception + * @throws FileSystemException + * @throws NotFoundException + * @throws Exception */ public function export(ExportEntityInterface $exportEntity): string { @@ -130,6 +118,7 @@ public function export(ExportEntityInterface $exportEntity): string $fileName . '.zip' ); } + //todo remove files after bundling if (!isset($filePath)) { throw new LocalizedException( @@ -152,12 +141,6 @@ public function export(ExportEntityInterface $exportEntity): string return $filePath; } - /** - * Prepare the file name with sub directory for the export entity - * - * @param ExportEntityInterface $exportEntity - * @return string - */ private function prepareFileName(ExportEntityInterface $exportEntity): string { return 'gdpr' . diff --git a/Model/ExportEntityRepository.php b/Model/ExportEntityRepository.php index dc5272b..e4a7a47 100644 --- a/Model/ExportEntityRepository.php +++ b/Model/ExportEntityRepository.php @@ -13,69 +13,61 @@ use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\Exception\CouldNotDeleteException; use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Exception\FileSystemException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Filesystem; use Magento\Framework\Phrase; use Opengento\Gdpr\Api\Data\ExportEntityInterface; use Opengento\Gdpr\Api\Data\ExportEntityInterfaceFactory; +use Opengento\Gdpr\Api\Data\ExportEntitySearchResultsInterface; use Opengento\Gdpr\Api\Data\ExportEntitySearchResultsInterfaceFactory; use Opengento\Gdpr\Api\ExportEntityRepositoryInterface; use Opengento\Gdpr\Model\ResourceModel\ExportEntity as ExportEntityResource; +use Opengento\Gdpr\Model\ResourceModel\ExportEntity\Collection; use Opengento\Gdpr\Model\ResourceModel\ExportEntity\CollectionFactory; -/** - * Class ExportEntityRepository - */ final class ExportEntityRepository implements ExportEntityRepositoryInterface { /** - * @var \Opengento\Gdpr\Model\ResourceModel\ExportEntity + * @var ExportEntityResource */ private $exportEntityResource; /** - * @var \Opengento\Gdpr\Api\Data\ExportEntityInterfaceFactory + * @var ExportEntityInterfaceFactory */ private $exportCustomerFactory; /** - * @var \Opengento\Gdpr\Model\ResourceModel\ExportEntity\CollectionFactory + * @var CollectionFactory */ private $collectionFactory; /** - * @var \Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface + * @var CollectionProcessorInterface */ private $collectionProcessor; /** - * @var \Opengento\Gdpr\Api\Data\ExportEntitySearchResultsInterfaceFactory + * @var ExportEntitySearchResultsInterfaceFactory */ private $searchResultsFactory; /** - * @var \Opengento\Gdpr\Api\Data\ExportEntityInterface[] + * @var ExportEntityInterface[] */ private $instances = []; /** - * @var \Opengento\Gdpr\Api\Data\ExportEntityInterface[] + * @var ExportEntityInterface[] */ private $instancesByEntity = []; /** - * @var \Magento\Framework\Filesystem + * @var Filesystem */ private $fileSystem; - /** - * @param ExportEntityResource $exportEntityResource - * @param ExportEntityInterfaceFactory $exportCustomerFactory - * @param CollectionFactory $collectionFactory - * @param CollectionProcessorInterface $collectionProcessor - * @param ExportEntitySearchResultsInterfaceFactory $searchResultsFactory - * @param Filesystem $filesystem - */ public function __construct( ExportEntityResource $exportEntityResource, ExportEntityInterfaceFactory $exportCustomerFactory, @@ -92,9 +84,6 @@ public function __construct( $this->searchResultsFactory = $searchResultsFactory; } - /** - * @inheritdoc - */ public function save(ExportEntityInterface $entity): ExportEntityInterface { try { @@ -107,13 +96,10 @@ public function save(ExportEntityInterface $entity): ExportEntityInterface return $entity; } - /** - * @inheritdoc - */ public function getById(int $entityId, bool $forceReload = false): ExportEntityInterface { if ($forceReload || !isset($this->instances[$entityId])) { - /** @var \Opengento\Gdpr\Api\Data\ExportEntityInterface $entity */ + /** @var ExportEntityInterface $entity */ $entity = $this->exportCustomerFactory->create(); $this->exportEntityResource->load($entity, $entityId, ExportEntityInterface::ID); @@ -127,13 +113,10 @@ public function getById(int $entityId, bool $forceReload = false): ExportEntityI return $this->instances[$entityId]; } - /** - * @inheritdoc - */ public function getByEntity(int $entityId, string $entityType, bool $forceReload = false): ExportEntityInterface { if ($forceReload || !isset($this->instancesByEntity[$entityId])) { - /** @var \Opengento\Gdpr\Api\Data\ExportEntityInterface $entity */ + /** @var ExportEntityInterface $entity */ $entity = $this->exportCustomerFactory->create(); $this->exportEntityResource->load( $entity, @@ -153,17 +136,14 @@ public function getByEntity(int $entityId, string $entityType, bool $forceReload return $this->instancesByEntity[$entityType . '_' . $entityId]; } - /** - * @inheritdoc - */ public function getList(SearchCriteriaInterface $searchCriteria): SearchResultsInterface { - /** @var \Opengento\Gdpr\Model\ResourceModel\ExportEntity\Collection $collection */ + /** @var Collection $collection */ $collection = $this->collectionFactory->create(); $this->collectionProcessor->process($searchCriteria, $collection); - /** @var \Opengento\Gdpr\Api\Data\ExportEntitySearchResultsInterface $searchResults */ + /** @var ExportEntitySearchResultsInterface $searchResults */ $searchResults = $this->searchResultsFactory->create(); $searchResults->setSearchCriteria($searchCriteria); $searchResults->setItems($collection->getItems()); @@ -172,13 +152,10 @@ public function getList(SearchCriteriaInterface $searchCriteria): SearchResultsI return $searchResults; } - /** - * @inheritdoc - */ public function delete(ExportEntityInterface $entity): bool { try { - $this->removeFile($entity); + $this->fileSystem->getDirectoryWrite(DirectoryList::TMP)->delete($entity->getFilePath()); $this->remove($entity); $this->exportEntityResource->delete($entity); } catch (\Exception $e) { @@ -191,24 +168,12 @@ public function delete(ExportEntityInterface $entity): bool return true; } - /** - * Register the entity into the registry - * - * @param \Opengento\Gdpr\Api\Data\ExportEntityInterface $entity - * @return void - */ private function register(ExportEntityInterface $entity): void { $this->instances[$entity->getEntityId()] = $entity; $this->instancesByEntity[$entity->getEntityType() . '_' . $entity->getEntityId()] = $entity; } - /** - * Remove the entity from the registry - * - * @param \Opengento\Gdpr\Api\Data\ExportEntityInterface $entity - * @return void - */ private function remove(ExportEntityInterface $entity): void { unset( @@ -216,9 +181,4 @@ private function remove(ExportEntityInterface $entity): void $this->instancesByEntity[$entity->getEntityType() . '_' . $entity->getEntityId()] ); } - - private function removeFile(ExportEntityInterface $entity): void - { - $this->fileSystem->getDirectoryWrite(DirectoryList::TMP)->delete($entity->getFileName()); - } } diff --git a/Model/Newsletter/Subscriber.php b/Model/Newsletter/Subscriber.php index 09deaa4..78a4b91 100644 --- a/Model/Newsletter/Subscriber.php +++ b/Model/Newsletter/Subscriber.php @@ -19,14 +19,10 @@ final class Subscriber { /** - * @var \Magento\Newsletter\Model\Subscriber + * @var SubscriberModel */ private $subscriber; - /** - * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory - * @param array $data [optional] - */ public function __construct( SubscriberFactory $subscriberFactory, array $data = [] @@ -34,19 +30,11 @@ public function __construct( $this->subscriber = $subscriberFactory->create(['data' => $data]); } - /** - * Retrieve the real subscriber subject - * - * @return \Magento\Newsletter\Model\Subscriber - */ public function getRealSubscriber(): SubscriberModel { return $this->subscriber; } - /** - * @inheritdoc - */ public function __call($method, $args) { return $this->subscriber->{$method}(...$args); diff --git a/Model/Notifier/AbstractMailSender.php b/Model/Notifier/AbstractMailSender.php index 8af31b8..178027e 100644 --- a/Model/Notifier/AbstractMailSender.php +++ b/Model/Notifier/AbstractMailSender.php @@ -9,21 +9,20 @@ use Magento\Framework\App\Area; use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\MailException; use Magento\Framework\Mail\Template\TransportBuilder; use Magento\Store\Model\ScopeInterface; -/** - * Class AbstractMailSender - */ abstract class AbstractMailSender { /** - * @var \Magento\Framework\Mail\Template\TransportBuilder + * @var TransportBuilder */ protected $transportBuilder; /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface + * @var ScopeConfigInterface */ private $scopeConfig; @@ -33,8 +32,8 @@ abstract class AbstractMailSender private $configPaths; /** - * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig + * @param TransportBuilder $transportBuilder + * @param ScopeConfigInterface $scopeConfig * @param string[] $configPaths */ public function __construct( @@ -48,14 +47,12 @@ public function __construct( } /** - * Send an email to the recipient - * * @param string $to - * @param string|null $name - * @param int|null $storeId + * @param string|null $name [optional] Specify the to name. + * @param int|null $storeId [optional Current store ID is used by default. * @param array $vars - * @throws \Magento\Framework\Exception\LocalizedException - * @throws \Magento\Framework\Exception\MailException + * @throws LocalizedException + * @throws MailException */ protected function sendMail(string $to, ?string $name = null, ?int $storeId = null, array $vars = []): void { @@ -84,13 +81,11 @@ protected function sendMail(string $to, ?string $name = null, ?int $storeId = nu } /** - * Prepare the mail to send - * * @param string $to - * @param string|null $name - * @param int|null $storeId + * @param string|null $name [optional] Specify the to name. + * @param int|null $storeId [optional Current store ID is used by default. * @param array $vars - * @throws \Magento\Framework\Exception\MailException + * @throws MailException */ protected function prepareMail(string $to, ?string $name = null, ?int $storeId = null, array $vars = []): void { @@ -102,8 +97,6 @@ protected function prepareMail(string $to, ?string $name = null, ?int $storeId = } /** - * Check if the sender is currently available - * * @param int|null $storeId [optional] Retrieves the value by scope. * @return bool */ @@ -117,8 +110,6 @@ protected function isAvailable(?int $storeId = null): bool } /** - * Retrieve the email from - * * @param int|null $storeId [optional] Retrieves the value by scope. * @return string */ @@ -132,8 +123,6 @@ protected function getFrom(?int $storeId = null): string } /** - * Retrieve the email copy to - * * @param int|null $storeId [optional] Retrieves the value by scope. * @return array */ @@ -150,8 +139,6 @@ protected function getCopyTo(?int $storeId = null): array } /** - * Retrieve the email copy method - * * @param int|null $storeId [optional] Retrieves the value by scope. * @return string */ @@ -165,8 +152,6 @@ protected function getCopyMethod(?int $storeId = null): string } /** - * Retrieve the email template identifier - * * @param int|null $storeId [optional] Retrieves the value by scope. * @return string */ diff --git a/Model/Order/Anonymize/Processor/OrderDataProcessor.php b/Model/Order/Anonymize/Processor/OrderDataProcessor.php index 64738a8..c2e464b 100644 --- a/Model/Order/Anonymize/Processor/OrderDataProcessor.php +++ b/Model/Order/Anonymize/Processor/OrderDataProcessor.php @@ -7,43 +7,37 @@ namespace Opengento\Gdpr\Model\Order\Anonymize\Processor; +use Exception; +use Magento\Sales\Api\Data\OrderAddressInterface; use Magento\Sales\Api\OrderAddressRepositoryInterface; use Magento\Sales\Api\OrderRepositoryInterface; +use Magento\Sales\Model\Order; use Opengento\Gdpr\Api\EraseSalesInformationInterface; use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -/** - * Class OrderDataProcessor - */ final class OrderDataProcessor implements ProcessorInterface { /** - * @var \Opengento\Gdpr\Service\Anonymize\AnonymizerInterface + * @var AnonymizerInterface */ private $anonymizer; /** - * @var \Magento\Sales\Api\OrderRepositoryInterface + * @var OrderRepositoryInterface */ private $orderRepository; /** - * @var \Magento\Sales\Api\OrderAddressRepositoryInterface + * @var OrderAddressRepositoryInterface */ private $orderAddressRepository; /** - * @var \Opengento\Gdpr\Api\EraseSalesInformationInterface + * @var EraseSalesInformationInterface */ private $eraseSalesInformation; - /** - * @param \Opengento\Gdpr\Service\Anonymize\AnonymizerInterface $anonymizer - * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository - * @param \Magento\Sales\Api\OrderAddressRepositoryInterface $orderAddressRepository - * @param \Opengento\Gdpr\Api\EraseSalesInformationInterface $eraseSalesInformation - */ public function __construct( AnonymizerInterface $anonymizer, OrderRepositoryInterface $orderRepository, @@ -58,11 +52,11 @@ public function __construct( /** * @inheritdoc - * @throws \Exception + * @throws Exception */ public function execute(int $orderId): bool { - /** @var \Magento\Sales\Model\Order $order */ + /** @var Order $order */ $order = $this->orderRepository->get($orderId); $lastActive = new \DateTime($order->getUpdatedAt()); @@ -74,7 +68,7 @@ public function execute(int $orderId): bool $this->orderRepository->save($this->anonymizer->anonymize($order)); - /** @var \Magento\Sales\Api\Data\OrderAddressInterface|null $orderAddress */ + /** @var OrderAddressInterface|null $orderAddress */ foreach ([$order->getBillingAddress(), $order->getShippingAddress()] as $orderAddress) { if ($orderAddress) { $this->orderAddressRepository->save($this->anonymizer->anonymize($orderAddress)); diff --git a/Model/Order/Anonymize/Processor/QuoteDataProcessor.php b/Model/Order/Anonymize/Processor/QuoteDataProcessor.php index 9dafd89..15b8626 100644 --- a/Model/Order/Anonymize/Processor/QuoteDataProcessor.php +++ b/Model/Order/Anonymize/Processor/QuoteDataProcessor.php @@ -7,44 +7,37 @@ namespace Opengento\Gdpr\Model\Order\Anonymize\Processor; +use Exception; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Quote\Api\CartRepositoryInterface; +use Magento\Quote\Model\Quote; use Magento\Quote\Model\ResourceModel\Quote\Address; use Magento\Sales\Api\OrderRepositoryInterface; use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -/** - * Class QuoteDataProcessor - */ final class QuoteDataProcessor implements ProcessorInterface { /** - * @var \Opengento\Gdpr\Service\Anonymize\AnonymizerInterface + * @var AnonymizerInterface */ private $anonymizer; /** - * @var \Magento\Sales\Api\OrderRepositoryInterface + * @var OrderRepositoryInterface */ private $orderRepository; /** - * @var \Magento\Quote\Api\CartRepositoryInterface + * @var CartRepositoryInterface */ private $quoteRepository; /** - * @var \Magento\Quote\Model\ResourceModel\Quote\Address + * @var Address */ private $quoteAddressResourceModel; - /** - * @param \Opengento\Gdpr\Service\Anonymize\AnonymizerInterface $anonymizer - * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository - * @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository - * @param \Magento\Quote\Model\ResourceModel\Quote\Address $quoteAddressResourceModel - */ public function __construct( AnonymizerInterface $anonymizer, OrderRepositoryInterface $orderRepository, @@ -59,18 +52,18 @@ public function __construct( /** * @inheritdoc - * @throws \Exception + * @throws Exception */ public function execute(int $orderId): bool { try { $order = $this->orderRepository->get($orderId); - /** @var \Magento\Quote\Model\Quote $quote */ + /** @var Quote $quote */ $quote = $this->quoteRepository->get($order->getQuoteId()); $this->quoteRepository->save($this->anonymizer->anonymize($quote)); - /** @var \Magento\Quote\Model\Quote\Address|null $quoteAddress */ + /** @var Quote\Address|null $quoteAddress */ foreach ([$quote->getBillingAddress(), $quote->getShippingAddress()] as $quoteAddress) { if ($quoteAddress) { $this->quoteAddressResourceModel->save($this->anonymizer->anonymize($quoteAddress)); diff --git a/Model/Order/Anonymize/Processor/SubscriberDataProcessor.php b/Model/Order/Anonymize/Processor/SubscriberDataProcessor.php index e6892e9..f7a8272 100644 --- a/Model/Order/Anonymize/Processor/SubscriberDataProcessor.php +++ b/Model/Order/Anonymize/Processor/SubscriberDataProcessor.php @@ -7,43 +7,36 @@ namespace Opengento\Gdpr\Model\Order\Anonymize\Processor; +use Exception; use Magento\Newsletter\Model\ResourceModel\Subscriber as ResourceSubscriber; use Magento\Sales\Api\OrderRepositoryInterface; +use Opengento\Gdpr\Model\Newsletter\Subscriber; use Opengento\Gdpr\Model\Newsletter\SubscriberFactory; use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -/** - * Class SubscriberDataProcessor - */ final class SubscriberDataProcessor implements ProcessorInterface { /** - * @var \Opengento\Gdpr\Service\Anonymize\AnonymizerInterface + * @var AnonymizerInterface */ private $anonymizer; /** - * @var \Magento\Sales\Api\OrderRepositoryInterface + * @var OrderRepositoryInterface */ private $orderRepository; /** - * @var \Opengento\Gdpr\Model\Newsletter\SubscriberFactory + * @var SubscriberFactory */ private $subscriberFactory; /** - * @var \Magento\Newsletter\Model\ResourceModel\Subscriber + * @var ResourceSubscriber */ private $subscriberResourceModel; - /** - * @param \Opengento\Gdpr\Service\Anonymize\AnonymizerInterface $anonymizer - * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository - * @param \Opengento\Gdpr\Model\Newsletter\SubscriberFactory $subscriberFactory - * @param \Magento\Newsletter\Model\ResourceModel\Subscriber $subscriberResourceModel - */ public function __construct( AnonymizerInterface $anonymizer, OrderRepositoryInterface $orderRepository, @@ -58,13 +51,13 @@ public function __construct( /** * @inheritdoc - * @throws \Exception + * @throws Exception */ public function execute(int $orderId): bool { $order = $this->orderRepository->get($orderId); - /** @var \Opengento\Gdpr\Model\Newsletter\Subscriber $subscriber */ + /** @var Subscriber $subscriber */ $subscriber = $this->subscriberFactory->create(); $subscriber->loadByEmail($order->getCustomerEmail()); $this->anonymizer->anonymize($subscriber); diff --git a/Model/Order/Delete/Processor/OrderDataProcessor.php b/Model/Order/Delete/Processor/OrderDataProcessor.php index b50d331..b3a0239 100644 --- a/Model/Order/Delete/Processor/OrderDataProcessor.php +++ b/Model/Order/Delete/Processor/OrderDataProcessor.php @@ -7,29 +7,23 @@ namespace Opengento\Gdpr\Model\Order\Delete\Processor; +use Exception; use Magento\Sales\Api\OrderRepositoryInterface; use Opengento\Gdpr\Api\EraseSalesInformationInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -/** - * Class OrderDataProcessor - */ final class OrderDataProcessor implements ProcessorInterface { /** - * @var \Magento\Sales\Api\OrderRepositoryInterface + * @var OrderRepositoryInterface */ private $orderRepository; /** - * @var \Opengento\Gdpr\Api\EraseSalesInformationInterface + * @var EraseSalesInformationInterface */ private $eraseSalesInformation; - /** - * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository - * @param \Opengento\Gdpr\Api\EraseSalesInformationInterface $eraseSalesInformation - */ public function __construct( OrderRepositoryInterface $orderRepository, EraseSalesInformationInterface $eraseSalesInformation @@ -40,7 +34,7 @@ public function __construct( /** * @inheritdoc - * @throws \Exception + * @throws Exception */ public function execute(int $orderId): bool { diff --git a/Model/Order/Delete/Processor/QuoteDataProcessor.php b/Model/Order/Delete/Processor/QuoteDataProcessor.php index dedb06b..55d7ef1 100644 --- a/Model/Order/Delete/Processor/QuoteDataProcessor.php +++ b/Model/Order/Delete/Processor/QuoteDataProcessor.php @@ -12,25 +12,18 @@ use Magento\Sales\Api\OrderRepositoryInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -/** - * Class QuoteDataProcessor - */ final class QuoteDataProcessor implements ProcessorInterface { /** - * @var \Magento\Sales\Api\OrderRepositoryInterface + * @var OrderRepositoryInterface */ private $orderRepository; /** - * @var \Magento\Quote\Api\CartRepositoryInterface + * @var CartRepositoryInterface */ private $quoteRepository; - /** - * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository - * @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository - */ public function __construct( OrderRepositoryInterface $orderRepository, CartRepositoryInterface $quoteRepository @@ -39,9 +32,6 @@ public function __construct( $this->quoteRepository = $quoteRepository; } - /** - * @inheritdoc - */ public function execute(int $orderId): bool { try { diff --git a/Model/Order/Delete/Processor/SubscriberDataProcessor.php b/Model/Order/Delete/Processor/SubscriberDataProcessor.php index 10f0cd5..00234a9 100644 --- a/Model/Order/Delete/Processor/SubscriberDataProcessor.php +++ b/Model/Order/Delete/Processor/SubscriberDataProcessor.php @@ -7,36 +7,30 @@ namespace Opengento\Gdpr\Model\Order\Delete\Processor; +use Exception; use Magento\Newsletter\Model\ResourceModel\Subscriber as ResourceSubscriber; +use Magento\Newsletter\Model\Subscriber; use Magento\Newsletter\Model\SubscriberFactory; use Magento\Sales\Api\OrderRepositoryInterface; use Opengento\Gdpr\Service\Erase\ProcessorInterface; -/** - * Class SubscriberDataProcessor - */ final class SubscriberDataProcessor implements ProcessorInterface { /** - * @var \Magento\Sales\Api\OrderRepositoryInterface + * @var OrderRepositoryInterface */ private $orderRepository; /** - * @var \Magento\Newsletter\Model\SubscriberFactory + * @var SubscriberFactory */ private $subscriberFactory; /** - * @var \Magento\Newsletter\Model\ResourceModel\Subscriber + * @var ResourceSubscriber */ private $subscriberResourceModel; - /** - * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository - * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory - * @param \Magento\Newsletter\Model\ResourceModel\Subscriber $subscriberResourceModel - */ public function __construct( OrderRepositoryInterface $orderRepository, SubscriberFactory $subscriberFactory, @@ -49,13 +43,13 @@ public function __construct( /** * @inheritdoc - * @throws \Exception + * @throws Exception */ public function execute(int $orderId): bool { $order = $this->orderRepository->get($orderId); - /** @var \Magento\Newsletter\Model\Subscriber $subscriber */ + /** @var Subscriber $subscriber */ $subscriber = $this->subscriberFactory->create(); $subscriber->loadByEmail($order->getCustomerEmail()); $this->subscriberResourceModel->delete($subscriber); diff --git a/Model/Order/Erase/Notifier.php b/Model/Order/Erase/Notifier.php index 50ad48c..0e3a54e 100644 --- a/Model/Order/Erase/Notifier.php +++ b/Model/Order/Erase/Notifier.php @@ -12,24 +12,21 @@ use Opengento\Gdpr\Model\Erase\NotifierInterface; use Opengento\Gdpr\Model\Order\Notifier\SenderInterface; -/** - * Class Notifier - */ final class Notifier implements NotifierInterface { /** - * @var \Opengento\Gdpr\Model\Order\Notifier\SenderInterface[] + * @var SenderInterface[] */ private $senders; /** - * @var \Magento\Sales\Api\OrderRepositoryInterface + * @var OrderRepositoryInterface */ private $orderRepository; /** - * @param \Opengento\Gdpr\Model\Order\Notifier\SenderInterface[] $senders - * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository + * @param SenderInterface[] $senders + * @param OrderRepositoryInterface $orderRepository */ public function __construct( array $senders, @@ -41,9 +38,6 @@ public function __construct( $this->orderRepository = $orderRepository; } - /** - * @inheritdoc - */ public function notify(EraseEntityInterface $eraseEntity): void { $order = $this->orderRepository->get($eraseEntity->getEntityId()); diff --git a/Model/Order/Export/Notifier.php b/Model/Order/Export/Notifier.php index cd4c005..d4efc9d 100644 --- a/Model/Order/Export/Notifier.php +++ b/Model/Order/Export/Notifier.php @@ -12,24 +12,21 @@ use Opengento\Gdpr\Model\Export\NotifierInterface; use Opengento\Gdpr\Model\Order\Notifier\SenderInterface; -/** - * Class Notifier - */ final class Notifier implements NotifierInterface { /** - * @var \Opengento\Gdpr\Model\Order\Notifier\SenderInterface[] + * @var SenderInterface[] */ private $senders; /** - * @var \Magento\Sales\Api\OrderRepositoryInterface + * @var OrderRepositoryInterface */ private $orderRepository; /** - * @param \Opengento\Gdpr\Model\Order\Notifier\SenderInterface[] $senders - * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository + * @param SenderInterface[] $senders + * @param OrderRepositoryInterface $orderRepository */ public function __construct( array $senders, diff --git a/Model/Order/Export/Processor/AbstractDataProcessor.php b/Model/Order/Export/Processor/AbstractDataProcessor.php index df2cfe4..1132a26 100644 --- a/Model/Order/Export/Processor/AbstractDataProcessor.php +++ b/Model/Order/Export/Processor/AbstractDataProcessor.php @@ -12,20 +12,13 @@ use Opengento\Gdpr\Model\Entity\DataCollectorInterface; use Opengento\Gdpr\Service\Export\Processor\AbstractDataProcessor as AbstractExportDataProcessor; -/** - * Class AbstractDataProcessor - */ abstract class AbstractDataProcessor extends AbstractExportDataProcessor { /** - * @var \Magento\Sales\Api\OrderRepositoryInterface + * @var OrderRepositoryInterface */ private $orderRepository; - /** - * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository - * @param \Opengento\Gdpr\Model\Entity\DataCollectorInterface $dataCollector - */ public function __construct( OrderRepositoryInterface $orderRepository, DataCollectorInterface $dataCollector @@ -34,9 +27,6 @@ public function __construct( parent::__construct($dataCollector); } - /** - * @inheritdoc - */ public function execute(int $entityId, array $data): array { return $this->export($this->orderRepository->get($entityId), $data); @@ -46,7 +36,7 @@ public function execute(int $entityId, array $data): array * Execute the export processor for the given order entity. * It allows to retrieve the related data as an array. * - * @param \Magento\Sales\Api\Data\OrderInterface $order + * @param OrderInterface $order * @param array $ata * @return array */ diff --git a/Model/Order/Export/Processor/OrderDataProcessor.php b/Model/Order/Export/Processor/OrderDataProcessor.php index 5a92558..ed51842 100644 --- a/Model/Order/Export/Processor/OrderDataProcessor.php +++ b/Model/Order/Export/Processor/OrderDataProcessor.php @@ -7,23 +7,19 @@ namespace Opengento\Gdpr\Model\Order\Export\Processor; +use Magento\Sales\Api\Data\OrderAddressInterface; use Magento\Sales\Api\Data\OrderInterface; +use Magento\Sales\Model\Order; -/** - * Class OrderDataProcessor - */ final class OrderDataProcessor extends AbstractDataProcessor { - /** - * @inheritdoc - */ protected function export(OrderInterface $order, array $data): array { - /** @var \Magento\Sales\Model\Order $order */ + /** @var Order $order */ $key = 'order_id_' . $order->getEntityId(); $data['orders'][$key] = $this->collectData($order); - /** @var \Magento\Sales\Api\Data\OrderAddressInterface|null $orderAddress */ + /** @var OrderAddressInterface|null $orderAddress */ foreach ([$order->getBillingAddress(), $order->getShippingAddress()] as $orderAddress) { if ($orderAddress) { $data['orders'][$key][$orderAddress->getAddressType()] = $this->collectData($orderAddress); diff --git a/Model/Order/Export/Processor/QuoteDataProcessor.php b/Model/Order/Export/Processor/QuoteDataProcessor.php index 9b108cd..8f1151b 100644 --- a/Model/Order/Export/Processor/QuoteDataProcessor.php +++ b/Model/Order/Export/Processor/QuoteDataProcessor.php @@ -9,25 +9,19 @@ use Magento\Framework\Exception\NoSuchEntityException; use Magento\Quote\Api\CartRepositoryInterface; +use Magento\Quote\Model\Quote; +use Magento\Quote\Model\Quote\Address; use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Api\OrderRepositoryInterface; use Opengento\Gdpr\Model\Entity\DataCollectorInterface; -/** - * Class QuoteDataProcessor - */ final class QuoteDataProcessor extends AbstractDataProcessor { /** - * @var \Magento\Quote\Api\CartRepositoryInterface + * @var CartRepositoryInterface */ private $quoteRepository; - /** - * @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository - * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository - * @param \Opengento\Gdpr\Model\Entity\DataCollectorInterface $dataCollector - */ public function __construct( CartRepositoryInterface $quoteRepository, OrderRepositoryInterface $orderRepository, @@ -37,13 +31,10 @@ public function __construct( parent::__construct($orderRepository, $dataCollector); } - /** - * @inheritdoc - */ protected function export(OrderInterface $order, array $data): array { try { - /** @var \Magento\Quote\Model\Quote $quote */ + /** @var Quote $quote */ $quote = $this->quoteRepository->get($order->getQuoteId()); } catch (NoSuchEntityException $e) { return $data; @@ -52,7 +43,7 @@ protected function export(OrderInterface $order, array $data): array $key = 'quote_id_' . $quote->getId(); $data['quotes'][$key] = $this->collectData($quote); - /** @var \Magento\Quote\Model\Quote\Address|null $quoteAddress */ + /** @var Address|null $quoteAddress */ foreach ([$quote->getBillingAddress(), $quote->getShippingAddress()] as $quoteAddress) { if ($quoteAddress) { $data['quotes'][$key][$quoteAddress->getAddressType()] = $this->collectData($quoteAddress); diff --git a/Model/Order/Export/Processor/SubscriberDataProcessor.php b/Model/Order/Export/Processor/SubscriberDataProcessor.php index df6b1f4..428dbe9 100644 --- a/Model/Order/Export/Processor/SubscriberDataProcessor.php +++ b/Model/Order/Export/Processor/SubscriberDataProcessor.php @@ -10,23 +10,16 @@ use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Api\OrderRepositoryInterface; use Opengento\Gdpr\Model\Entity\DataCollectorInterface; +use Opengento\Gdpr\Model\Newsletter\Subscriber; use Opengento\Gdpr\Model\Newsletter\SubscriberFactory; -/** - * Class SubscriberDataProcessor - */ final class SubscriberDataProcessor extends AbstractDataProcessor { /** - * @var \Opengento\Gdpr\Model\Newsletter\SubscriberFactory + * @var SubscriberFactory */ private $subscriberFactory; - /** - * @param \Opengento\Gdpr\Model\Newsletter\SubscriberFactory $subscriberFactory - * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository - * @param \Opengento\Gdpr\Model\Entity\DataCollectorInterface $dataCollector - */ public function __construct( SubscriberFactory $subscriberFactory, OrderRepositoryInterface $orderRepository, @@ -36,12 +29,9 @@ public function __construct( parent::__construct($orderRepository, $dataCollector); } - /** - * @inheritdoc - */ protected function export(OrderInterface $order, array $data): array { - /** @var \Opengento\Gdpr\Model\Newsletter\Subscriber $subscriber */ + /** @var Subscriber $subscriber */ $subscriber = $this->subscriberFactory->create(); $subscriber->loadByEmail($order->getCustomerEmail()); $data['subscriber'] = $this->collectData($subscriber); diff --git a/Model/Order/Notifier/MailSender.php b/Model/Order/Notifier/MailSender.php index ff833e2..6725bd5 100644 --- a/Model/Order/Notifier/MailSender.php +++ b/Model/Order/Notifier/MailSender.php @@ -7,19 +7,19 @@ namespace Opengento\Gdpr\Model\Order\Notifier; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\MailException; use Magento\Sales\Api\Data\OrderInterface; +use Magento\Sales\Model\Order; use Opengento\Gdpr\Model\Notifier\AbstractMailSender; -/** - * Class MailSender - */ final class MailSender extends AbstractMailSender implements SenderInterface { /** * @inheritdoc - * @param \Magento\Sales\Model\Order $order - * @throws \Magento\Framework\Exception\LocalizedException - * @throws \Magento\Framework\Exception\MailException + * @param Order $order + * @throws LocalizedException + * @throws MailException */ public function send(OrderInterface $order): void { diff --git a/Model/Order/Notifier/SenderInterface.php b/Model/Order/Notifier/SenderInterface.php index 5f5bc28..79941ad 100644 --- a/Model/Order/Notifier/SenderInterface.php +++ b/Model/Order/Notifier/SenderInterface.php @@ -10,16 +10,9 @@ use Magento\Sales\Api\Data\OrderInterface; /** - * Interface SenderInterface * @api */ interface SenderInterface { - /** - * Send a notification to the guest - * - * @param \Magento\Sales\Api\Data\OrderInterface $order - * @return void - */ public function send(OrderInterface $order): void; } diff --git a/Model/Order/OrderChecker.php b/Model/Order/OrderChecker.php index 47099a3..5c2ff08 100644 --- a/Model/Order/OrderChecker.php +++ b/Model/Order/OrderChecker.php @@ -11,25 +11,18 @@ use Opengento\Gdpr\Model\Config; use Opengento\Gdpr\Model\Entity\EntityCheckerInterface; -/** - * Class OrderChecker - */ final class OrderChecker implements EntityCheckerInterface { /** - * @var \Magento\Sales\Api\OrderRepositoryInterface + * @var OrderRepositoryInterface */ private $orderRepository; /** - * @var \Opengento\Gdpr\Model\Config + * @var Config */ private $config; - /** - * @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository - * @param \Opengento\Gdpr\Model\Config $config - */ public function __construct( OrderRepositoryInterface $orderRepository, Config $config @@ -38,9 +31,6 @@ public function __construct( $this->config = $config; } - /** - * @inheritdoc - */ public function canErase(int $orderId): bool { $order = $this->orderRepository->get($orderId); diff --git a/Model/Order/SourceProvider/GuestModifier.php b/Model/Order/SourceProvider/GuestModifier.php index 1ece6d2..c10927d 100644 --- a/Model/Order/SourceProvider/GuestModifier.php +++ b/Model/Order/SourceProvider/GuestModifier.php @@ -9,23 +9,18 @@ use Magento\Framework\Api\Filter; use Magento\Framework\Data\Collection; +use Magento\Framework\Exception\LocalizedException; use Magento\Sales\Api\Data\OrderInterface; use Opengento\Gdpr\Model\Config; use Opengento\Gdpr\Model\Entity\SourceProvider\ModifierInterface; -/** - * Class GuestModifier - */ final class GuestModifier implements ModifierInterface { /** - * @var \Opengento\Gdpr\Model\Config + * @var Config */ private $config; - /** - * @param \Opengento\Gdpr\Model\Config $config - */ public function __construct(Config $config) { $this->config = $config; @@ -33,7 +28,7 @@ public function __construct(Config $config) /** * @inheritdoc - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ public function apply(Collection $collection, Filter $filter): void { diff --git a/Model/ResourceModel/EraseEntity.php b/Model/ResourceModel/EraseEntity.php index 5adc52e..3c1a1ea 100755 --- a/Model/ResourceModel/EraseEntity.php +++ b/Model/ResourceModel/EraseEntity.php @@ -8,32 +8,27 @@ namespace Opengento\Gdpr\Model\ResourceModel; use Magento\Framework\DB\Select; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Model\AbstractModel; use Magento\Framework\Model\ResourceModel\Db\AbstractDb; use Opengento\Gdpr\Api\Data\EraseEntityInterface; -/** - * Class EraseEntity - */ class EraseEntity extends AbstractDb { public const TABLE = 'opengento_gdpr_erase_entity'; - /** - * @inheritdoc - */ protected function _construct(): void { $this->_init(self::TABLE, EraseEntityInterface::ID); } /** - * Retrieve select object for load object data - * + * @inheritDoc * @param string|array $field * @param mixed $value - * @param \Magento\Framework\Model\AbstractModel $object - * @return \Magento\Framework\DB\Select - * @throws \Magento\Framework\Exception\LocalizedException + * @param AbstractModel $object + * @return Select + * @throws LocalizedException */ protected function _getLoadSelect($field, $value, $object): Select { diff --git a/Model/ResourceModel/EraseEntity/Collection.php b/Model/ResourceModel/EraseEntity/Collection.php index 2ed4957..48c9dad 100755 --- a/Model/ResourceModel/EraseEntity/Collection.php +++ b/Model/ResourceModel/EraseEntity/Collection.php @@ -12,14 +12,8 @@ use Opengento\Gdpr\Model\EraseEntity; use Opengento\Gdpr\Model\ResourceModel\EraseEntity as EraseEntityResourceModel; -/** - * Class Collection - */ class Collection extends AbstractCollection { - /** - * @inheritdoc - */ protected function _construct(): void { $this->_init(EraseEntity::class, EraseEntityResourceModel::class); diff --git a/Model/ResourceModel/ExportEntity.php b/Model/ResourceModel/ExportEntity.php index e664554..207b8ca 100755 --- a/Model/ResourceModel/ExportEntity.php +++ b/Model/ResourceModel/ExportEntity.php @@ -8,32 +8,27 @@ namespace Opengento\Gdpr\Model\ResourceModel; use Magento\Framework\DB\Select; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Model\AbstractModel; use Magento\Framework\Model\ResourceModel\Db\AbstractDb; use Opengento\Gdpr\Api\Data\ExportEntityInterface; -/** - * Class ExportEntity - */ class ExportEntity extends AbstractDb { public const TABLE = 'opengento_gdpr_export_entity'; - /** - * @inheritdoc - */ protected function _construct(): void { $this->_init(self::TABLE, ExportEntityInterface::ID); } /** - * Retrieve select object for load object data - * + * @inheritDoc * @param string|array $field * @param mixed $value - * @param \Magento\Framework\Model\AbstractModel $object - * @return \Magento\Framework\DB\Select - * @throws \Magento\Framework\Exception\LocalizedException + * @param AbstractModel $object + * @return Select + * @throws LocalizedException */ protected function _getLoadSelect($field, $value, $object): Select { diff --git a/Model/ResourceModel/ExportEntity/Collection.php b/Model/ResourceModel/ExportEntity/Collection.php index ea5e27f..e9dbc10 100755 --- a/Model/ResourceModel/ExportEntity/Collection.php +++ b/Model/ResourceModel/ExportEntity/Collection.php @@ -12,14 +12,8 @@ use Opengento\Gdpr\Model\ExportEntity; use Opengento\Gdpr\Model\ResourceModel\ExportEntity as ExportEntityResourceModel; -/** - * Class Collection - */ class Collection extends AbstractCollection { - /** - * @inheritdoc - */ protected function _construct(): void { $this->_init(ExportEntity::class, ExportEntityResourceModel::class); diff --git a/ViewModel/Privacy/EraseCustomerDataProvider.php b/ViewModel/Privacy/EraseCustomerDataProvider.php index c943e99..070f726 100644 --- a/ViewModel/Privacy/EraseCustomerDataProvider.php +++ b/ViewModel/Privacy/EraseCustomerDataProvider.php @@ -12,26 +12,18 @@ use Magento\Framework\View\Element\Block\ArgumentInterface; use Opengento\Gdpr\Api\EraseEntityCheckerInterface; -/** - * Class EraseCustomerDataProvider - */ final class EraseCustomerDataProvider extends DataObject implements ArgumentInterface { /** - * @var \Opengento\Gdpr\Api\EraseEntityCheckerInterface + * @var EraseEntityCheckerInterface */ private $eraseEntityChecker; /** - * @var \Magento\Customer\Model\Session + * @var Session */ private $session; - /** - * @param \Opengento\Gdpr\Api\EraseEntityCheckerInterface $eraseEntityChecker - * @param \Magento\Customer\Model\Session $session - * @param array $data - */ public function __construct( EraseEntityCheckerInterface $eraseEntityChecker, Session $session, @@ -42,33 +34,28 @@ public function __construct( parent::__construct($data); } - /** - * Check if the erasure is already planned and could be canceled - * - * @return bool - */ public function canCancel(): bool { if (!$this->hasData('can_cancel')) { - $canCancel = $this->eraseEntityChecker->canCancel((int) $this->session->getCustomerId(), 'customer'); + $canCancel = $this->eraseEntityChecker->canCancel($this->currentCustomerId(), 'customer'); $this->setData('can_cancel', $canCancel); } return (bool) $this->_getData('can_cancel'); } - /** - * Check if the erasure can be planned and processed - * - * @return bool - */ public function canCreate(): bool { if (!$this->hasData('can_create')) { - $canCreate = $this->eraseEntityChecker->canCreate((int) $this->session->getCustomerId(), 'customer'); + $canCreate = $this->eraseEntityChecker->canCreate($this->currentCustomerId(), 'customer'); $this->setData('can_create', $canCreate); } return (bool) $this->_getData('can_create'); } + + private function currentCustomerId(): int + { + return (int) $this->session->getCustomerId(); + } } diff --git a/ViewModel/Privacy/EraseDataProvider.php b/ViewModel/Privacy/EraseDataProvider.php index c1648c8..8988f51 100644 --- a/ViewModel/Privacy/EraseDataProvider.php +++ b/ViewModel/Privacy/EraseDataProvider.php @@ -19,20 +19,15 @@ final class EraseDataProvider extends DataObject implements ArgumentInterface { /** - * @var \Opengento\Gdpr\Model\Config + * @var Config */ private $config; /** - * @var \Magento\Framework\View\Element\BlockFactory + * @var BlockFactory */ private $blockFactory; - /** - * @param \Opengento\Gdpr\Model\Config $config - * @param \Magento\Framework\View\Element\BlockFactory $blockFactory - * @param array $data - */ public function __construct( Config $config, BlockFactory $blockFactory, @@ -43,22 +38,12 @@ public function __construct( parent::__construct($data); } - /** - * Check if the erasure is enabled - * - * @return bool - */ public function isErasureEnabled(): bool { return $this->config->isExportEnabled(); } - /** - * Retrieve the erase information html - * - * @return string - */ - public function getErasureInformation(): string + public function getErasureInformationHtml(): string { if (!$this->hasData('erasure_information')) { $block = $this->blockFactory->createBlock( @@ -71,12 +56,7 @@ public function getErasureInformation(): string return (string) $this->_getData('erasure_information'); } - /** - * Retrieve the anonymize information html - * - * @return string - */ - public function getAnonymizeInformation(): string + public function getAnonymizeInformationHtml(): string { if (!$this->hasData('anonymize_information')) { $block = $this->blockFactory->createBlock( diff --git a/ViewModel/Privacy/EraseGuestDataProvider.php b/ViewModel/Privacy/EraseGuestDataProvider.php index 0031de9..da53d55 100644 --- a/ViewModel/Privacy/EraseGuestDataProvider.php +++ b/ViewModel/Privacy/EraseGuestDataProvider.php @@ -13,26 +13,18 @@ use Magento\Sales\Api\Data\OrderInterface; use Opengento\Gdpr\Api\EraseEntityCheckerInterface; -/** - * Class EraseGuestDataProvider - */ final class EraseGuestDataProvider extends DataObject implements ArgumentInterface { /** - * @var \Opengento\Gdpr\Api\EraseEntityCheckerInterface + * @var EraseEntityCheckerInterface */ private $eraseEntityChecker; /** - * @var \Magento\Framework\Registry + * @var Registry */ private $registry; - /** - * @param \Opengento\Gdpr\Api\EraseEntityCheckerInterface $eraseEntityChecker - * @param \Magento\Framework\Registry $registry - * @param array $data - */ public function __construct( EraseEntityCheckerInterface $eraseEntityChecker, Registry $registry, @@ -43,43 +35,31 @@ public function __construct( parent::__construct($data); } - /** - * Check if the erasure is already planned and could be canceled - * - * @return bool - */ public function canCancel(): bool { if (!$this->hasData('can_cancel')) { - $canCancel = $this->eraseEntityChecker->canCancel((int) $this->resolveOrder()->getEntityId(), 'order'); + $canCancel = $this->eraseEntityChecker->canCancel($this->currentOrderId(), 'order'); $this->setData('can_cancel', $canCancel); } return (bool) $this->_getData('can_cancel'); } - /** - * Check if the erasure can be planned and processed - * - * @return bool - */ public function canCreate(): bool { if (!$this->hasData('can_create')) { - $canCreate = $this->eraseEntityChecker->canCreate((int) $this->resolveOrder()->getEntityId(), 'order'); + $canCreate = $this->eraseEntityChecker->canCreate($this->currentOrderId(), 'order'); $this->setData('can_create', $canCreate); } return (bool) $this->_getData('can_create'); } - /** - * Resolve the current order - * - * @return \Magento\Sales\Api\Data\OrderInterface - */ - private function resolveOrder(): OrderInterface + private function currentOrderId(): int { - return $this->registry->registry('current_order'); + /** @var OrderInterface $order */ + $order = $this->registry->registry('current_order'); + + return (int) $order->getEntityId(); } } diff --git a/ViewModel/Privacy/ExportCustomerDataProvider.php b/ViewModel/Privacy/ExportCustomerDataProvider.php index 5bcfb8c..626c6d4 100644 --- a/ViewModel/Privacy/ExportCustomerDataProvider.php +++ b/ViewModel/Privacy/ExportCustomerDataProvider.php @@ -11,9 +11,6 @@ use Magento\Framework\View\Element\Block\ArgumentInterface; use Opengento\Gdpr\Api\ExportEntityCheckerInterface; -/** - * Class ExportCustomerDataProvider - */ final class ExportCustomerDataProvider implements ArgumentInterface { /** @@ -36,10 +33,6 @@ final class ExportCustomerDataProvider implements ArgumentInterface */ private $isExported; - /** - * @param ExportEntityCheckerInterface $exportEntityChecker - * @param Session $session - */ public function __construct( ExportEntityCheckerInterface $exportEntityChecker, Session $session @@ -48,25 +41,20 @@ public function __construct( $this->session = $session; } - /** - * Check if the export entity exists for the current customer - * - * @return bool - */ public function hasExport(): bool { return $this->isExportEntityExists ?? - $this->isExportEntityExists = $this->exportEntityChecker->exists((int) $this->session->getCustomerId(), 'customer'); + $this->isExportEntityExists = $this->exportEntityChecker->exists($this->currentCustomerId(), 'customer'); } - /** - * Check if the export entity is ready for download - * - * @return bool - */ public function isExported(): bool { return $this->isExported ?? - $this->isExported = $this->exportEntityChecker->isExported((int) $this->session->getCustomerId(), 'customer'); + $this->isExported = $this->exportEntityChecker->isExported($this->currentCustomerId(), 'customer'); + } + + private function currentCustomerId(): int + { + return (int) $this->session->getCustomerId(); } } diff --git a/ViewModel/Privacy/ExportDataProvider.php b/ViewModel/Privacy/ExportDataProvider.php index 78667b1..de511d8 100644 --- a/ViewModel/Privacy/ExportDataProvider.php +++ b/ViewModel/Privacy/ExportDataProvider.php @@ -13,26 +13,18 @@ use Magento\Framework\View\Element\BlockFactory; use Opengento\Gdpr\Model\Config; -/** - * Class ExportDataProvider - */ final class ExportDataProvider extends DataObject implements ArgumentInterface { /** - * @var \Opengento\Gdpr\Model\Config + * @var Config */ private $config; /** - * @var \Magento\Framework\View\Element\BlockFactory + * @var BlockFactory */ private $blockFactory; - /** - * @param \Opengento\Gdpr\Model\Config $config - * @param \Magento\Framework\View\Element\BlockFactory $blockFactory - * @param array $data - */ public function __construct( Config $config, BlockFactory $blockFactory, @@ -43,22 +35,12 @@ public function __construct( parent::__construct($data); } - /** - * Check if the export is enabled - * - * @return bool - */ public function isExportEnabled(): bool { return $this->config->isExportEnabled(); } - /** - * Retrieve the privacy information html - * - * @return string - */ - public function getExportInformation(): string + public function getExportInformationHtml(): string { if (!$this->hasData('export_information')) { $block = $this->blockFactory->createBlock( diff --git a/ViewModel/Privacy/ExportGuestDataProvider.php b/ViewModel/Privacy/ExportGuestDataProvider.php index c40be9f..c46235a 100644 --- a/ViewModel/Privacy/ExportGuestDataProvider.php +++ b/ViewModel/Privacy/ExportGuestDataProvider.php @@ -12,9 +12,6 @@ use Magento\Sales\Api\Data\OrderInterface; use Opengento\Gdpr\Api\ExportEntityCheckerInterface; -/** - * Class ExportGuestDataProvider - */ final class ExportGuestDataProvider implements ArgumentInterface { /** @@ -28,19 +25,15 @@ final class ExportGuestDataProvider implements ArgumentInterface private $registry; /** - * @var null|bool + * @var bool|null */ private $isExportEntityExists; /** - * @var null|bool + * @var bool|null */ private $isExported; - /** - * @param ExportEntityCheckerInterface $exportEntityChecker - * @param Registry $registry - */ public function __construct( ExportEntityCheckerInterface $exportEntityChecker, Registry $registry @@ -49,34 +42,19 @@ public function __construct( $this->registry = $registry; } - /** - * Check if the export entity exists for the current guest - * - * @return bool - */ public function hasExport(): bool { return $this->isExportEntityExists ?? - $this->isExportEntityExists = $this->exportEntityChecker->exists($this->resolveOrderId(), 'order'); + $this->isExportEntityExists = $this->exportEntityChecker->exists($this->currentOrderId(), 'order'); } - /** - * Check if the export entity is ready for download - * - * @return bool - */ public function isExported(): bool { return $this->isExported ?? - $this->isExported = $this->exportEntityChecker->isExported($this->resolveOrderId(), 'order'); + $this->isExported = $this->exportEntityChecker->isExported($this->currentOrderId(), 'order'); } - /** - * Resolve the current order ID - * - * @return int - */ - private function resolveOrderId(): int + private function currentOrderId(): int { /** @var OrderInterface $order */ $order = $this->registry->registry('current_order'); diff --git a/ViewModel/Privacy/SettingsDataProvider.php b/ViewModel/Privacy/SettingsDataProvider.php index 6b39008..b7ef8f3 100644 --- a/ViewModel/Privacy/SettingsDataProvider.php +++ b/ViewModel/Privacy/SettingsDataProvider.php @@ -13,26 +13,18 @@ use Magento\Framework\View\Element\BlockFactory; use Opengento\Gdpr\Model\Config; -/** - * Class SettingsDataProvider - */ final class SettingsDataProvider extends DataObject implements ArgumentInterface { /** - * @var \Opengento\Gdpr\Model\Config + * @var Config */ private $config; /** - * @var \Magento\Framework\View\Element\BlockFactory + * @var BlockFactory */ private $blockFactory; - /** - * @param \Opengento\Gdpr\Model\Config $config - * @param \Magento\Framework\View\Element\BlockFactory $blockFactory - * @param array $data - */ public function __construct( Config $config, BlockFactory $blockFactory, @@ -43,22 +35,12 @@ public function __construct( parent::__construct($data); } - /** - * Check if the module is enabled - * - * @return bool - */ public function isModuleEnabled(): bool { return $this->config->isModuleEnabled(); } - /** - * Retrieve the privacy information html - * - * @return string - */ - public function getPrivacyInformation(): string + public function getPrivacyInformationHtml(): string { if (!$this->hasData('privacy_information')) { $block = $this->blockFactory->createBlock( diff --git a/ViewModel/UrlsDataProvider.php b/ViewModel/UrlsDataProvider.php index baf6933..e073781 100644 --- a/ViewModel/UrlsDataProvider.php +++ b/ViewModel/UrlsDataProvider.php @@ -12,12 +12,9 @@ use Magento\Framework\View\Element\Block\ArgumentInterface; use Opengento\Gdpr\Model\Config; -/** - * Class UrlsDataProvider - */ final class UrlsDataProvider implements ArgumentInterface { - /**#@+ + /** * Routes Path Data */ public const ROUTE_PATH_SETTINGS = 'customer/privacy/settings'; @@ -26,28 +23,22 @@ final class UrlsDataProvider implements ArgumentInterface public const ROUTE_PATH_UNDO_ERASE = 'customer/privacy/undoerase'; public const ROUTE_PATH_EXPORT = 'customer/privacy/export'; public const ROUTE_PATH_DOWNLOAD = 'customer/privacy/download'; - /**#@-*/ /** - * @var \Magento\Framework\UrlInterface + * @var UrlInterface */ private $urlBuilder; /** - * @var \Magento\Cms\Helper\Page + * @var HelperPage */ private $helperPage; /** - * @var \Opengento\Gdpr\Model\Config + * @var Config */ private $config; - /** - * @param \Magento\Framework\UrlInterface $urlBuilder - * @param \Magento\Cms\Helper\Page $helperPage - * @param \Opengento\Gdpr\Model\Config $config - */ public function __construct( UrlInterface $urlBuilder, HelperPage $helperPage, @@ -58,71 +49,36 @@ public function __construct( $this->config = $config; } - /** - * Retrieve the information page url - * - * @return string - */ public function getInformationPageUrl(): string { return (string) $this->helperPage->getPageUrl($this->config->getPrivacyInformationPageId()); } - /** - * Retrieve the settings page url - * - * @return string - */ public function getSettingsPageUrl(): string { return $this->urlBuilder->getUrl(self::ROUTE_PATH_SETTINGS); } - /** - * Retrieve the erase page url - * - * @return string - */ public function getErasePageUrl(): string { return $this->urlBuilder->getUrl(self::ROUTE_PATH_ERASE); } - /** - * Retrieve the erase action url - * - * @return string - */ public function getEraseActionUrl(): string { return $this->urlBuilder->getUrl(self::ROUTE_PATH_ERASE_POST); } - /** - * Retrieve the undo erase action url - * - * @return string - */ public function getUndoEraseActionUrl(): string { return $this->urlBuilder->getUrl(self::ROUTE_PATH_UNDO_ERASE); } - /** - * Retrieve the export action url - * - * @return string - */ public function getExportActionUrl(): string { return $this->urlBuilder->getUrl(self::ROUTE_PATH_EXPORT); } - /** - * Retrieve the download export action url - * - * @return string - */ public function getDownloadActionUrl(): string { return $this->urlBuilder->getUrl(self::ROUTE_PATH_DOWNLOAD); diff --git a/view/frontend/templates/account/privacy/erase.phtml b/view/frontend/templates/account/privacy/erase.phtml index a677e6e..8998138 100755 --- a/view/frontend/templates/account/privacy/erase.phtml +++ b/view/frontend/templates/account/privacy/erase.phtml @@ -19,7 +19,7 @@ $urlsDataProvider = $block->getData('urlsDataProvider');