summaryrefslogtreecommitdiff
path: root/tests/UnitTests/__shared/PHPunitplugins/compiler.getparamsshort.php
blob: 9fb80a894741da8de52c18fde873f3e375454745 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/**
 * Smarty plugin params
 *


 */

use Smarty\Compile\Base;

/**
 * Smarty {getparams}
 *
 * @param array  $params   parameter array
 * @param object $template template object
 *
 * @return string
 */
class smarty_compiler_getparamsshort extends Base
{
    /**
     * Attribute definition: Overwrites base class.
     *
     * @var array
     * @see Base
     */
    public $required_attributes = array();

    /**
     * Attribute definition: Overwrites base class.
     *
     * @var array
     * @see Base
     */
    public $optional_attributes = array('_any');
    /**
     * Attribute definition: Overwrites base class.
     *
     * @var array
     * @see Base
     */
    public $shorttag_order = array('s1', 's2', 's3');

    public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
	{
        $_attr = $this->getAttributes($compiler, $args);
        $output = '<?php echo "array(';
             foreach ($_attr as $key => $value) {
                $output .= "'{$key}'=>\" . ";
                $output .= is_string($value) ? "({$value})" : ("'" . var_export($value, true). "'");
                $output .= ' . ",';

            }

        $output .= ")\";?>\n";
        return $output;
    }
}