1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Shopware\Storefront\Event; |
4
|
|
|
|
5
|
|
|
use Shopware\Core\Framework\Context; |
6
|
|
|
use Shopware\Core\Framework\Event\NestedEvent; |
7
|
|
|
use Shopware\Core\Framework\Event\ShopwareSalesChannelEvent; |
8
|
|
|
use Shopware\Core\Framework\Log\Package; |
9
|
|
|
use Shopware\Core\System\SalesChannel\SalesChannelContext; |
10
|
|
|
use Symfony\Component\HttpFoundation\Request; |
11
|
|
|
|
12
|
|
|
#[Package('storefront')] |
13
|
|
|
class StorefrontRenderEvent extends NestedEvent implements ShopwareSalesChannelEvent |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var string |
17
|
|
|
*/ |
18
|
|
|
protected $view; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var array<string, mixed> |
22
|
|
|
*/ |
23
|
|
|
protected $parameters; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var Request |
27
|
|
|
*/ |
28
|
|
|
protected $request; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var SalesChannelContext |
32
|
|
|
*/ |
33
|
|
|
protected $context; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param array<string, mixed> $parameters |
37
|
|
|
*/ |
38
|
|
|
public function __construct( |
39
|
|
|
string $view, |
40
|
|
|
array $parameters, |
41
|
|
|
Request $request, |
42
|
|
|
SalesChannelContext $context |
43
|
|
|
) { |
44
|
|
|
$this->view = $view; |
45
|
|
|
$this->parameters = array_merge(['context' => $context], $parameters); |
46
|
|
|
$this->request = $request; |
47
|
|
|
$this->context = $context; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function getSalesChannelContext(): SalesChannelContext |
51
|
|
|
{ |
52
|
|
|
return $this->context; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function setSalesChannelContext(SalesChannelContext $context): void |
56
|
|
|
{ |
57
|
|
|
$this->context = $context; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function getContext(): Context |
61
|
|
|
{ |
62
|
|
|
return $this->context->getContext(); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getView(): string |
66
|
|
|
{ |
67
|
|
|
return $this->view; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return array<string, mixed> |
72
|
|
|
*/ |
73
|
|
|
public function getParameters(): array |
74
|
|
|
{ |
75
|
|
|
return $this->parameters; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function getRequest(): Request |
79
|
|
|
{ |
80
|
|
|
return $this->request; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param mixed $value |
85
|
|
|
*/ |
86
|
|
|
public function setParameter(string $key, $value): void |
87
|
|
|
{ |
88
|
|
|
$this->parameters[$key] = $value; |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|