You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: distribution/index.md
+31-77Lines changed: 31 additions & 77 deletions
Original file line number
Diff line number
Diff line change
@@ -337,8 +337,8 @@ The framework also use these metadata to serialize and deserialize data from JSO
337
337
338
338
For the sake of simplicity, in this example we used public properties (except for the id, see below). API Platform (as well
339
339
as Symfony and Doctrine) also supports accessor methods (getters/setters), use them if you want to.
340
-
We used a private property and a getter for the id to enforce the fact that it is read only (we will let the DBMS generating it). API Platform also has first-grade support for UUIDs. [You should
341
-
probably use them instead of auto-incremented ids](https://www.clever-cloud.com/blog/engineering/2015/05/20/why-auto-increment-is-a-terrible-idea/).
340
+
We used a private property and a getter for the ID to enforce the fact that it is read only (we will let the DBMS generating it). API Platform also has first-grade support for UUIDs. [You should
341
+
probably use them instead of auto-incremented IDs](https://www.clever-cloud.com/blog/engineering/2015/05/20/why-auto-increment-is-a-terrible-idea/).
342
342
343
343
Because API Platform provides all the infrastructure for us, our API is almost ready!
344
344
@@ -367,62 +367,37 @@ Modify these files as described in these patches:
367
367
use Doctrine\Common\Collections\ArrayCollection;
368
368
+use Doctrine\ORM\Mapping as ORM;
369
369
370
-
-/** A book. */
371
-
+/**
372
-
+ * A book.
373
-
+ *
374
-
+ */
375
-
#[ORM\Entity]
370
+
/** A book. */
371
+
+#[ORM\Entity]
376
372
#[ApiResource]
377
373
class Book
378
374
{
379
-
- /** The id of this book. */
380
-
+ /**
381
-
+ * The id of this book.
382
-
+ */
383
-
#[ORM\Id, ORM\Column, ORM\GeneratedValue]
375
+
/** The id of this book. */
376
+
+ #[ORM\Id, ORM\Column, ORM\GeneratedValue]
384
377
private ?int $id = null;
385
378
386
-
- /** The ISBN of this book (or null if doesn't have one). */
387
-
+ /**
388
-
+ * The ISBN of this book (or null if doesn't have one).
389
-
+ */
390
-
#[ORM\Column(nullable: true)]
379
+
/** The ISBN of this book (or null if doesn't have one). */
380
+
+ #[ORM\Column(nullable: true)]
391
381
public ?string $isbn = null;
392
382
393
-
- /** The title of this book. */
394
-
+ /**
395
-
+ * The title of this book.
396
-
+ */
397
-
#[ORM\Column]
383
+
/** The title of this book. */
384
+
+ #[ORM\Column]
398
385
public string $title = '';
399
386
400
-
- /** The description of this book. */
401
-
+ /**
402
-
+ * The description of this book.
403
-
+ */
404
-
#[ORM\Column(type="text")]
387
+
/** The description of this book. */
388
+
+ #[ORM\Column(type: "text")]
405
389
public string $description = '';
406
390
407
-
- /** The author of this book. */
408
-
+ /**
409
-
+ * The author of this book.
410
-
+ */
411
-
#[ORM\Column]
391
+
/** The author of this book. */
392
+
+ #[ORM\Column]
412
393
public string $author = '';
413
394
414
-
- /** The publication date of this book. */
415
-
+ /**
416
-
+ * The publication date of this book.
417
-
+ */
418
-
#[ORM\Column]
395
+
/** The publication date of this book. */
396
+
+ #[ORM\Column(type: "datetime")]
419
397
public ?\DateTimeInterface $publicationDate = null;
420
398
421
-
- /** @var Review[] Available reviews for this book. */
422
-
+ /**
423
-
+ * @var Review[] Available reviews for this book.
0 commit comments