aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/Files/Template/Field.php
blob: 9a847d29ce0c8783327b8d6dc27a4be31277ac1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php

declare(strict_types=1);

/**
 * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

namespace OCP\Files\Template;

/**
 * @since 30.0.0
 */
class Field implements \JsonSerializable {
	private string $index;
	private string $content;
	private FieldType $type;
	private ?string $alias;
	private ?int $id;
	private ?string $tag;

	/**
	 * @since 30.0.0
	 */
	public function __construct(string $index, string $content, FieldType $type, ?string $alias = null, ?int $id = null, ?string $tag = null) {
		$this->index = $index;
		$this->alias = $alias;
		$this->type = $type;
		$this->id = $id;
		$this->tag = $tag;
		$this->content = $content;
	}

	/**
	 * @since 30.0.0
	 */
	public function jsonSerialize(): array {
		return [
			'index' => $this->index,
			'content' => $this->content,
			'type' => $this->type->value,
			'alias' => $this->alias,
			'id' => $this->id,
			'tag' => $this->tag,
		];
	}
}