1 | <?php |
||
26 | final class SyliusCollector extends DataCollector |
||
27 | { |
||
28 | /** |
||
29 | * @var ShopperContextInterface |
||
30 | */ |
||
31 | private $shopperContext; |
||
32 | |||
33 | /** |
||
34 | * @param ShopperContextInterface $shopperContext |
||
35 | * @param array $bundles |
||
36 | * @param string $defaultLocaleCode |
||
37 | */ |
||
38 | public function __construct( |
||
39 | ShopperContextInterface $shopperContext, |
||
40 | array $bundles, |
||
41 | string $defaultLocaleCode |
||
42 | ) { |
||
43 | $this->shopperContext = $shopperContext; |
||
44 | |||
45 | $this->data = [ |
||
46 | 'version' => Kernel::VERSION, |
||
47 | 'base_currency_code' => null, |
||
48 | 'currency_code' => null, |
||
49 | 'default_locale_code' => $defaultLocaleCode, |
||
50 | 'locale_code' => null, |
||
51 | 'extensions' => [ |
||
52 | 'SyliusAdminApiBundle' => ['name' => 'API', 'enabled' => false], |
||
53 | 'SyliusAdminBundle' => ['name' => 'Admin', 'enabled' => false], |
||
54 | 'SyliusShopBundle' => ['name' => 'Shop', 'enabled' => false], |
||
55 | ], |
||
56 | ]; |
||
57 | |||
58 | foreach (array_keys($this->data['extensions']) as $bundleName) { |
||
59 | if (isset($bundles[$bundleName])) { |
||
60 | $this->data['extensions'][$bundleName]['enabled'] = true; |
||
61 | } |
||
62 | } |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * @return string |
||
67 | */ |
||
68 | public function getVersion(): string |
||
72 | |||
73 | /** |
||
74 | * @return array |
||
75 | */ |
||
76 | public function getExtensions(): array |
||
80 | |||
81 | /** |
||
82 | * @return string |
||
83 | */ |
||
84 | public function getCurrencyCode(): ?string |
||
88 | |||
89 | /** |
||
90 | * @return string |
||
91 | */ |
||
92 | public function getLocaleCode(): ?string |
||
96 | |||
97 | /** |
||
98 | * @return string |
||
99 | */ |
||
100 | public function getDefaultCurrencyCode(): ?string |
||
104 | |||
105 | /** |
||
106 | * @return string |
||
107 | */ |
||
108 | public function getDefaultLocaleCode(): ?string |
||
112 | |||
113 | /** |
||
114 | * {@inheritdoc} |
||
115 | */ |
||
116 | public function collect(Request $request, Response $response, \Exception $exception = null): void |
||
132 | |||
133 | /** |
||
134 | * {@inheritdoc} |
||
135 | */ |
||
136 | public function reset(): void |
||
142 | |||
143 | /** |
||
144 | * {@inheritdoc} |
||
145 | */ |
||
146 | public function getName(): string |
||
150 | } |
||
151 |