Field.php 970 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. abstract class Field implements \JsonSerializable {
  12. public ?string $alias = null;
  13. public ?string $tag = null;
  14. public ?int $id = null;
  15. /**
  16. * @since 30.0.0
  17. */
  18. public function __construct(
  19. private string $index,
  20. private FieldType $type,
  21. ) {
  22. }
  23. /**
  24. * @since 30.0.0
  25. */
  26. abstract public function setValue(mixed $value): void;
  27. /**
  28. * @return array{
  29. * index: string,
  30. * type: string,
  31. * alias: ?string,
  32. * tag: ?string,
  33. * id: ?int,
  34. * content?: string,
  35. * checked?: bool,
  36. * }
  37. * @since 30.0.0
  38. */
  39. public function jsonSerialize(): array {
  40. return [
  41. 'index' => $this->index,
  42. 'type' => $this->type->value,
  43. 'alias' => $this->alias,
  44. 'tag' => $this->tag,
  45. 'id' => $this->id,
  46. ];
  47. }
  48. }