-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathConfig.php
80 lines (70 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php declare(strict_types=1);
namespace Yireo\LinkPreload\Config;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Module\ModuleListInterface;
/***
* Class Config
* @package Yireo\LinkPreload\Config
*/
class Config
{
/**
* @var ScopeConfigInterface
*/
private $scopeConfig;
/**
* @var ModuleListInterface
*/
private $moduleList;
/**
* Config constructor.
* @param ScopeConfigInterface $scopeConfig
* @param ModuleListInterface $moduleList
*/
public function __construct(
ScopeConfigInterface $scopeConfig,
ModuleListInterface $moduleList
) {
$this->scopeConfig = $scopeConfig;
$this->moduleList = $moduleList;
}
/**
* @return bool
*/
public function enabled(): bool
{
return (bool)$this->scopeConfig->getValue('system/yireo_linkpreload/enabled');
}
/**
* @return bool
*/
public function useCookie(): bool
{
return (bool)$this->scopeConfig->getValue('system/yireo_linkpreload/use_cookie');
}
/**
* @return bool
*/
public function skipImages(): bool
{
if ($this->isModuleEnabled('Yireo_Webp2')) {
return true;
}
return (bool)$this->scopeConfig->getValue('system/yireo_linkpreload/skip_images');
}
/**
* @param string $module
* @return bool
*/
private function isModuleEnabled(string $module): bool
{
return (bool)$this->moduleList->has($module);
}
/**
* @return bool
*/
public function isCriticalEnabled(): bool
{
return (bool)$this->scopeConfig->getValue('dev/css/use_css_critical_path');
}
}