|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the API Platform project. |
| 5 | + * |
| 6 | + * (c) Kévin Dunglas <[email protected]> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +declare(strict_types=1); |
| 13 | + |
| 14 | +namespace ApiPlatform\Doctrine\Common\Tests\Fixtures\TestBundle\Entity; |
| 15 | + |
| 16 | +use ApiPlatform\Metadata\ApiProperty; |
| 17 | +use ApiPlatform\Metadata\ApiResource; |
| 18 | +use ApiPlatform\Metadata\Get; |
| 19 | +use ApiPlatform\Metadata\Link; |
| 20 | +use Doctrine\Common\Collections\ArrayCollection; |
| 21 | +use Doctrine\Common\Collections\Collection; |
| 22 | +use Doctrine\ORM\Mapping as ORM; |
| 23 | +use Symfony\Component\Validator\Constraints as Assert; |
| 24 | + |
| 25 | +/** |
| 26 | + * Dummy. |
| 27 | + * |
| 28 | + * @author Kévin Dunglas <[email protected]> |
| 29 | + */ |
| 30 | +#[ApiResource(filters: ['my_dummy.boolean', 'my_dummy.date', 'my_dummy.exists', 'my_dummy.numeric', 'my_dummy.order', 'my_dummy.range', 'my_dummy.search', 'my_dummy.property'], extraProperties: ['standard_put' => false])] |
| 31 | +#[ApiResource(uriTemplate: '/related_owned_dummies/{id}/owning_dummy{._format}', uriVariables: ['id' => new Link(fromClass: RelatedOwnedDummy::class, identifiers: ['id'], fromProperty: 'owningDummy')], status: 200, filters: ['my_dummy.boolean', 'my_dummy.date', 'my_dummy.exists', 'my_dummy.numeric', 'my_dummy.order', 'my_dummy.range', 'my_dummy.search', 'my_dummy.property'], operations: [new Get()])] |
| 32 | +#[ApiResource(uriTemplate: '/related_owning_dummies/{id}/owned_dummy{._format}', uriVariables: ['id' => new Link(fromClass: RelatedOwningDummy::class, identifiers: ['id'], fromProperty: 'ownedDummy')], status: 200, filters: ['my_dummy.boolean', 'my_dummy.date', 'my_dummy.exists', 'my_dummy.numeric', 'my_dummy.order', 'my_dummy.range', 'my_dummy.search', 'my_dummy.property'], operations: [new Get()])] |
| 33 | +#[ORM\Entity] |
| 34 | +class Dummy |
| 35 | +{ |
| 36 | + /** |
| 37 | + * @var int|null The id |
| 38 | + */ |
| 39 | + #[ORM\Column(type: 'integer', nullable: true)] |
| 40 | + #[ORM\Id] |
| 41 | + #[ORM\GeneratedValue(strategy: 'AUTO')] |
| 42 | + private $id; |
| 43 | + |
| 44 | + /** |
| 45 | + * @var string The dummy name |
| 46 | + */ |
| 47 | + #[ApiProperty(iris: ['https://schema.org/name'])] |
| 48 | + #[ORM\Column] |
| 49 | + #[Assert\NotBlank] |
| 50 | + private string $name; |
| 51 | + |
| 52 | + /** |
| 53 | + * @var string|null The dummy name alias |
| 54 | + */ |
| 55 | + #[ApiProperty(iris: ['https://schema.org/alternateName'])] |
| 56 | + #[ORM\Column(nullable: true)] |
| 57 | + private $alias; |
| 58 | + |
| 59 | + /** |
| 60 | + * @var array foo |
| 61 | + */ |
| 62 | + private ?array $foo = null; |
| 63 | + |
| 64 | + /** |
| 65 | + * @var string|null A short description of the item |
| 66 | + */ |
| 67 | + #[ApiProperty(iris: ['https://schema.org/description'])] |
| 68 | + #[ORM\Column(nullable: true)] |
| 69 | + public $description; |
| 70 | + |
| 71 | + /** |
| 72 | + * @var string|null A dummy |
| 73 | + */ |
| 74 | + #[ORM\Column(nullable: true)] |
| 75 | + public $dummy; |
| 76 | + |
| 77 | + /** |
| 78 | + * @var bool|null A dummy boolean |
| 79 | + */ |
| 80 | + #[ORM\Column(type: 'boolean', nullable: true)] |
| 81 | + |
| 82 | + public ?bool $dummyBoolean = null; |
| 83 | + /** |
| 84 | + * @var \DateTime|null A dummy date |
| 85 | + */ |
| 86 | + #[ApiProperty(iris: ['https://schema.org/DateTime'])] |
| 87 | + #[ORM\Column(type: 'datetime', nullable: true)] |
| 88 | + public $dummyDate; |
| 89 | + |
| 90 | + /** |
| 91 | + * @var float|null A dummy float |
| 92 | + */ |
| 93 | + #[ORM\Column(type: 'float', nullable: true)] |
| 94 | + public $dummyFloat; |
| 95 | + |
| 96 | + /** |
| 97 | + * @var string|null A dummy price |
| 98 | + */ |
| 99 | + #[ORM\Column(type: 'decimal', precision: 10, scale: 2, nullable: true)] |
| 100 | + public $dummyPrice; |
| 101 | + |
| 102 | + #[ApiProperty(push: true)] |
| 103 | + #[ORM\ManyToOne(targetEntity: RelatedDummy::class)] |
| 104 | + public ?RelatedDummy $relatedDummy = null; |
| 105 | + |
| 106 | + #[ORM\ManyToMany(targetEntity: RelatedDummy::class)] |
| 107 | + public Collection|iterable $relatedDummies; |
| 108 | + |
| 109 | + /** |
| 110 | + * @var array|null serialize data |
| 111 | + */ |
| 112 | + #[ORM\Column(type: 'json', nullable: true)] |
| 113 | + public $jsonData = []; |
| 114 | + |
| 115 | + /** |
| 116 | + * @var array|null |
| 117 | + */ |
| 118 | + #[ORM\Column(type: 'simple_array', nullable: true)] |
| 119 | + public $arrayData = []; |
| 120 | + |
| 121 | + /** |
| 122 | + * @var string|null |
| 123 | + */ |
| 124 | + #[ORM\Column(nullable: true)] |
| 125 | + public $nameConverted; |
| 126 | + |
| 127 | + /** |
| 128 | + * @var RelatedOwnedDummy|null |
| 129 | + */ |
| 130 | + #[ORM\OneToOne(targetEntity: RelatedOwnedDummy::class, cascade: ['persist'], mappedBy: 'owningDummy')] |
| 131 | + public $relatedOwnedDummy; |
| 132 | + |
| 133 | + /** |
| 134 | + * @var RelatedOwningDummy|null |
| 135 | + */ |
| 136 | + #[ORM\OneToOne(targetEntity: RelatedOwningDummy::class, cascade: ['persist'], inversedBy: 'ownedDummy')] |
| 137 | + public $relatedOwningDummy; |
| 138 | + |
| 139 | + public static function staticMethod(): void |
| 140 | + { |
| 141 | + } |
| 142 | + |
| 143 | + public function __construct() |
| 144 | + { |
| 145 | + $this->relatedDummies = new ArrayCollection(); |
| 146 | + } |
| 147 | + |
| 148 | + public function getId() |
| 149 | + { |
| 150 | + return $this->id; |
| 151 | + } |
| 152 | + |
| 153 | + public function setId($id): void |
| 154 | + { |
| 155 | + $this->id = $id; |
| 156 | + } |
| 157 | + |
| 158 | + public function setName(string $name): void |
| 159 | + { |
| 160 | + $this->name = $name; |
| 161 | + } |
| 162 | + |
| 163 | + public function getName(): string |
| 164 | + { |
| 165 | + return $this->name; |
| 166 | + } |
| 167 | + |
| 168 | + public function setAlias($alias): void |
| 169 | + { |
| 170 | + $this->alias = $alias; |
| 171 | + } |
| 172 | + |
| 173 | + public function getAlias() |
| 174 | + { |
| 175 | + return $this->alias; |
| 176 | + } |
| 177 | + |
| 178 | + public function setDescription($description): void |
| 179 | + { |
| 180 | + $this->description = $description; |
| 181 | + } |
| 182 | + |
| 183 | + public function getDescription() |
| 184 | + { |
| 185 | + return $this->description; |
| 186 | + } |
| 187 | + |
| 188 | + public function fooBar($baz): void |
| 189 | + { |
| 190 | + } |
| 191 | + |
| 192 | + public function getFoo(): ?array |
| 193 | + { |
| 194 | + return $this->foo; |
| 195 | + } |
| 196 | + |
| 197 | + public function setFoo(array $foo = null): void |
| 198 | + { |
| 199 | + $this->foo = $foo; |
| 200 | + } |
| 201 | + |
| 202 | + public function setDummyDate(\DateTime $dummyDate = null): void |
| 203 | + { |
| 204 | + $this->dummyDate = $dummyDate; |
| 205 | + } |
| 206 | + |
| 207 | + public function getDummyDate() |
| 208 | + { |
| 209 | + return $this->dummyDate; |
| 210 | + } |
| 211 | + |
| 212 | + public function setDummyPrice($dummyPrice) |
| 213 | + { |
| 214 | + $this->dummyPrice = $dummyPrice; |
| 215 | + |
| 216 | + return $this; |
| 217 | + } |
| 218 | + |
| 219 | + public function getDummyPrice() |
| 220 | + { |
| 221 | + return $this->dummyPrice; |
| 222 | + } |
| 223 | + |
| 224 | + public function setJsonData($jsonData): void |
| 225 | + { |
| 226 | + $this->jsonData = $jsonData; |
| 227 | + } |
| 228 | + |
| 229 | + public function getJsonData() |
| 230 | + { |
| 231 | + return $this->jsonData; |
| 232 | + } |
| 233 | + |
| 234 | + public function setArrayData($arrayData): void |
| 235 | + { |
| 236 | + $this->arrayData = $arrayData; |
| 237 | + } |
| 238 | + |
| 239 | + public function getArrayData() |
| 240 | + { |
| 241 | + return $this->arrayData; |
| 242 | + } |
| 243 | + |
| 244 | + public function getRelatedDummy(): ?RelatedDummy |
| 245 | + { |
| 246 | + return $this->relatedDummy; |
| 247 | + } |
| 248 | + |
| 249 | + public function setRelatedDummy(RelatedDummy $relatedDummy): void |
| 250 | + { |
| 251 | + $this->relatedDummy = $relatedDummy; |
| 252 | + } |
| 253 | + |
| 254 | + public function addRelatedDummy(RelatedDummy $relatedDummy): void |
| 255 | + { |
| 256 | + $this->relatedDummies->add($relatedDummy); |
| 257 | + } |
| 258 | + |
| 259 | + public function getRelatedOwnedDummy() |
| 260 | + { |
| 261 | + return $this->relatedOwnedDummy; |
| 262 | + } |
| 263 | + |
| 264 | + public function setRelatedOwnedDummy(RelatedOwnedDummy $relatedOwnedDummy): void |
| 265 | + { |
| 266 | + $this->relatedOwnedDummy = $relatedOwnedDummy; |
| 267 | + if ($this !== $this->relatedOwnedDummy->getOwningDummy()) { |
| 268 | + $this->relatedOwnedDummy->setOwningDummy($this); |
| 269 | + } |
| 270 | + } |
| 271 | + |
| 272 | + public function getRelatedOwningDummy() |
| 273 | + { |
| 274 | + return $this->relatedOwningDummy; |
| 275 | + } |
| 276 | + |
| 277 | + public function setRelatedOwningDummy(RelatedOwningDummy $relatedOwningDummy): void |
| 278 | + { |
| 279 | + $this->relatedOwningDummy = $relatedOwningDummy; |
| 280 | + } |
| 281 | + |
| 282 | + public function isDummyBoolean(): ?bool |
| 283 | + { |
| 284 | + return $this->dummyBoolean; |
| 285 | + } |
| 286 | + |
| 287 | + /** |
| 288 | + * @param bool $dummyBoolean |
| 289 | + */ |
| 290 | + public function setDummyBoolean($dummyBoolean): void |
| 291 | + { |
| 292 | + $this->dummyBoolean = $dummyBoolean; |
| 293 | + } |
| 294 | + |
| 295 | + public function setDummy($dummy = null): void |
| 296 | + { |
| 297 | + $this->dummy = $dummy; |
| 298 | + } |
| 299 | + |
| 300 | + public function getDummy() |
| 301 | + { |
| 302 | + return $this->dummy; |
| 303 | + } |
| 304 | + |
| 305 | + public function getRelatedDummies(): Collection|iterable |
| 306 | + { |
| 307 | + return $this->relatedDummies; |
| 308 | + } |
| 309 | +} |
0 commit comments