|
6 | 6 |
|
7 | 7 | use Symfony\Component\Validator\Constraints as Assert; |
8 | 8 | use Undabot\SymfonyJsonApi\Model\ApiModel; |
9 | | -use Undabot\SymfonyJsonApi\Model\Resource\Annotation\Attribute; |
10 | | -use Undabot\SymfonyJsonApi\Model\Resource\Annotation\ToMany; |
11 | | -use Undabot\SymfonyJsonApi\Model\Resource\Annotation\ToOne; |
| 9 | +use Undabot\SymfonyJsonApi\Model\Resource\Attribute\Attribute; |
| 10 | +use Undabot\SymfonyJsonApi\Model\Resource\Attribute\ToMany; |
| 11 | +use Undabot\SymfonyJsonApi\Model\Resource\Attribute\ToOne; |
12 | 12 | use Undabot\SymfonyJsonApi\Service\Resource\Validation\Constraint\ResourceType; |
13 | 13 |
|
14 | | -/** @ResourceType(type="article") */ |
| 14 | +#[ResourceType('article')] |
15 | 15 | class Article implements ApiModel |
16 | 16 | { |
17 | | - /** |
18 | | - * @var string |
19 | | - */ |
20 | | - private $id; |
| 17 | + private string $id; |
21 | 18 |
|
22 | | - /** |
23 | | - * @var string |
24 | | - * |
25 | | - * @Attribute(nullable=false) |
26 | | - */ |
27 | | - private $slug; |
| 19 | + #[Attribute('slug')] |
| 20 | + private string $slug; |
28 | 21 |
|
29 | | - /** |
30 | | - * @var string |
31 | | - * |
32 | | - * @Attribute |
33 | | - */ |
34 | | - private $title; |
| 22 | + #[Attribute('titlw')] |
| 23 | + private string $title; |
35 | 24 |
|
36 | | - /** |
37 | | - * @var string |
38 | | - * |
39 | | - * @Attribute(name="eventAddress") |
40 | | - */ |
41 | | - private $address; |
| 25 | + #[Attribute('eventAddress')] |
| 26 | + private string $address; |
42 | 27 |
|
43 | | - /** |
44 | | - * @var string |
45 | | - * |
46 | | - * @Attribute(name="eventDate") |
47 | | - */ |
48 | | - private $date; |
| 28 | + #[Attribute('eventDate')] |
| 29 | + private string $date; |
49 | 30 |
|
50 | | - /** |
51 | | - * @var bool |
52 | | - * |
53 | | - * @Attribute |
54 | | - */ |
55 | | - private $enabled; |
| 31 | + #[Attribute('enabled')] |
| 32 | + private bool $enabled; |
56 | 33 |
|
57 | | - /** |
58 | | - * @var null|string |
59 | | - * |
60 | | - * @Attribute |
61 | | - */ |
62 | | - private $description; |
| 34 | + #[Attribute('description', null, null, null, true)] |
| 35 | + private ?string $description; |
63 | 36 |
|
64 | | - /** |
65 | | - * @var string |
66 | | - * |
67 | | - * @ToOne(name="category", type="category", nullable=true) |
68 | | - * |
69 | | - * @Assert\Type(type="string") |
70 | | - */ |
71 | | - private $categoryId; |
| 37 | + #[ToOne('category', 'category', null, true)] |
| 38 | + private string $categoryId; |
72 | 39 |
|
73 | | - /** |
74 | | - * @var string[] |
75 | | - * |
76 | | - * @ToMany(name="tags", type="tag", nullable=false) |
77 | | - * |
78 | | - * @Assert\Type(type="array") |
79 | | - */ |
80 | | - private $tagIds; |
| 40 | + #[ToMany('tags', 'tag')] |
| 41 | + #[Assert\Type('array')] |
| 42 | + private array $tagIds; |
81 | 43 |
|
82 | | - /** |
83 | | - * @var string |
84 | | - * |
85 | | - * @Attribute(format="datetime", example="2001") |
86 | | - * |
87 | | - * @Assert\NotBlank |
88 | | - */ |
89 | | - private $createdAt; |
| 44 | + #[Attribute('createdAt', null, null, 'datetime')] |
| 45 | + private string $createdAt; |
90 | 46 |
|
91 | | - /** |
92 | | - * @var null|string |
93 | | - * |
94 | | - * @Attribute |
95 | | - */ |
96 | | - private $updatedAt; |
| 47 | + #[Attribute('updatedAt')] |
| 48 | + private ?string $updatedAt; |
97 | 49 | } |
0 commit comments