src/Postroyka/AppBundle/Entity/PageDefected.php line 19

Open in your IDE?
  1. <?php
  2. namespace Postroyka\AppBundle\Entity;
  3. use DateTime;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Submarine\CoreBundle\Entity\SubmarineEntityInterface;
  8. use Submarine\CoreBundle\Uploader\AbstractUploadEntity;
  9. use Submarine\FilesBundle\Entity\Image;
  10. use Submarine\PagesBundle\Entity\Page;
  11. use Symfony\Component\HttpFoundation\File\File;
  12. /**
  13.  * @ORM\Entity
  14.  * @ORM\Table(name="page_defected")
  15.  */
  16. class PageDefected extends AbstractUploadEntity implements
  17.     SubmarineEntityInterface
  18. {
  19.     /**
  20.      * @var integer|null
  21.      *
  22.      * @ORM\Id
  23.      * @ORM\GeneratedValue(strategy="AUTO")
  24.      * @ORM\Column(type="integer")
  25.      */
  26.     private int $id;
  27.     /**
  28.      * @var string|null
  29.      *
  30.      * @ORM\Column(type="text", nullable=true)
  31.      */
  32.     private ?string $reason;
  33.     /**
  34.      * @ORM\ManyToMany(targetEntity="Submarine\FilesBundle\Entity\Image")
  35.      * @ORM\JoinTable(name="pages_defected_images",
  36.      *      joinColumns={@ORM\JoinColumn(name="page_defected_id", referencedColumnName="id", onDelete="CASCADE")},
  37.      *      inverseJoinColumns={@ORM\JoinColumn(name="image_id", referencedColumnName="id", onDelete="CASCADE", unique=true)}
  38.      *      )
  39.      * @var Collection<int, Image>
  40.      */
  41.     private Collection $images;
  42.     /**
  43.      * @var float|null
  44.      *
  45.      * @ORM\Column(type="float", scale=2, nullable=true)
  46.      */
  47.     private ?float $cost;
  48.     /**
  49.      * @var integer
  50.      *
  51.      * @ORM\Column(type="integer", nullable=true)
  52.      */
  53.     private int $maxCount;
  54.     /**
  55.      * @var bool
  56.      *
  57.      * @ORM\Column(type="boolean")
  58.      */
  59.     private bool $isActive false;
  60.     /**
  61.      * @var DateTime
  62.      *
  63.      * @ORM\Column(type="datetime")
  64.      */
  65.     private \DateTimeInterface $updatedAt;
  66.     /**
  67.      * @var Page
  68.      *
  69.      * @ORM\OneToOne(targetEntity="Submarine\PagesBundle\Entity\Page", inversedBy="pageDefected")
  70.      * @ORM\JoinColumn(name="page_id", referencedColumnName="id", onDelete="CASCADE")
  71.      */
  72.     private Page $parent;
  73.     /**
  74.      * @ORM\Column(type="integer", nullable=true)
  75.      */
  76.     private ?int $b24Id;
  77.     /**
  78.      * @ORM\Column(type="integer", nullable=true)
  79.      */
  80.     private ?int $b24TimeInfoUpdate;
  81.     /**
  82.      * @ORM\Column(type="integer", nullable=true)
  83.      */
  84.     private ?int $b24StatusUpdate;
  85.     /**
  86.      * @ORM\Column(type="integer", nullable=true)
  87.      */
  88.     private ?int $b24PriceUpdate;
  89.     //support data
  90.     /** @var File */
  91.     private $file;
  92.     /** @var string */
  93.     private $image;
  94.     //support data
  95.     public function __construct(Page $product)
  96.     {
  97.         $this->updatedAt = new DateTime();
  98.         $this->isActive false;
  99.         $this->maxCount 1;
  100.         $this->parent $product;
  101.         $this->images = new ArrayCollection();
  102.         $this->b24StatusUpdate null;
  103.         $this->b24PriceUpdate null;
  104.         $this->b24TimeInfoUpdate null;
  105.     }
  106.     /**
  107.      * @return int|null
  108.      */
  109.     public function getId(): ?int
  110.     {
  111.         return $this->id;
  112.     }
  113.     /**
  114.      * @param int|null $id
  115.      */
  116.     public function setId(?int $id): void
  117.     {
  118.         $this->id $id;
  119.     }
  120.     /**
  121.      * @return string|null
  122.      */
  123.     public function getReason(): ?string
  124.     {
  125.         return $this->reason;
  126.     }
  127.     /**
  128.      * @param string|null $reason
  129.      */
  130.     public function setReason(?string $reason): void
  131.     {
  132.         $this->reason $reason;
  133.     }
  134.     /**
  135.      * @return Collection
  136.      */
  137.     public function getImages(): ArrayCollection|Collection
  138.     {
  139.         return $this->images;
  140.     }
  141.     /**
  142.      * @param Collection $images
  143.      */
  144.     public function setImages(ArrayCollection|Collection $images): void
  145.     {
  146.         $this->images $images;
  147.     }
  148.     /**
  149.      * @return float|null
  150.      */
  151.     public function getCost(): ?float
  152.     {
  153.         return $this->cost;
  154.     }
  155.     /**
  156.      * @param float|null $cost
  157.      */
  158.     public function setCost(?float $cost): void
  159.     {
  160.         $this->cost $cost;
  161.     }
  162.     /**
  163.      * @return int
  164.      */
  165.     public function getMaxCount(): int
  166.     {
  167.         return $this->maxCount;
  168.     }
  169.     /**
  170.      * @param int $maxCount
  171.      */
  172.     public function setMaxCount(int $maxCount): void
  173.     {
  174.         $this->maxCount $maxCount;
  175.     }
  176.     /**
  177.      * @return bool
  178.      */
  179.     public function isActive(): bool
  180.     {
  181.         return $this->isActive;
  182.     }
  183.     /**
  184.      * @param bool $isActive
  185.      */
  186.     public function setIsActive(bool $isActive): void
  187.     {
  188.         $this->isActive $isActive;
  189.     }
  190.     /**
  191.      * @return DateTime
  192.      */
  193.     public function getUpdatedAt(): DateTime
  194.     {
  195.         return $this->updatedAt;
  196.     }
  197.     /**
  198.      * @param DateTime $updatedAt
  199.      */
  200.     public function setUpdatedAt(DateTime $updatedAt): void
  201.     {
  202.         $this->updatedAt $updatedAt;
  203.     }
  204.     /**
  205.      * @return Page
  206.      */
  207.     public function getParent(): Page
  208.     {
  209.         return $this->parent;
  210.     }
  211.     /**
  212.      * @param Page $parent
  213.      */
  214.     public function setParent(Page $parent): void
  215.     {
  216.         $this->parent $parent;
  217.     }
  218.     /**
  219.      * @return int|null
  220.      */
  221.     public function getB24Id(): ?int
  222.     {
  223.         return $this->b24Id;
  224.     }
  225.     /**
  226.      * @param int|null $b24Id
  227.      */
  228.     public function setB24Id(?int $b24Id): void
  229.     {
  230.         $this->b24Id $b24Id;
  231.     }
  232.     /**
  233.      * @return int|null
  234.      */
  235.     public function getB24TimeInfoUpdate(): ?int
  236.     {
  237.         return $this->b24TimeInfoUpdate;
  238.     }
  239.     /**
  240.      * @param int|null $b24TimeInfoUpdate
  241.      */
  242.     public function setB24TimeInfoUpdate(?int $b24TimeInfoUpdate): void
  243.     {
  244.         $this->b24TimeInfoUpdate $b24TimeInfoUpdate;
  245.     }
  246.     /**
  247.      * @return int|null
  248.      */
  249.     public function getB24StatusUpdate(): ?int
  250.     {
  251.         return $this->b24StatusUpdate;
  252.     }
  253.     /**
  254.      * @param int|null $b24StatusUpdate
  255.      */
  256.     public function setB24StatusUpdate(?int $b24StatusUpdate): void
  257.     {
  258.         $this->b24StatusUpdate $b24StatusUpdate;
  259.     }
  260.     /**
  261.      * @return int|null
  262.      */
  263.     public function getB24PriceUpdate(): ?int
  264.     {
  265.         return $this->b24PriceUpdate;
  266.     }
  267.     /**
  268.      * @param int|null $b24PriceUpdate
  269.      */
  270.     public function setB24PriceUpdate(?int $b24PriceUpdate): void
  271.     {
  272.         $this->b24PriceUpdate $b24PriceUpdate;
  273.     }
  274.     //support methods
  275.     /**
  276.      * Установка файла
  277.      *
  278.      * @param File $file
  279.      */
  280.     public function setFile(File $file null)
  281.     {
  282.         $this->file $file;
  283.     }
  284.     /**
  285.      * Получение файла
  286.      * @return File
  287.      */
  288.     public function getFile()
  289.     {
  290.         return $this->file;
  291.     }
  292.     /**
  293.      * Имя сущности
  294.      * @return string
  295.      */
  296.     public static function entityName()
  297.     {
  298.         return __CLASS__;
  299.     }
  300.     /**
  301.      * Путь к файлу
  302.      *
  303.      * @param string $filePath
  304.      */
  305.     public function setFilePath($filePath)
  306.     {
  307.         $this->image $filePath;
  308.     }
  309.     /**
  310.      * Путь к файлу
  311.      * @return string
  312.      */
  313.     public function getFilePath()
  314.     {
  315.         return $this->image;
  316.     }
  317.     public function postUpload(SubmarineEntityInterface $file) : void
  318.     {
  319.         $this->images->add($file);
  320.     }
  321.     //support methods
  322. }