|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (c) 2013-2017 |
|
4
|
|
|
* |
|
5
|
|
|
* @category Library |
|
6
|
|
|
* @package Dwoo\Plugins\Functions |
|
7
|
|
|
* @author Jordi Boggiano <[email protected]> |
|
8
|
|
|
* @author David Sanchez <[email protected]> |
|
9
|
|
|
* @copyright 2008-2013 Jordi Boggiano |
|
10
|
|
|
* @copyright 2013-2017 David Sanchez |
|
11
|
|
|
* @license http://dwoo.org/LICENSE Modified BSD License |
|
12
|
|
|
* @version 1.3.2 |
|
13
|
|
|
* @date 2017-01-06 |
|
14
|
|
|
* @link http://dwoo.org/ |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
namespace Dwoo\Plugins\Functions; |
|
18
|
|
|
|
|
19
|
|
|
use Dwoo\Compiler; |
|
20
|
|
|
use Dwoo\ICompilable; |
|
21
|
|
|
use Dwoo\Plugin; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Inserts another template into the current one |
|
25
|
|
|
* <pre> |
|
26
|
|
|
* * file : the resource name of the template |
|
27
|
|
|
* * cache_time : cache length in seconds |
|
28
|
|
|
* * cache_id : cache identifier for the included template |
|
29
|
|
|
* * compile_id : compilation identifier for the included template |
|
30
|
|
|
* * data : data to feed into the included template, it can be any array and will default to $_root (the current data) |
|
31
|
|
|
* * assign : if set, the output of the included template will be saved in this variable instead of being output |
|
32
|
|
|
* * rest : any additional parameter/value provided will be added to the data array |
|
33
|
|
|
* </pre> |
|
34
|
|
|
* This software is provided 'as-is', without any express or implied warranty. |
|
35
|
|
|
* In no event will the authors be held liable for any damages arising from the use of this software. |
|
36
|
|
|
*/ |
|
37
|
|
|
class PluginReturn extends Plugin implements ICompilable |
|
38
|
|
|
{ |
|
39
|
|
|
/** |
|
40
|
|
|
* @param Compiler $compiler |
|
41
|
|
|
* @param array $rest |
|
42
|
|
|
* |
|
43
|
|
|
* @return string |
|
44
|
|
|
*/ |
|
45
|
|
|
public static function compile(Compiler $compiler, array $rest = array()) |
|
|
|
|
|
|
46
|
|
|
{ |
|
47
|
|
|
$out = array(); |
|
48
|
|
|
foreach ($rest as $var => $val) { |
|
49
|
|
|
$out[] = '$this->setReturnValue(' . var_export($var, true) . ', ' . $val . ')'; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
return '(' . implode('.', $out) . ')'; |
|
53
|
|
|
} |
|
54
|
|
|
} |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.