|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the core-bundle package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) 2018 WEBEWEB |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace WBW\Bundle\CoreBundle\Twig\Extension; |
|
13
|
|
|
|
|
14
|
|
|
use Twig\Environment; |
|
15
|
|
|
use Twig\Extension\AbstractExtension; |
|
16
|
|
|
use WBW\Bundle\CoreBundle\Twig\Environment\TwigEnvironmentTrait; |
|
17
|
|
|
use WBW\Library\Symfony\Assets\NavigationNodeInterface; |
|
18
|
|
|
use WBW\Library\Types\Helper\StringHelper; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Abstract Twig extension. |
|
22
|
|
|
* |
|
23
|
|
|
* @author webeweb <https://github.com/webeweb> |
|
24
|
|
|
* @package WBW\Bundle\CoreBundle\Twig\Extension |
|
25
|
|
|
* @abstract |
|
26
|
|
|
*/ |
|
27
|
|
|
abstract class AbstractTwigExtension extends AbstractExtension { |
|
28
|
|
|
|
|
29
|
1 |
|
use TwigEnvironmentTrait; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Default content. |
|
33
|
|
|
* |
|
34
|
|
|
* @var string |
|
35
|
|
|
*/ |
|
36
|
|
|
const DEFAULT_CONTENT = " "; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Default href. |
|
40
|
|
|
* |
|
41
|
|
|
* @var string |
|
42
|
|
|
*/ |
|
43
|
|
|
const DEFAULT_HREF = NavigationNodeInterface::DEFAULT_HREF; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Constructor. |
|
47
|
|
|
* |
|
48
|
|
|
* @param Environment $twigEnvironment The Twig environment. |
|
49
|
|
|
*/ |
|
50
|
1620 |
|
public function __construct(Environment $twigEnvironment) { |
|
51
|
1620 |
|
$this->setTwigEnvironment($twigEnvironment); |
|
52
|
1620 |
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Display an HTML element. |
|
56
|
|
|
* |
|
57
|
|
|
* @param string $element The object. |
|
58
|
|
|
* @param string|null $content The content. |
|
59
|
|
|
* @param array $attrs The attributes. |
|
60
|
|
|
* @return string Returns the HTML element. |
|
61
|
|
|
*/ |
|
62
|
440 |
|
public static function coreHtmlElement(string $element, ?string $content, array $attrs = []): string { |
|
63
|
440 |
|
return StringHelper::domNode($element, $content, $attrs); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|