src/Entity/ModuleCarousel.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5. * ModuleText
  6. *
  7. * @ORM\Table(name="module_carousels")
  8. * @ORM\Entity
  9. */
  10. class ModuleCarousel {
  11. /**
  12. * @var integer
  13. *
  14. * @ORM\Column(name="id", type="integer")
  15. * @ORM\Id
  16. * @ORM\GeneratedValue(strategy="AUTO")
  17. */
  18. private $id;
  19. /**
  20. * @ORM\ManyToOne(targetEntity="ModuleHook")
  21. * @ORM\JoinColumn(name="module_hook_id", referencedColumnName="id")
  22. */
  23. private $moduleHook;
  24. /**
  25. * @var integer
  26. *
  27. * @ORM\OneToMany(targetEntity="ModuleCarouselItem", mappedBy="moduleCarousel", cascade={"remove"})
  28. * @ORM\OrderBy({"orderNum" = "ASC"})
  29. */
  30. private $items;
  31. /**
  32. * @var string
  33. *
  34. * @ORM\Column(name="speed", type="float", nullable=true)
  35. */
  36. private $speed;
  37. /**
  38. * @var string
  39. *
  40. * @ORM\Column(name="display", type="float", nullable=true)
  41. */
  42. private $display;
  43. /**
  44. * Get id
  45. *
  46. * @return integer
  47. */
  48. public function getId() {
  49. return $this->id;
  50. }
  51. /**
  52. * Chargement des paramètres du module
  53. */
  54. public function getData(ModuleHook $module_hooked) {
  55. $data = array();
  56. $data['items'] = $this->getItems();
  57. $data['speed'] = $this->getSpeed()*1000;
  58. $data['display'] = $this->getDisplay()*1000;
  59. return $data;
  60. }
  61. /**
  62. * @return the $moduleHook
  63. */
  64. public function getModuleHook() {
  65. return $this->moduleHook;
  66. }
  67. /**
  68. * @param field_type $moduleHook
  69. */
  70. public function setModuleHook($moduleHook) {
  71. $this->moduleHook = $moduleHook;
  72. }
  73. /**
  74. * @return the $items
  75. */
  76. public function getItems() {
  77. return $this->items;
  78. }
  79. public function getItemsByPriceContext(?PriceGroup $priceGroup) {
  80. $output = [];
  81. foreach($this->items as $item){
  82. if($item->matchPriceContext($priceGroup))
  83. $output[] = $item;
  84. }
  85. return $output;
  86. }
  87. public function getSpeed() {
  88. if(empty($this->speed))
  89. return 1;
  90. return $this->speed;
  91. }
  92. public function setSpeed($speed) {
  93. $this->speed = $speed;
  94. }
  95. public function getDisplay() {
  96. if(empty($this->display))
  97. return 5;
  98. return $this->display;
  99. }
  100. public function setDisplay($display) {
  101. $this->display = $display;
  102. }
  103. public function setItems($items) {
  104. $this->items = $items;
  105. }
  106. }