|
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 SprykerEco\Yves\ShopUiCompatibility\Twig\Node; |
|
9
|
|
|
|
|
10
|
|
|
use Twig_Compiler; |
|
|
|
|
|
|
11
|
|
|
use Twig_Node; |
|
|
|
|
|
|
12
|
|
|
use Twig_Node_Expression; |
|
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
class ShopUiCompatibilityDefineTwigNode extends Twig_Node |
|
15
|
|
|
{ |
|
16
|
|
|
public const REQUIRED_VALUE = '___REQUIRED___'; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @param string $name |
|
20
|
|
|
* @param \Twig_Node_Expression $value |
|
21
|
|
|
* @param int $line |
|
22
|
|
|
* @param string|null $tag |
|
23
|
|
|
*/ |
|
24
|
|
|
public function __construct(string $name, Twig_Node_Expression $value, int $line, ?string $tag = null) |
|
25
|
|
|
{ |
|
26
|
|
|
parent::__construct(['value' => $value], ['name' => $name], $line, $tag); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @param \Twig_Compiler $compiler |
|
31
|
|
|
* |
|
32
|
|
|
* @return void |
|
33
|
|
|
*/ |
|
34
|
|
|
public function compile(Twig_Compiler $compiler): void |
|
35
|
|
|
{ |
|
36
|
|
|
$key = "'" . $this->getAttribute('name') . "'"; |
|
37
|
|
|
$requiredValue = "'" . self::REQUIRED_VALUE . "'"; |
|
38
|
|
|
|
|
39
|
|
|
$compiler |
|
40
|
|
|
->addDebugInfo($this) |
|
41
|
|
|
->raw('if (!array_key_exists(' . $key . ', $context)) {') |
|
42
|
|
|
->raw('$context[' . $key . '] = [];') |
|
43
|
|
|
->raw('}') |
|
44
|
|
|
->raw('$context[' . $key . '] = array_replace_recursive(') |
|
45
|
|
|
->subcompile($this->getNode('value')) |
|
46
|
|
|
->raw(', $context[' . $key . ']);') |
|
47
|
|
|
->raw('array_walk_recursive($context[' . $key . '], function($value, $key) {') |
|
48
|
|
|
->raw('if ($value === ' . $requiredValue . ') {') |
|
49
|
|
|
->raw('throw new Twig_Error_Runtime(\'required <em>' . $this->getAttribute('name') . '</em> property "\'.$key.\'" is not defined for "' . $this->getTemplateName() . ':' . $this->getTemplateLine() . '"\'); }') |
|
50
|
|
|
->raw('});'); |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|
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