forked from opengento/magento2-gdpr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExportEntityChecker.php
43 lines (36 loc) · 1.25 KB
/
ExportEntityChecker.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* Copyright © OpenGento, All rights reserved.
* See LICENSE bundled with this library for license details.
*/
declare(strict_types=1);
namespace Opengento\Gdpr\Model;
use Magento\Framework\Exception\NoSuchEntityException;
use Opengento\Gdpr\Api\ExportEntityCheckerInterface;
use Opengento\Gdpr\Api\ExportEntityRepositoryInterface;
final class ExportEntityChecker implements ExportEntityCheckerInterface
{
private ExportEntityRepositoryInterface $exportRepository;
public function __construct(
ExportEntityRepositoryInterface $exportRepository
) {
$this->exportRepository = $exportRepository;
}
public function exists(int $entityId, string $entityType): bool
{
try {
return (bool) $this->exportRepository->getByEntity($entityId, $entityType)->getExportId();
} catch (NoSuchEntityException $e) {
return false;
}
}
public function isExported(int $entityId, string $entityType): bool
{
try {
$entity = $this->exportRepository->getByEntity($entityId, $entityType);
} catch (NoSuchEntityException $e) {
return false;
}
return $entity->getExportedAt() !== null && $entity->getFilePath() !== null;
}
}