1
|
<?php
|
2
|
|
3
|
/*
|
4
|
* This file is part of Twig.
|
5
|
*
|
6
|
* (c) 2009 Fabien Potencier
|
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
|
@trigger_error('The Twig_Filter class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFilter instead.', E_USER_DEPRECATED);
|
13
|
|
14
|
/**
|
15
|
* Represents a template filter.
|
16
|
*
|
17
|
* Use Twig_SimpleFilter instead.
|
18
|
*
|
19
|
* @author Fabien Potencier <fabien@symfony.com>
|
20
|
*
|
21
|
* @deprecated since 1.12 (to be removed in 2.0)
|
22
|
*/
|
23
|
abstract class Twig_Filter implements Twig_FilterInterface, Twig_FilterCallableInterface
|
24
|
{
|
25
|
protected $options;
|
26
|
protected $arguments = array();
|
27
|
|
28
|
public function __construct(array $options = array())
|
29
|
{
|
30
|
$this->options = array_merge(array(
|
31
|
'needs_environment' => false,
|
32
|
'needs_context' => false,
|
33
|
'pre_escape' => null,
|
34
|
'preserves_safety' => null,
|
35
|
'callable' => null,
|
36
|
), $options);
|
37
|
}
|
38
|
|
39
|
public function setArguments($arguments)
|
40
|
{
|
41
|
$this->arguments = $arguments;
|
42
|
}
|
43
|
|
44
|
public function getArguments()
|
45
|
{
|
46
|
return $this->arguments;
|
47
|
}
|
48
|
|
49
|
public function needsEnvironment()
|
50
|
{
|
51
|
return $this->options['needs_environment'];
|
52
|
}
|
53
|
|
54
|
public function needsContext()
|
55
|
{
|
56
|
return $this->options['needs_context'];
|
57
|
}
|
58
|
|
59
|
public function getSafe(Twig_Node $filterArgs)
|
60
|
{
|
61
|
if (isset($this->options['is_safe'])) {
|
62
|
return $this->options['is_safe'];
|
63
|
}
|
64
|
|
65
|
if (isset($this->options['is_safe_callback'])) {
|
66
|
return call_user_func($this->options['is_safe_callback'], $filterArgs);
|
67
|
}
|
68
|
}
|
69
|
|
70
|
public function getPreservesSafety()
|
71
|
{
|
72
|
return $this->options['preserves_safety'];
|
73
|
}
|
74
|
|
75
|
public function getPreEscape()
|
76
|
{
|
77
|
return $this->options['pre_escape'];
|
78
|
}
|
79
|
|
80
|
public function getCallable()
|
81
|
{
|
82
|
return $this->options['callable'];
|
83
|
}
|
84
|
}
|