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 XlsSheetNode |
11
|
|
|
* |
12
|
|
|
* @package MewesK\TwigExcelBundle\Twig\Node |
13
|
|
|
*/ |
14
|
|
|
class XlsSheetNode extends XlsNode |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @param Twig_Node_Expression $index |
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 $index, Twig_Node_Expression $properties, Twig_Node $body, $line = 0, $tag = 'xlssheet') |
24
|
|
|
{ |
25
|
|
|
parent::__construct(['index' => $index, '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('$sheetIndex = ') |
35
|
|
|
->subcompile($this->getNode('index')) |
36
|
|
|
->raw(';' . PHP_EOL) |
37
|
|
|
->write('$sheetProperties = ') |
38
|
|
|
->subcompile($this->getNode('properties')) |
39
|
|
|
->raw(';' . PHP_EOL) |
40
|
|
|
->write('$context[\'phpExcel\']->startSheet($sheetIndex, $sheetProperties);' . PHP_EOL) |
41
|
|
|
->write('unset($sheetIndex, $sheetProperties);' . PHP_EOL); |
42
|
|
|
|
43
|
|
|
if ($this->hasNode('body')) { |
44
|
|
|
$compiler->subcompile($this->getNode('body')); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
$compiler->addDebugInfo($this)->write('$context[\'phpExcel\']->endSheet();' . PHP_EOL); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return string[] |
52
|
|
|
*/ |
53
|
|
|
public function getAllowedParents() |
54
|
|
|
{ |
55
|
|
|
return [ |
56
|
|
|
'MewesK\TwigExcelBundle\Twig\Node\XlsDocumentNode' |
57
|
|
|
]; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return bool |
62
|
|
|
*/ |
63
|
|
|
public function canContainText() |
64
|
|
|
{ |
65
|
|
|
return false; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|