Skip to content

Commit e60bd5f

Browse files
soyukabouffa
andauthored
fix: diff of Doctrine annotations (#1521) (#1522)
Co-authored-by: Mourad Boufarguine <[email protected]>
1 parent 1e2fdab commit e60bd5f

File tree

2 files changed

+33
-78
lines changed

2 files changed

+33
-78
lines changed

.github/linters/.textlintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"rules": {
33
"terminology": {
44
"exclude": [
5-
"Node(?:js)?"
5+
"Node(?:js)?",
6+
"web[- ]?site(s)?"
67
]
78
}
89
}

distribution/index.md

Lines changed: 31 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ The framework also use these metadata to serialize and deserialize data from JSO
337337

338338
For the sake of simplicity, in this example we used public properties (except for the id, see below). API Platform (as well
339339
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/).
342342

343343
Because API Platform provides all the infrastructure for us, our API is almost ready!
344344

@@ -367,62 +367,37 @@ Modify these files as described in these patches:
367367
use Doctrine\Common\Collections\ArrayCollection;
368368
+use Doctrine\ORM\Mapping as ORM;
369369

370-
-/** A book. */
371-
+/**
372-
+ * A book.
373-
+ *
374-
+ */
375-
#[ORM\Entity]
370+
/** A book. */
371+
+#[ORM\Entity]
376372
#[ApiResource]
377373
class Book
378374
{
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]
384377
private ?int $id = null;
385378

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)]
391381
public ?string $isbn = null;
392382

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]
398385
public string $title = '';
399386

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")]
405389
public string $description = '';
406390

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]
412393
public string $author = '';
413394

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")]
419397
public ?\DateTimeInterface $publicationDate = null;
420398

421-
- /** @var Review[] Available reviews for this book. */
422-
+ /**
423-
+ * @var Review[] Available reviews for this book.
424-
+ */
425-
#[ORM\OneToMany(mappedBy: 'book', targetEntity: 'Review', cascade: ['persist', 'remove'])]
399+
/** @var Review[] Available reviews for this book. */
400+
+ #[ORM\OneToMany(mappedBy: 'book', targetEntity: 'Review', cascade: ['persist', 'remove'])]
426401
public iterable $reviews;
427402

428403
public function __construct()
@@ -436,54 +411,33 @@ Modify these files as described in these patches:
436411
use ApiPlatform\Metadata\ApiResource;
437412
+use Doctrine\ORM\Mapping as ORM;
438413

439-
-/** A review of a book. */
440-
+/**
441-
+ * A review of a book.
442-
+ */
443-
#[ORM\Entity]
414+
/** A review of a book. */
415+
+#[ORM\Entity]
444416
#[ApiResource]
445417
class Review
446418
{
447-
- /** The id of this review. */
448-
+ /**
449-
+ * The id of this review.
450-
+ */
419+
/** The id of this review. */
451420
#[ORM\Id, ORM\Column, ORM\GeneratedValue]
452421
private ?int $id = null;
453422

454-
- /** The rating of this review (between 0 and 5). */
455-
+ /**
456-
+ * The rating of this review (between 0 and 5).
457-
+ */
458-
#[ORM\Column(type: "smallint")]
423+
/** The rating of this review (between 0 and 5). */
424+
+ #[ORM\Column(type: "smallint")]
459425
public int $rating = 0;
460426

461-
- /** The body of the review. */
462-
+ /**
463-
+ * The body of the review.
464-
+ */
465-
#[ORM\Column(type: "text")]
427+
/** The body of the review. */
428+
+ #[ORM\Column(type: "text")]
466429
public string $body = '';
467430

468-
- /** The author of the review. */
469-
+ /**
470-
+ * The author of the review.
471-
+ */
472-
#[ORM\Column]
431+
/** The author of the review. */
432+
+ #[ORM\Column]
473433
public string $author = '';
474434

475-
- /** The date of publication of this review.*/
476-
+ /**
477-
+ * The date of publication of this review.
478-
+ */
479-
#[ORM\Column]
435+
/** The date of publication of this review.*/
436+
+ #[ORM\Column(type: "datetime")]
480437
public ?\DateTimeInterface $publicationDate = null;
481438

482-
- /** The book this review is about. */
483-
+ /**
484-
+ * The book this review is about.
485-
+ */
486-
#[ORM\ManyToOne(targetEntity: "Book", inversedBy: "reviews")]
439+
/** The book this review is about. */
440+
+ #[ORM\ManyToOne(targetEntity: "Book", inversedBy: "reviews")]
487441
public ?Book $book = null;
488442

489443
public function getId(): ?int

0 commit comments

Comments
 (0)