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
@@ -339,8 +339,8 @@ The framework also use these metadata to serialize and deserialize data from JSO
339
339
340
340
For the sake of simplicity, in this example we used public properties (except for the id, see below). API Platform (as well
341
341
as Symfony and Doctrine) also supports accessor methods (getters/setters), use them if you want to.
342
-
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
343
-
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
+
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
343
+
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/).
344
344
345
345
Because API Platform provides all the infrastructure for us, our API is almost ready!
346
346
@@ -369,62 +369,37 @@ Modify these files as described in these patches:
369
369
use Doctrine\Common\Collections\ArrayCollection;
370
370
+use Doctrine\ORM\Mapping as ORM;
371
371
372
-
-/** A book. */
373
-
+/**
374
-
+ * A book.
375
-
+ *
376
-
+ */
377
-
#[ORM\Entity]
372
+
/** A book. */
373
+
+#[ORM\Entity]
378
374
#[ApiResource]
379
375
class Book
380
376
{
381
-
- /** The id of this book. */
382
-
+ /**
383
-
+ * The id of this book.
384
-
+ */
385
-
#[ORM\Id, ORM\Column, ORM\GeneratedValue]
377
+
/** The id of this book. */
378
+
+ #[ORM\Id, ORM\Column, ORM\GeneratedValue]
386
379
private ?int $id = null;
387
380
388
-
- /** The ISBN of this book (or null if doesn't have one). */
389
-
+ /**
390
-
+ * The ISBN of this book (or null if doesn't have one).
391
-
+ */
392
-
#[ORM\Column(nullable: true)]
381
+
/** The ISBN of this book (or null if doesn't have one). */
382
+
+ #[ORM\Column(nullable: true)]
393
383
public ?string $isbn = null;
394
384
395
-
- /** The title of this book. */
396
-
+ /**
397
-
+ * The title of this book.
398
-
+ */
399
-
#[ORM\Column]
385
+
/** The title of this book. */
386
+
+ #[ORM\Column]
400
387
public string $title = '';
401
388
402
-
- /** The description of this book. */
403
-
+ /**
404
-
+ * The description of this book.
405
-
+ */
406
-
#[ORM\Column(type="text")]
389
+
/** The description of this book. */
390
+
+ #[ORM\Column(type: "text")]
407
391
public string $description = '';
408
392
409
-
- /** The author of this book. */
410
-
+ /**
411
-
+ * The author of this book.
412
-
+ */
413
-
#[ORM\Column]
393
+
/** The author of this book. */
394
+
+ #[ORM\Column]
414
395
public string $author = '';
415
396
416
-
- /** The publication date of this book. */
417
-
+ /**
418
-
+ * The publication date of this book.
419
-
+ */
420
-
#[ORM\Column]
397
+
/** The publication date of this book. */
398
+
+ #[ORM\Column(type: "datetime")]
421
399
public ?\DateTimeInterface $publicationDate = null;
422
400
423
-
- /** @var Review[] Available reviews for this book. */
424
-
+ /**
425
-
+ * @var Review[] Available reviews for this book.
0 commit comments