1 | <?php |
||
22 | $this->setFile($file); |
||
23 | $this->setInline($inline); |
||
24 | $this->setParams($params); |
||
25 | } |
||
26 | |||
27 | public function getFile(): ?string |
||
28 | { |
||
29 | return $this->file; |
||
30 | } |
||
31 | |||
32 | public function setFile(?string $file): static |
||
33 | { |
||
34 | $this->file = $file; |
||
35 | |||
36 | return $this; |
||
37 | } |
||
38 | |||
39 | public function getInline(): ?string |
||
40 | { |
||
41 | return $this->inline; |
||
42 | } |
||
43 | |||
44 | public function setInline(?string $inline): static |
||
45 | { |
||
46 | $this->inline = $inline; |
||
47 | |||
48 | return $this; |
||
49 | } |
||
50 | |||
51 | public function getParams(): array |
||
52 | { |
||
53 | return $this->params; |
||
54 | } |
||
55 | |||
56 | public function setParams(array $params): static |
||
57 | { |
||
58 | $this->params = $params; |
||
59 | |||
60 | return $this; |
||
61 | } |
||
62 | |||
63 | public function getType(): string |
||
64 | { |
||
65 | return 'template'; |
||
66 | } |
||
67 | |||
68 | public function toArray(): array |
||
69 | { |
||
70 | $output = array_filter( |
||
71 | [ |
||
72 | 'file' => $this->getFile(), |
||
73 | 'inline' => $this->getInline(), |
||
74 | 'params' => $this->getParams(), |
||
75 | ] |
||
76 | ); |
||
77 | |||
78 | if (!isset($output['file']) && !isset($output['inline'])) { |
||
79 | throw new \InvalidArgumentException( |
||
80 | 'Template query requires that either `inline` or `file` parameters are set' |
||
81 | ); |
||
82 | } |
||
83 | |||
84 | $output = $this->processArray($output); |
||
85 | |||
86 | return [$this->getType() => $output]; |
||
87 | } |
||
88 | } |
||
89 |