forked from opengento/magento2-gdpr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfig.php
66 lines (57 loc) · 1.7 KB
/
Config.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?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\App\Config\ScopeConfigInterface;
use Magento\Store\Model\ScopeInterface;
use function explode;
final class Config
{
/**
* Scope Config: Data Settings Paths
*/
public const CONFIG_PATH_GENERAL_ENABLED = 'gdpr/general/enabled';
public const CONFIG_PATH_ERASURE_ENABLED = 'gdpr/erasure/enabled';
public const CONFIG_PATH_ERASURE_ALLOWED_STATES = 'gdpr/erasure/allowed_states';
public const CONFIG_PATH_EXPORT_ENABLED = 'gdpr/export/enabled';
private ScopeConfigInterface $scopeConfig;
public function __construct(
ScopeConfigInterface $scopeConfig
) {
$this->scopeConfig = $scopeConfig;
}
public function isModuleEnabled(): bool
{
return $this->scopeConfig->isSetFlag(
self::CONFIG_PATH_GENERAL_ENABLED,
ScopeInterface::SCOPE_STORE
);
}
public function isErasureEnabled(): bool
{
return $this->scopeConfig->isSetFlag(
self::CONFIG_PATH_ERASURE_ENABLED,
ScopeInterface::SCOPE_STORE
);
}
/**
* @return string[]
*/
public function getAllowedStatesToErase(): array
{
return explode(',', (string) $this->scopeConfig->getValue(
self::CONFIG_PATH_ERASURE_ALLOWED_STATES,
ScopeInterface::SCOPE_STORE
));
}
public function isExportEnabled(): bool
{
return $this->scopeConfig->isSetFlag(
self::CONFIG_PATH_EXPORT_ENABLED,
ScopeInterface::SCOPE_STORE
);
}
}