src/Entity/ProductFeaturingRotation.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Validator\Constraints as AppAssert;
  4. use App\Entity\Product\ConfirmedProduct;
  5. use DateTime;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Exception;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. /**
  11.  * ProductFeaturing
  12.  *
  13.  * @ORM\Table(name="product_featuring_rotation")
  14.  * @ORM\Entity()
  15.  * @ORM\HasLifecycleCallbacks()
  16.  * @AppAssert\ProductFeaturingRotation
  17.  */
  18. class ProductFeaturingRotation
  19. {
  20.     /**
  21.      * @var int
  22.      *
  23.      * @ORM\Column(name="id", type="integer")
  24.      * @ORM\Id
  25.      * @ORM\GeneratedValue(strategy="AUTO")
  26.      */
  27.     private $id;
  28.     /**
  29.      * @var int
  30.      *
  31.      * @ORM\Column(name="priority", type="integer")
  32.      * @Assert\NotBlank()
  33.      * @Assert\GreaterThan(0)
  34.      */
  35.     private $priority;
  36.     /**
  37.      * @ORM\ManyToMany(targetEntity="App\Entity\Product\ConfirmedProduct")
  38.      * @ORM\JoinTable(name="malys_product_feature_rotation_product",
  39.      *     joinColumns={@ORM\JoinColumn(name="product_featuring_rotation_id", referencedColumnName="id", onDelete="cascade")}
  40.      *     )
  41.      * @Assert\Count(min=1)
  42.      * @Assert\All(
  43.      *     @Assert\Type("App\Entity\Product\ConfirmedProduct")
  44.      * )
  45.      */
  46.     protected $products;
  47.     /**
  48.      * @var ProductFeaturing
  49.      *
  50.      * @ORM\ManyToOne(targetEntity="ProductFeaturing", inversedBy="rotations")
  51.      * @ORM\JoinColumn(name="product_featuring_id", referencedColumnName="id", onDelete="cascade")
  52.      */
  53.     protected $productFeaturing;
  54.     /**
  55.      * @var DateTime
  56.      *
  57.      * @ORM\Column(name="createdAt", type="datetime", nullable=false)
  58.      * @Assert\DateTime()
  59.      */
  60.     protected $createdAt;
  61.     /**
  62.      * @var DateTime
  63.      *
  64.      * @ORM\Column(name="updatedAt", type="datetime", nullable=false)
  65.      * @Assert\DateTime()
  66.      */
  67.     protected $updatedAt;
  68.     public function __construct()
  69.     {
  70.         $this->products = new ArrayCollection();
  71.     }
  72.     /**
  73.      * Get id.
  74.      *
  75.      * @return int
  76.      */
  77.     public function getId()
  78.     {
  79.         return $this->id;
  80.     }
  81.     /**
  82.      * @return DateTime
  83.      */
  84.     public function getCreatedAt()
  85.     {
  86.         return $this->createdAt;
  87.     }
  88.     /**
  89.      * Set createdAt
  90.      *
  91.      * @return ProductFeaturingRotation
  92.      * @throws Exception
  93.      * @ORM\PrePersist
  94.      */
  95.     public function setCreatedAt()
  96.     {
  97.         $this->createdAt = new DateTime();
  98.         $this->updatedAt = new DateTime();
  99.         return $this;
  100.     }
  101.     /**
  102.      * @return DateTime
  103.      */
  104.     public function getUpdatedAt()
  105.     {
  106.         return $this->updatedAt;
  107.     }
  108.     /**
  109.      * Set updatedAt
  110.      *
  111.      * @return ProductFeaturingRotation
  112.      * @throws Exception
  113.      * @ORM\PreUpdate
  114.      */
  115.     public function setUpdatedAt()
  116.     {
  117.         $this->updatedAt = new DateTime();
  118.         return $this;
  119.     }
  120.     /**
  121.      * @return int
  122.      */
  123.     public function getPriority()
  124.     {
  125.         return $this->priority;
  126.     }
  127.     /**
  128.      * @param int $priority
  129.      */
  130.     public function setPriority(int $priority)
  131.     {
  132.         $this->priority $priority;
  133.     }
  134.     /**
  135.      * @return mixed
  136.      */
  137.     public function getProducts()
  138.     {
  139.         return $this->products;
  140.     }
  141.     /**
  142.      * @param mixed $products
  143.      */
  144.     public function setProducts($products)
  145.     {
  146.         $this->products $products;
  147.     }
  148.     public function addProduct(ConfirmedProduct $product)
  149.     {
  150.         if (!$this->products->contains($product)) {
  151.             $this->products->add($product);
  152.         }
  153.         return $this;
  154.     }
  155.     public function removeProduct(ConfirmedProduct $product)
  156.     {
  157.         $this->products->removeElement($product);
  158.         return $this;
  159.     }
  160.     /**
  161.      * @return ProductFeaturing
  162.      */
  163.     public function getProductFeaturing(): ProductFeaturing
  164.     {
  165.         return $this->productFeaturing;
  166.     }
  167.     /**
  168.      * @param ProductFeaturing $productFeaturing
  169.      */
  170.     public function setProductFeaturing($productFeaturing)
  171.     {
  172.         $this->productFeaturing $productFeaturing;
  173.     }
  174. }