Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Symfony]Anemiczna encja
PawelC
post 1.09.2019, 20:15:58
Post #1





Grupa: Zarejestrowani
Postów: 1 173
Pomógł: 121
Dołączył: 24.09.2007
Skąd: Toruń

Ostrzeżenie: (0%)
-----


Witam,
Piszę API w Symfony 4. Znajomy mi napisał, że mam anemiczną encję, możecie mi wyjaśnić co to znaczy i jak zrobić encję, aby nie była anemiczna? Kod encji
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. /**
  6.  * @ORM\Entity(repositoryClass="App\Repository\PostRepository")
  7.  */
  8. class Post
  9. {
  10. /**
  11.   * @ORM\Id()
  12.   * @ORM\GeneratedValue()
  13.   * @ORM\Column(type="integer")
  14.   */
  15. private $id;
  16. /**
  17.   * @ORM\Column(type="string", length=255)
  18.   * @Assert\NotBlank()
  19.   */
  20. private $title;
  21. /**
  22.   * @ORM\Column(type="string", length=255)
  23.   * @Assert\NotBlank()
  24.   */
  25. private $content;
  26. /**
  27.   * @ORM\Column(type="string", length=255)
  28.   * @Assert\NotBlank()
  29.   */
  30. private $author;
  31. public function getId(): ?int
  32. {
  33. return $this->id;
  34. }
  35. public function getTitle(): ?string
  36. {
  37. return $this->title;
  38. }
  39. public function setTitle(string $title): self
  40. {
  41. $this->title = $title;
  42. return $this;
  43. }
  44. public function getContent(): ?string
  45. {
  46. return $this->content;
  47. }
  48. public function setContent(string $content): self
  49. {
  50. $this->content = $content;
  51. return $this;
  52. }
  53. public function getAuthor(): ?string
  54. {
  55. return $this->author;
  56. }
  57. public function setAuthor(string $author): self
  58. {
  59. $this->author = $author;
  60. return $this;
  61. }
  62. }


Chcę napisać prosty CRUD, ale taki który ma jakość, a nie byle bałagan bez dobrych praktyk i standardów, dlatego już teraz chciałbym uniknąć anemicznych encji.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 29.03.2024 - 07:02