src/Entity/Redirection.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5. * Manufacturers
  6. *
  7. * @ORM\Table(name="redirections")
  8. * @ORM\Entity(repositoryClass="App\Repository\RedirectionRepository")
  9. */
  10. class Redirection
  11. {
  12. /**
  13. * @ORM\Column(name="id", type="integer", nullable=false)
  14. * @ORM\Id
  15. * @ORM\GeneratedValue(strategy="IDENTITY")
  16. */
  17. private $id;
  18. /**
  19. * @var App\Entity\Product|null
  20. *
  21. * @ORM\ManyToOne(targetEntity="App\Entity\Product")
  22. * @ORM\JoinColumn(name="redirect_product_id", referencedColumnName="products_id", nullable=true, onDelete="CASCADE")
  23. */
  24. private $fromProduct;
  25. /**
  26. * @var App\Entity\Category|null
  27. *
  28. * @ORM\ManyToOne(targetEntity="App\Entity\Category")
  29. * @ORM\JoinColumn(name="redirect_category_id", referencedColumnName="categories_id", nullable=true, onDelete="CASCADE")
  30. */
  31. private $fromCategory;
  32. /**
  33. * @var App\Entity\Category|null
  34. *
  35. * @ORM\Column(name="redirect_url", type="string", length=255, nullable=true)
  36. */
  37. private $fromUrl;
  38. /**
  39. * @ORM\Column(name="target_path", type="string", length=255, nullable=true)
  40. */
  41. private $targetPath;
  42. /**
  43. * @var App\Entity\Product|null
  44. *
  45. * @ORM\ManyToOne(targetEntity="App\Entity\Product")
  46. * @ORM\JoinColumn(name="target_product_id", referencedColumnName="products_id", nullable=true, onDelete="CASCADE")
  47. */
  48. private $toProduct;
  49. /**
  50. *
  51. * @ORM\ManyToOne(targetEntity="App\Entity\Category")
  52. * @ORM\JoinColumn(name="target_category_id", referencedColumnName="categories_id", nullable=true, onDelete="CASCADE")
  53. */
  54. private $toCategory;
  55. /**
  56. * @ORM\Column(name="target_url", type="string", length=255, nullable=true)
  57. */
  58. private $toUrl;
  59. public function getId() {
  60. return $this->id;
  61. }
  62. public function getFromProduct() {
  63. return $this->fromProduct;
  64. }
  65. public function getFromCategory() {
  66. return $this->fromCategory;
  67. }
  68. public function getFromUrl() {
  69. return $this->fromUrl;
  70. }
  71. public function getTargetPath(){
  72. return $this->targetPath;
  73. }
  74. public function getToProduct() {
  75. return $this->toProduct;
  76. }
  77. public function getToCategory() {
  78. return $this->toCategory;
  79. }
  80. public function getToUrl() {
  81. return $this->toUrl;
  82. }
  83. public function setFromProduct($fromProduct) {
  84. $this->fromProduct = $fromProduct;
  85. }
  86. public function setFromCategory($fromCategory) {
  87. $this->fromCategory = $fromCategory;
  88. }
  89. public function setFromUrl($fromUrl) {
  90. $this->fromUrl = $fromUrl;
  91. }
  92. public function setTargetPath($targetPath) {
  93. $this->targetPath = $targetPath;
  94. }
  95. public function setToProduct($toProduct) {
  96. $this->toProduct = $toProduct;
  97. }
  98. public function setToCategory($toCategory) {
  99. $this->toCategory = $toCategory;
  100. }
  101. public function setToUrl($toUrl) {
  102. $this->toUrl = $toUrl;
  103. }
  104. public function toArray() : array{
  105. $output = [
  106. 'id' => $this->getId(),
  107. 'fromProduct' => $this->getFromProduct()?$this->getFromProduct()->toArray():null,
  108. 'fromCategory' => $this->getFromCategory()?$this->getFromCategory()->toArray():null,
  109. 'fromUrl' => $this->getFromUrl(),
  110. 'targetPath' => $this->getTargetPath(),
  111. 'toProduct' => $this->getToProduct()?$this->getToProduct()->toArray():null,
  112. 'toCategory' => $this->getToCategory()?$this->getToCategory()->toArray():null,
  113. 'toUrl' => $this->getToUrl(),
  114. ];
  115. return $output;
  116. }
  117. }