1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MewesK\TwigExcelBundle\Twig\Node; |
4
|
|
|
|
5
|
|
|
use Twig_Compiler; |
6
|
|
|
use Twig_Node; |
7
|
|
|
use Twig_Node_Expression; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class XlsFooterNode |
11
|
|
|
* |
12
|
|
|
* @package MewesK\TwigExcelBundle\Twig\Node |
13
|
|
|
*/ |
14
|
|
|
class XlsFooterNode extends Twig_Node implements SyntaxAwareNodeInterface |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @param Twig_Node_Expression $type |
18
|
|
|
* @param Twig_Node_Expression $properties |
19
|
|
|
* @param Twig_Node $body |
20
|
|
|
* @param int $line |
21
|
|
|
* @param string $tag |
22
|
|
|
*/ |
23
|
|
|
public function __construct(Twig_Node_Expression $type, Twig_Node_Expression $properties, Twig_Node $body, $line = 0, $tag = 'xlsfooter') |
24
|
|
|
{ |
25
|
|
|
parent::__construct(['type' => $type, 'properties' => $properties, 'body' => $body], [], $line, $tag); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param Twig_Compiler $compiler |
30
|
|
|
*/ |
31
|
|
|
public function compile(Twig_Compiler $compiler) |
32
|
|
|
{ |
33
|
|
|
$compiler->addDebugInfo($this) |
34
|
|
|
->write('$footerType = ') |
35
|
|
|
->subcompile($this->getNode('type')) |
36
|
|
|
->raw(';' . PHP_EOL) |
37
|
|
|
->write('$footerType = $footerType ? $footerType : \'footer\';' . PHP_EOL) |
38
|
|
|
->write('$footerProperties = ') |
39
|
|
|
->subcompile($this->getNode('properties')) |
40
|
|
|
->raw(';' . PHP_EOL) |
41
|
|
|
->write('$context[\'phpExcel\']->startHeaderFooter($footerType, $footerProperties);' . PHP_EOL) |
42
|
|
|
->write('unset($footerType, $footerProperties);' . PHP_EOL) |
43
|
|
|
->subcompile($this->getNode('body')) |
44
|
|
|
->addDebugInfo($this) |
45
|
|
|
->write('$context[\'phpExcel\']->endHeaderFooter();' . PHP_EOL); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return string[] |
50
|
|
|
*/ |
51
|
|
|
public function getAllowedParents() |
52
|
|
|
{ |
53
|
|
|
return [ |
54
|
|
|
'MewesK\TwigExcelBundle\Twig\Node\XlsSheetNode' |
55
|
|
|
]; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return bool |
60
|
|
|
*/ |
61
|
|
|
public function canContainText() |
62
|
|
|
{ |
63
|
|
|
return false; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|