Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
TwigFilter.php
001 <?php
002
003 /*
004 * This file is part of Twig.
005 *
006 * (c) Fabien Potencier
007 *
008 * For the full copyright and license information, please view the LICENSE
009 * file that was distributed with this source code.
010 */
011
012 namespace Twig;
013
014 use Twig\Node\Expression\FilterExpression;
015 use Twig\Node\Node;
016
017 /**
018 * Represents a template filter.
019 *
020 * @final since Twig 2.4.0
021 *
022 * @author Fabien Potencier <fabien@symfony.com>
023 *
024 * @see https://twig.symfony.com/doc/templates.html#filters
025 */
026 class TwigFilter
027 {
028 private $name;
029 private $callable;
030 private $options;
031 private $arguments = [];
032
033 /**
034 * Creates a template filter.
035 *
036 * @param string $name Name of this filter
037 * @param callable|null $callable A callable implementing the filter. If null, you need to overwrite the "node_class" option to customize compilation.
038 * @param array $options Options array
039 */
040 public function __construct(string $name, $callable = null, array $options = [])
041 {
042 if (__CLASS__ !== static::class) {
043 @trigger_error('Overriding '.__CLASS__.' is deprecated since Twig 2.4.0 and the class will be final in 3.0.', \E_USER_DEPRECATED);
044 }
045
046 $this->name = $name;
047 $this->callable = $callable;
048 $this->options = array_merge([
049 'needs_environment' => false,
050 'needs_context' => false,
051 'is_variadic' => false,
052 'is_safe' => null,
053 'is_safe_callback' => null,
054 'pre_escape' => null,
055 'preserves_safety' => null,
056 'node_class' => FilterExpression::class,
057 'deprecated' => false,
058 'alternative' => null,
059 ], $options);
060 }
061
062 public function getName()
063 {
064 return $this->name;
065 }
066
067 /**
068 * Returns the callable to execute for this filter.
069 *
070 * @return callable|null
071 */
072 public function getCallable()
073 {
074 return $this->callable;
075 }
076
077 public function getNodeClass()
078 {
079 return $this->options['node_class'];
080 }
081
082 public function setArguments($arguments)
083 {
084 $this->arguments = $arguments;
085 }
086
087 public function getArguments()
088 {
089 return $this->arguments;
090 }
091
092 public function needsEnvironment()
093 {
094 return $this->options['needs_environment'];
095 }
096
097 public function needsContext()
098 {
099 return $this->options['needs_context'];
100 }
101
102 public function getSafe(Node $filterArgs)
103 {
104 if (null !== $this->options['is_safe']) {
105 return $this->options['is_safe'];
106 }
107
108 if (null !== $this->options['is_safe_callback']) {
109 return $this->options['is_safe_callback']($filterArgs);
110 }
111 }
112
113 public function getPreservesSafety()
114 {
115 return $this->options['preserves_safety'];
116 }
117
118 public function getPreEscape()
119 {
120 return $this->options['pre_escape'];
121 }
122
123 public function isVariadic()
124 {
125 return $this->options['is_variadic'];
126 }
127
128 public function isDeprecated()
129 {
130 return (bool) $this->options['deprecated'];
131 }
132
133 public function getDeprecatedVersion()
134 {
135 return $this->options['deprecated'];
136 }
137
138 public function getAlternative()
139 {
140 return $this->options['alternative'];
141 }
142 }
143
144 // For Twig 1.x compatibility
145 class_alias('Twig\TwigFilter', 'Twig_SimpleFilter', false);
146
147 class_alias('Twig\TwigFilter', 'Twig_Filter');
148
149 // Ensure that the aliased name is loaded to keep BC for classes implementing the typehint with the old aliased name.
150 class_exists('Twig\Node\Node');
151