Dotclear

source: inc/libs/Twig/Function.php @ 1149:1657e862089c

Revision 1149:1657e862089c, 1.6 KB checked in by dsls, 12 years ago (diff)

Fixed unix case-sensitive twig directory

Line 
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) 2010 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/**
13 * Represents a template function.
14 *
15 * Use Twig_SimpleFunction instead.
16 *
17 * @package    twig
18 * @author     Fabien Potencier <fabien@symfony.com>
19 * @deprecated since 1.12 (to be removed in 2.0)
20 */
21abstract class Twig_Function implements Twig_FunctionInterface, Twig_FunctionCallableInterface
22{
23    protected $options;
24    protected $arguments = array();
25
26    public function __construct(array $options = array())
27    {
28        $this->options = array_merge(array(
29            'needs_environment' => false,
30            'needs_context'     => false,
31            'callable'          => null,
32        ), $options);
33    }
34
35    public function setArguments($arguments)
36    {
37        $this->arguments = $arguments;
38    }
39
40    public function getArguments()
41    {
42        return $this->arguments;
43    }
44
45    public function needsEnvironment()
46    {
47        return $this->options['needs_environment'];
48    }
49
50    public function needsContext()
51    {
52        return $this->options['needs_context'];
53    }
54
55    public function getSafe(Twig_Node $functionArgs)
56    {
57        if (isset($this->options['is_safe'])) {
58            return $this->options['is_safe'];
59        }
60
61        if (isset($this->options['is_safe_callback'])) {
62            return call_user_func($this->options['is_safe_callback'], $functionArgs);
63        }
64
65        return array();
66    }
67
68    public function getCallable()
69    {
70        return $this->options['callable'];
71    }
72}
Note: See TracBrowser for help on using the repository browser.

Sites map