TemplateNode.php 914 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Services\Template;
  3. class TemplateNode extends ContentNode
  4. {
  5. public string $name;
  6. public array $parameters = [];
  7. public array $children = [];
  8. public string $raw = '';
  9. public function __construct(string $name, array $parameters = [], array $children = [], string $raw = '', array $position = [])
  10. {
  11. $this->type = 'template';
  12. $this->name = $name;
  13. $this->parameters = $parameters;
  14. $this->children = $children;
  15. $this->raw = $raw;
  16. $this->position = $position;
  17. }
  18. public function toArray(): array
  19. {
  20. return [
  21. 'type' => $this->type,
  22. 'name' => $this->name,
  23. 'parameters' => $this->parameters,
  24. 'children' => array_map(fn($child) => $child->toArray(), $this->children),
  25. 'raw' => $this->raw,
  26. 'position' => $this->position
  27. ];
  28. }
  29. }