src/Entity/LessonXLibrary.php line 303

Open in your IDE?
  1. <?php
  2. namespace EADPlataforma\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. use EADPlataforma\Validator\Constraints as EADAssert;
  6. use EADPlataforma\Enum\LessonXLibraryEnum;
  7. use \DateTime;
  8. /**
  9.  * LessonXLibrary
  10.  *
  11.  * @ORM\Table(name="lesson_x_library", indexes={
  12.  *      @ORM\Index(name="fk_lesson_file_lesson_id", columns={"lesson_id"}), 
  13.  *      @ORM\Index(name="fk_lesson_file_library_id", columns={"library_id"}),
  14.  *      @ORM\Index(name="fk_lesson_user_delete_id", columns={"user_delete_id"})
  15.  * })
  16.  *
  17.  * @ORM\Entity(repositoryClass="EADPlataforma\Repository\LessonXLibraryRepository")
  18.  */
  19. class LessonXLibrary
  20. {
  21.     /**
  22.      * @var int
  23.      *
  24.      * @ORM\Column(name="id", type="integer", nullable=false)
  25.      * @ORM\Id
  26.      * @ORM\GeneratedValue(strategy="IDENTITY")
  27.      */
  28.     private $id;
  29.     /**
  30.      * @Assert\NotBlank(
  31.      *      message = "Deleted not informed"
  32.      * )
  33.      *
  34.      * @Assert\Choice(
  35.      *      choices = { 
  36.      *                      LessonXLibraryEnum::ITEM_NO_DELETED, 
  37.      *                      LessonXLibraryEnum::ITEM_ON_TRASH,
  38.      *                      LessonXLibraryEnum::ITEM_DELETED
  39.      *                },
  40.      *      message = "Delete Option Invalid"
  41.      * )
  42.      *
  43.      * @var int
  44.      *
  45.      * @ORM\Column(name="deleted", type="integer", nullable=false, options={"default"="0"})
  46.      */
  47.     private $deleted LessonXLibraryEnum::ITEM_NO_DELETED;
  48.     /**
  49.      * @Assert\NotBlank(
  50.      *    message = "Type not informed"
  51.      * )
  52.      *
  53.      * @Assert\Choice(
  54.      *      choices = { LessonXLibraryEnum::CONTENT, LessonXLibraryEnum::DOWNLOAD },
  55.      *      message = "Type Invalid"
  56.      * )
  57.      *
  58.      * @var int
  59.      *
  60.      * @ORM\Column(name="type", type="integer", nullable=false)
  61.      */
  62.     private $type;
  63.     /**
  64.      * @Assert\NotBlank(
  65.      *    message = "Control Show Document not informed"
  66.      * )
  67.      *
  68.      * @Assert\Choice(
  69.      *      choices = { LessonXLibraryEnum::NO, LessonXLibraryEnum::YES },
  70.      *      message = "Control Show Document Invalid"
  71.      * )
  72.      *
  73.      * @var int
  74.      *
  75.      * @ORM\Column(name="control_show_document", type="integer", nullable=false, options={"default"="0"})
  76.      */
  77.     private $controlShowDocument LessonXLibraryEnum::NO;
  78.     /**
  79.      * @Assert\NotBlank(
  80.      *    message = "Lesson not informed"
  81.      * )
  82.      *
  83.      * @Assert\Valid
  84.      *
  85.      * @var \Lesson
  86.      *
  87.      * @ORM\ManyToOne(targetEntity="Lesson")
  88.      * @ORM\JoinColumns({
  89.      *   @ORM\JoinColumn(name="lesson_id", referencedColumnName="id", nullable=false)
  90.      * })
  91.      */
  92.     private $lesson;
  93.     /**
  94.      * @Assert\NotBlank(
  95.      *    message = "Library not informed"
  96.      * )
  97.      *
  98.      * @Assert\Valid
  99.      *
  100.      * @var \Library
  101.      *
  102.      * @ORM\ManyToOne(targetEntity="Library")
  103.      * @ORM\JoinColumns({
  104.      *   @ORM\JoinColumn(name="library_id", referencedColumnName="id", nullable=false)
  105.      * })
  106.      */
  107.     private $library;
  108.     /**
  109.      * @Assert\Valid
  110.      *
  111.      * @var \EADPlataforma\Entity\User
  112.      *
  113.      * @ORM\ManyToOne(targetEntity="User")
  114.      * @ORM\JoinColumns({
  115.      *   @ORM\JoinColumn(name="user_delete_id", referencedColumnName="id", nullable=true)
  116.      * })
  117.      */
  118.     private $userDelete;
  119.     /**
  120.      * @Assert\Choice(
  121.      *      choices = { 
  122.      *                      LessonXLibraryEnum::INDIVIDUAL, 
  123.      *                      LessonXLibraryEnum::CASCADE
  124.      *                },
  125.      *      message = "Type Delete Invalid"
  126.      * )
  127.      *
  128.      * @var int
  129.      *
  130.      * @ORM\Column(name="type_delete", type="integer", nullable=true)
  131.      */
  132.     private $typeDelete;
  133.     /**
  134.      * @EADAssert\DateTimeEAD(
  135.      *      message = "Date Delete Invalid"
  136.      * )
  137.      *
  138.      * @var \DateTime|null
  139.      *
  140.      * @ORM\Column(name="date_delete", type="datetime", nullable=true)
  141.      */
  142.     private $dateDelete;
  143.     public function getId(): ?int
  144.     {
  145.         return $this->id;
  146.     }
  147.     public function getType($string false)
  148.     {
  149.         if($string){
  150.             return $this->stringType($this->type);
  151.         }
  152.         return $this->type;
  153.     }
  154.     public function setType(int $type): self
  155.     {
  156.         $this->type $type;
  157.         return $this;
  158.     }
  159.     public function getControlShowDocument(): ?int
  160.     {
  161.         return $this->controlShowDocument;
  162.     }
  163.     public function setControlShowDocument(int $controlShowDocument): self
  164.     {
  165.         $this->controlShowDocument $controlShowDocument;
  166.         return $this;
  167.     }
  168.     public function getLesson(): ?Lesson
  169.     {
  170.         return $this->lesson;
  171.     }
  172.     public function setLesson(?Lesson $lesson): self
  173.     {
  174.         $this->lesson $lesson;
  175.         return $this;
  176.     }
  177.     public function getLibrary(): ?Library
  178.     {
  179.         return $this->library;
  180.     }
  181.     public function setLibrary(?Library $library): self
  182.     {
  183.         $this->library $library;
  184.         return $this;
  185.     }
  186.     public function getUserDelete(): ?User
  187.     {
  188.         return $this->userDelete;
  189.     }
  190.     public function setUserDelete(?User $userDelete): self
  191.     {
  192.         $this->userDelete $userDelete;
  193.         return $this;
  194.     }
  195.     public function getDateDelete($dateFormat 'Y-m-d H:i:s')
  196.     {
  197.         if($this->dateDelete){
  198.             return $this->dateDelete->format($dateFormat);
  199.         }
  200.         return $this->dateDelete;
  201.     }
  202.     public function setDateDelete($dateDelete): self
  203.     {
  204.         if(!empty($dateDelete)){
  205.             $dateDelete DateTime::createFromFormat('Y-m-d H:i:s'$dateDelete);
  206.         }
  207.         
  208.         $this->dateDelete $dateDelete;
  209.         return $this;
  210.     }
  211.     public function individual(): self
  212.     {
  213.         $this->typeDelete LessonXLibraryEnum::INDIVIDUAL;
  214.         return $this;
  215.     }
  216.     public function cascade(): self
  217.     {
  218.         $this->typeDelete LessonXLibraryEnum::CASCADE;
  219.         return $this;
  220.     }
  221.     public function isOnTrash(): bool
  222.     {
  223.         return ($this->deleted == LessonXLibraryEnum::ITEM_ON_TRASH);
  224.     }
  225.     public function isDeleted(): bool
  226.     {
  227.         return ($this->deleted == LessonXLibraryEnum::ITEM_DELETED);
  228.     }
  229.     public function restore(): self
  230.     {
  231.         $this->deleted LessonXLibraryEnum::ITEM_NO_DELETED;
  232.         return $this;
  233.     }
  234.     public function trash(): self
  235.     {
  236.         $this->deleted LessonXLibraryEnum::ITEM_ON_TRASH;
  237.         return $this;
  238.     }
  239.     public function delete(): self
  240.     {
  241.         $this->deleted LessonXLibraryEnum::ITEM_DELETED;
  242.         return $this;
  243.     }
  244.     public function stringType($type){
  245.         $string '';
  246.         switch ($type) {
  247.             case LessonXLibraryEnum::CONTENT:
  248.                 $string 'Lesson';
  249.             break;
  250.             case LessonXLibraryEnum::DOWNLOAD:
  251.                 $string 'Download';
  252.             break;
  253.         }
  254.         return $string;
  255.     }
  256.     public function toReturn(){
  257.         $data = (object)[
  258.             "id" => $this->id,
  259.             "deleted" => $this->deleted,
  260.             "type" => $this->type,
  261.             "controlShowDocument" => $this->controlShowDocument,
  262.             "libraryPdfSvgMode" => ( $this->library $this->library->getPdfSvgMode() : null ),
  263.             "lesson" => ( $this->lesson $this->lesson->getId() : null ),
  264.             "library" => ( $this->library $this->library->getId() : null ),
  265.             "libraryTitle" => ( $this->library $this->library->getTitle() : null ),
  266.             "libraryDownloadNumber" => ( $this->library $this->library->getDownloadNumber() : null),
  267.             "libraryType" => ( $this->library $this->library->getType() : null),
  268.             "libraryLink" => ( $this->library $this->library->getLink() : null),
  269.             "libraryText" => ( $this->library $this->library->getText() : null),
  270.             "libraryFile" => ( $this->library $this->library->getFileName() : null),
  271.             "libraryFileSize" => ( $this->library $this->library->getFileSize() : null),
  272.             "libraryFileExtension" => ( $this->library $this->library->getFileExtension() : null),
  273.             "libraryPagesNumber" => ( $this->library $this->library->getPagesNumber() : null),
  274.             "libraryDuration" => ( $this->library $this->library->getDuration() : null),
  275.             "libraryLiveStart" => ( $this->library $this->library->getLiveStart() : null),
  276.             "libraryLiveCover" => ( $this->library $this->library->getLiveCover() : null),
  277.             "libraryLiveLinkTransmit" => ( 
  278.                 $this->library $this->library->getLiveLinkTransmit() : null
  279.             ),
  280.             "libraryLiveLink" => ( $this->library $this->library->getLiveLink() : null),
  281.             "libraryLiveToken" => ( $this->library $this->library->getLiveToken() : null),
  282.             "libraryLiveIdEvent" => ( $this->library $this->library->getLiveIdEvent() : null),
  283.             "libraryshowTextPdf" => ( $this->library $this->library->getShowTextPdf() : null),
  284.             "userDelete" => ( $this->userDelete $this->userDelete->getId() : null ),
  285.             "typeDelete" => $this->typeDelete,
  286.             "dateDelete" => $this->getDateDelete()
  287.         ];
  288.         return $data;
  289.     }
  290. }