-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCoreVariables.php
executable file
·61 lines (52 loc) · 1.48 KB
/
CoreVariables.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
<?php
/**
* Copyright © MageSpecialist - Skeeller srl. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace MSP\NotifierTemplate\Model\VariablesDecorator;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\HTTP\PhpEnvironment\RemoteAddress;
use Magento\Store\Model\StoreManagerInterface;
class CoreVariables implements VariablesDecoratorInterface
{
const VARIABLE_STORE = '_store';
const VARIABLE_IP = '_ip';
const VARIABLE_REQUEST = '_request';
/**
* @var RemoteAddress
*/
private $remoteAddress;
/**
* @var RequestInterface
*/
private $request;
/**
* @var StoreManagerInterface
*/
private $storeManager;
/**
* CoreDecorator constructor.
* @param RemoteAddress $remoteAddress
* @param RequestInterface $request
* @param StoreManagerInterface $storeManager
*/
public function __construct(
RemoteAddress $remoteAddress,
RequestInterface $request,
StoreManagerInterface $storeManager
) {
$this->remoteAddress = $remoteAddress;
$this->request = $request;
$this->storeManager = $storeManager;
}
/**
* @inheritdoc
*/
public function execute(array &$data)
{
$data[self::VARIABLE_STORE] = $this->storeManager->getStore();
$data[self::VARIABLE_IP] = $this->remoteAddress->getRemoteAddress();
$data[self::VARIABLE_REQUEST] = $this->request;
}
}