|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. |
|
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace SprykerShop\Yves\CmsContentWidgetChartConnector\Plugin\CmsContentWidget; |
|
9
|
|
|
|
|
10
|
|
|
use Spryker\Shared\CmsContentWidget\Dependency\CmsContentWidgetConfigurationProviderInterface; |
|
11
|
|
|
use Spryker\Yves\CmsContentWidget\Dependency\CmsContentWidgetPluginInterface; |
|
12
|
|
|
use Spryker\Yves\Kernel\AbstractPlugin; |
|
13
|
|
|
use Twig_Environment; |
|
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @method \SprykerShop\Yves\CmsContentWidgetChartConnector\CmsContentWidgetChartConnectorFactory getFactory() |
|
17
|
|
|
*/ |
|
18
|
|
|
class CmsChartContentWidgetPlugin extends AbstractPlugin implements CmsContentWidgetPluginInterface |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @var \Spryker\Shared\CmsContentWidget\Dependency\CmsContentWidgetConfigurationProviderInterface |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $widgetConfiguration; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @param \Spryker\Shared\CmsContentWidget\Dependency\CmsContentWidgetConfigurationProviderInterface $widgetConfiguration |
|
27
|
|
|
*/ |
|
28
|
|
|
public function __construct(CmsContentWidgetConfigurationProviderInterface $widgetConfiguration) |
|
29
|
|
|
{ |
|
30
|
|
|
$this->widgetConfiguration = $widgetConfiguration; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @return callable |
|
35
|
|
|
*/ |
|
36
|
|
|
public function getContentWidgetFunction() |
|
37
|
|
|
{ |
|
38
|
|
|
return [$this, 'contentWidgetFunction']; |
|
|
|
|
|
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param \Twig_Environment $twig |
|
43
|
|
|
* @param array $context |
|
44
|
|
|
* @param string $chartPluginName |
|
45
|
|
|
* @param string|null $dataIdentifier |
|
46
|
|
|
* @param string|null $templateIdentifier |
|
47
|
|
|
* |
|
48
|
|
|
* @return string |
|
49
|
|
|
*/ |
|
50
|
|
|
public function contentWidgetFunction(Twig_Environment $twig, array $context, $chartPluginName, $dataIdentifier = null, $templateIdentifier = null): string |
|
51
|
|
|
{ |
|
52
|
|
|
$widgetContainerRegistry = $this->getFactory()->createWidgetContainerRegistry(); |
|
53
|
|
|
$widgetContainerRegistry->add( |
|
54
|
|
|
$this->getFactory()->createCmsChartContentWidgetCollection() |
|
55
|
|
|
); |
|
56
|
|
|
|
|
57
|
|
|
$result = $twig->render( |
|
58
|
|
|
$this->resolveTemplatePath($templateIdentifier), |
|
59
|
|
|
$this->getContent($context, $chartPluginName, $dataIdentifier) |
|
60
|
|
|
); |
|
61
|
|
|
|
|
62
|
|
|
$widgetContainerRegistry->removeLastAdded(); |
|
63
|
|
|
|
|
64
|
|
|
return $result; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @param null|string $templateIdentifier |
|
69
|
|
|
* |
|
70
|
|
|
* @return string |
|
71
|
|
|
*/ |
|
72
|
|
|
protected function resolveTemplatePath($templateIdentifier = null): string |
|
73
|
|
|
{ |
|
74
|
|
|
if (!$templateIdentifier) { |
|
75
|
|
|
$templateIdentifier = CmsContentWidgetConfigurationProviderInterface::DEFAULT_TEMPLATE_IDENTIFIER; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
return $this->widgetConfiguration->getAvailableTemplates()[$templateIdentifier]; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @param array $context |
|
83
|
|
|
* @param string $chartPluginName |
|
84
|
|
|
* @param string|null $dataIdentifier |
|
85
|
|
|
* |
|
86
|
|
|
* @return array |
|
87
|
|
|
*/ |
|
88
|
|
|
protected function getContent(array $context, $chartPluginName, $dataIdentifier = null): array |
|
|
|
|
|
|
89
|
|
|
{ |
|
90
|
|
|
return [ |
|
91
|
|
|
'chartPluginName' => $chartPluginName, |
|
92
|
|
|
'dataIdentifier' => $dataIdentifier, |
|
93
|
|
|
]; |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths