Field.php 978 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Files\Template;
  8. /**
  9. * @since 30.0.0
  10. */
  11. class Field implements \JsonSerializable {
  12. private string $index;
  13. private string $content;
  14. private FieldType $type;
  15. private ?string $alias;
  16. private ?int $id;
  17. private ?string $tag;
  18. /**
  19. * @since 30.0.0
  20. */
  21. public function __construct(string $index, string $content, FieldType $type, ?string $alias = null, ?int $id = null, ?string $tag = null) {
  22. $this->index = $index;
  23. $this->alias = $alias;
  24. $this->type = $type;
  25. $this->id = $id;
  26. $this->tag = $tag;
  27. $this->content = $content;
  28. }
  29. /**
  30. * @since 30.0.0
  31. */
  32. public function jsonSerialize(): array {
  33. return [
  34. "index" => $this->index,
  35. "content" => $this->content,
  36. "type" => $this->type->value,
  37. "alias" => $this->alias,
  38. "id" => $this->id,
  39. "tag" => $this->tag,
  40. ];
  41. }
  42. }