src/Entity/ModuleFeatured.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Doctrine\ORM\Event\LifecycleEventArgs;
  5. /**
  6. * ModuleText
  7. *
  8. * @ORM\Table(name="module_featured")
  9. * @ORM\Entity(repositoryClass="App\Repository\ModuleCarouselRepository")
  10. * @ORM\HasLifecycleCallbacks
  11. */
  12. class ModuleFeatured {
  13. /**
  14. * @var integer
  15. *
  16. * @ORM\Column(name="id", type="integer")
  17. * @ORM\Id
  18. * @ORM\GeneratedValue(strategy="AUTO")
  19. */
  20. private $id;
  21. /**
  22. * @ORM\ManyToOne(targetEntity="ModuleHook")
  23. * @ORM\JoinColumn(name="module_hook_id", referencedColumnName="id")
  24. */
  25. private $moduleHook;
  26. /**
  27. * @var ?string
  28. *
  29. * @ORM\Column(name="title_fr", type="string", length=255, nullable=true)
  30. */
  31. private $titleFr;
  32. /**
  33. * @var ?string
  34. *
  35. * @ORM\Column(name="title_en", type="string", length=255, nullable=true)
  36. */
  37. private $titleEn;
  38. /**
  39. * @var integer
  40. *
  41. * @ORM\OneToMany(targetEntity="ModuleFeaturedItem", mappedBy="module", cascade={"remove"})
  42. * @ORM\OrderBy({"orderNum" = "ASC"})
  43. */
  44. private $items;
  45. public function getId() {
  46. return $this->id;
  47. }
  48. public function getModuleHook() {
  49. return $this->moduleHook;
  50. }
  51. public function getTitleFr(): ?string {
  52. return $this->titleFr;
  53. }
  54. public function getTitleEn(): ?string {
  55. return $this->titleEn;
  56. }
  57. public function getItems(){
  58. return $this->items;
  59. }
  60. public function setId($id): void {
  61. $this->id = $id;
  62. }
  63. public function setModuleHook($moduleHook): void {
  64. $this->moduleHook = $moduleHook;
  65. }
  66. public function setTitleFr(?string $titleFr): void {
  67. $this->titleFr = $titleFr;
  68. }
  69. public function setTitleEn(?string $titleEn): void {
  70. $this->titleEn = $titleEn;
  71. }
  72. public function setProducts($items): void {
  73. $this->items = $items;
  74. }
  75. /**
  76. * Chargement des paramètres du module
  77. */
  78. public function getData(ModuleHook $module_hooked) {
  79. $data = array();
  80. $data['titleFr'] = $this->getTitleFr();
  81. $data['titleEn'] = $this->getTitleEn();
  82. $data['items'] = $this->getItems();
  83. $data['products'] = [];
  84. foreach($this->getItems() as $item){
  85. if($item->getProduct()->isActive())
  86. $data['products'][] = $item->getProduct();
  87. }
  88. return $data;
  89. }
  90. }