|
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 |
| - #[\Undabot\SymfonyJsonApi\Model\Resource\Attribute\Attribute('ovoJeIme')] |
49 |
| - private $date; |
| 28 | + #[Attribute('eventDate')] |
| 29 | + private string $date; |
50 | 30 |
|
51 |
| - /** |
52 |
| - * @var bool |
53 |
| - * |
54 |
| - * @Attribute |
55 |
| - */ |
56 |
| - private $enabled; |
| 31 | + #[Attribute('enabled')] |
| 32 | + private bool $enabled; |
57 | 33 |
|
58 |
| - /** |
59 |
| - * @var null|string |
60 |
| - * |
61 |
| - * @Attribute |
62 |
| - */ |
63 |
| - private $description; |
| 34 | + #[Attribute('description', null, null, null, true)] |
| 35 | + private ?string $description; |
64 | 36 |
|
65 |
| - /** |
66 |
| - * @var string |
67 |
| - * |
68 |
| - * @ToOne(name="category", type="category", nullable=true) |
69 |
| - * |
70 |
| - * @Assert\Type(type="string") |
71 |
| - */ |
72 |
| - private $categoryId; |
| 37 | + #[ToOne('category', 'category', null, true)] |
| 38 | + private string $categoryId; |
73 | 39 |
|
74 |
| - /** |
75 |
| - * @var string[] |
76 |
| - * |
77 |
| - * @ToMany(name="tags", type="tag", nullable=false) |
78 |
| - * |
79 |
| - * @Assert\Type(type="array") |
80 |
| - */ |
81 |
| - private $tagIds; |
| 40 | + #[ToMany('tags', 'tag')] |
| 41 | + #[Assert\Type('array')] |
| 42 | + private array $tagIds; |
82 | 43 |
|
83 |
| - /** |
84 |
| - * @var string |
85 |
| - * |
86 |
| - * @Attribute(format="datetime", example="2001") |
87 |
| - * |
88 |
| - * @Assert\NotBlank |
89 |
| - */ |
90 |
| - private $createdAt; |
| 44 | + #[Attribute('createdAt', null, null, 'datetime')] |
| 45 | + private string $createdAt; |
91 | 46 |
|
92 |
| - /** |
93 |
| - * @var null|string |
94 |
| - * |
95 |
| - * @Attribute |
96 |
| - */ |
97 |
| - private $updatedAt; |
| 47 | + #[Attribute('updatedAt')] |
| 48 | + private ?string $updatedAt; |
98 | 49 | }
|
0 commit comments