src/Entity/DocFile.php line 130

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Upload;
  4. use App\Annotation\EsUploadable;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use App\Annotation\EsElasticIndex;
  7. use App\Filter\SearchWithTagFilter;
  8. use App\Repository\DocFileRepository;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. use ApiPlatform\Core\Annotation\ApiFilter;
  11. use Doctrine\Common\Collections\Collection;
  12. use ApiPlatform\Core\Annotation\ApiProperty;
  13. use ApiPlatform\Core\Annotation\ApiResource;
  14. use App\Entity\Interfaces\OwnerMappedInterface;
  15. use App\Entity\Interfaces\UploadMappedInterface;
  16. use Doctrine\Common\Collections\ArrayCollection;
  17. use App\Entity\Interfaces\ElasticMappedInterface;
  18. use App\Entity\Interfaces\ContainerMappedInterface;
  19. use App\Entity\Interfaces\NewsfeedCreatorInterface;
  20. use Symfony\Component\Serializer\Annotation\Groups;
  21. use Symfony\Component\Validator\Constraints as Assert;
  22. use Symfony\Component\Serializer\Annotation\SerializedName;
  23. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  24. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\ExistsFilter;
  25. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  26. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
  27. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  28. /**
  29.  * @ApiResource(
  30.  *      attributes={"security"="is_granted('ROLE_OPERATOR')"},
  31.  *      normalizationContext={"groups"={"DocFile:Read"}, "skip_null_values"=false},
  32.  *      denormalizationContext={"groups"={"DocFile:Write"}},
  33.  *      collectionOperations={
  34.  *          "get"={"security"="is_granted('IS_AUTHENTICATED_FULLY')"},
  35.  *          "get_for_filter"={
  36.  *              "path"="/doc_files/get-for-filter",
  37.  *              "method"="GET",
  38.  *              "security"="is_granted('IS_AUTHENTICATED_FULLY')"
  39.  *          },
  40.  *          "get_public"={
  41.  *              "path"="/doc_files/get-public",
  42.  *              "method"="GET",
  43.  *              "normalization_context"={"groups"={"DocFile:Read"}, "skip_null_values"=false},
  44.  *              "security"="is_granted('IS_AUTHENTICATED_FULLY')"
  45.  *          },
  46.  *          "get_for_select"={
  47.  *              "path"="/doc_files/get-for-select",
  48.  *              "method"="GET",
  49.  *              "normalization_context"={"groups"={"DocFile:Read"}, "skip_null_values"=false},
  50.  *              "security"="is_granted('ROLE_OPERATOR')"
  51.  *          },
  52.  *          "get_for_feed"={
  53.  *              "path"="/doc_files/get-for-feed",
  54.  *              "method"="GET",
  55.  *              "normalization_context"={"groups"={"DocFile:Read"}, "skip_null_values"=false},
  56.  *              "security"="is_granted('IS_AUTHENTICATED_FULLY')"
  57.  *          },
  58.  *          "get_user_saved"={
  59.  *              "path"="/doc_files/get-user-saved",
  60.  *              "method"="GET",
  61.  *              "normalization_context"={"groups"={"DocFile:Read", "TZ:Read"}, "skip_null_values"=false},
  62.  *              "security"="is_granted('IS_AUTHENTICATED_FULLY')"
  63.  *          },
  64.  *          "post"={
  65.  *              "route_name"="api_doc_files_post_collection",
  66.  *              "method"="POST",
  67.  *              "security"="is_granted('IS_AUTHENTICATED_FULLY')"
  68.  *          },
  69.  *          "post_bulk_operation"={
  70.  *              "route_name"="api_doc_files_bulk_operation_collection",
  71.  *              "method"="POST",
  72.  *              "denormalization_context"={"groups"={"DocFile:BulkOperation"}},
  73.  *              "security"="is_granted('IS_AUTHENTICATED_FULLY')"
  74.  *          },
  75.  *          "post_ai_assistant_upload"={
  76.  *              "route_name"="api_doc_files_ai_assistant_upload_collection",
  77.  *              "method"="POST",
  78.  *              "denormalization_context"={"groups"={"DocFile:AiAssistantUpload"}},
  79.  *              "security"="is_granted('IS_AUTHENTICATED_FULLY')"
  80.  *          },
  81.  *          "post_ai_assistant_query"={
  82.  *              "route_name"="api_doc_files_ai_assistant_query_collection",
  83.  *              "method"="POST",
  84.  *              "denormalization_context"={"groups"={"DocFile:AiAssistantQuery"}},
  85.  *              "security"="is_granted('IS_AUTHENTICATED_FULLY')"
  86.  *          },
  87.  *      },
  88.  *      itemOperations={
  89.  *          "get"={
  90.  *              "security"="is_granted('IS_AUTHENTICATED_FULLY')",
  91.  *              "normalization_context"={"groups"={"DocFile:Read", "DocFile:AllParents", "DocFile:Versions"}, "skip_null_values"=false},
  92.  *          },
  93.  *          "get_dicom"={
  94.  *              "path"="/doc_files/{id}/get-dicom",
  95.  *              "method"="GET",
  96.  *              "normalization_context"={"groups"={"DocFile:Read", "DocFile:Read-Dicom"}, "skip_null_values"=false},
  97.  *              "security"="is_granted('IS_CO_USR_SPE', object) || is_granted('IS_CO_OPR', object) || is_granted('IS_CO_ANY_SPE_DOCFILE_AUTHOR', object)"
  98.  *          },
  99.  *          "get_download"={
  100.  *              "route_name"="api_doc_files_download_item",
  101.  *              "method"="GET",
  102.  *              "security"="is_granted('IS_AUTHENTICATED_FULLY')"
  103.  *          },
  104.  *          "get_download_with_version"={
  105.  *              "route_name"="api_doc_files_download_with_version_item",
  106.  *              "method"="GET",
  107.  *              "security"="is_granted('IS_AUTHENTICATED_FULLY')"
  108.  *          },
  109.  *          "put"={"security"="is_granted('IS_CO_OPR', object) || is_granted('IS_CO_USR_SPE', object) || is_granted('IS_CO_ANY_SPE_DOCFILE_AUTHOR', object)"},
  110.  *          "patch"={"security"="is_granted('IS_CO_OPR', object) || is_granted('IS_CO_USR_SPE', object) || is_granted('IS_CO_ANY_SPE_DOCFILE_AUTHOR', object)"},
  111.  *          "delete"={"security"="is_granted('IS_CO_OPR', object) || is_granted('IS_CO_USR_SPE', object) || is_granted('IS_CO_ANY_SPE_DOCFILE_AUTHOR', object)"}
  112.  *     }
  113.  * )
  114.  * @ApiFilter(SearchFilter::class, properties={"id": "exact", "container.id": "exact", "parent.id": "exact", "user.id": "exact", "userGroups.id": "exact", "docFileTags.id": "exact", "docFileType": "exact", "origFileName": "partial", "fileName": "partial", "authors.id", "exact"})
  115.  * @ApiFilter(SearchWithTagFilter::class, properties={"search_with_tag": "partial"})
  116.  * @ApiFilter(OrderFilter::class, properties={"id": "ASC", "origFileName", "fileName", "size", "docFileType", "parent", "createdAt", "updatedAt"})
  117.  * @ApiFilter(BooleanFilter::class, properties={"isActive", "isShowDocHub", "isDownload", "isPublic"})
  118.  * @ApiFilter(ExistsFilter::class, properties={"parent.id"})
  119.  * @ORM\Entity(repositoryClass=DocFileRepository::class)
  120.  * @UniqueEntity(fields={"origFileName", "parent"}, errorPath="origFileName")
  121.  * @ORM\Table(
  122.  *      name="doc_file",
  123.  *      indexes={@ORM\Index(name="docfile_fileName_idx", columns={"orig_file_name"})}
  124.  * )
  125.  * @EsElasticIndex("DocFile:EL")
  126.  */
  127. class DocFile implements ContainerMappedInterfaceOwnerMappedInterfaceUploadMappedInterfaceNewsfeedCreatorInterfaceElasticMappedInterface
  128. {
  129.     /**
  130.      * @var \DateTime
  131.      * @Gedmo\Timestampable(on="create")
  132.      * @ORM\Column(type="datetime")
  133.      *
  134.      * @Groups({"DocFile:EL", "DocFile:Read", "DocFile:Write", "ElTask:Read", "ElExam:Read-Solution"})
  135.      */
  136.     protected $createdAt;
  137.     /**
  138.      * @var \DateTime
  139.      * @Gedmo\Timestampable(on="update")
  140.      * @ORM\Column(type="datetime")
  141.      *
  142.      * @Groups({"DocFile:EL", "DocFile:Read", "DocFile:Write"})
  143.      */
  144.     protected $updatedAt;
  145.     public function setCreatedAt(\DateTime $createdAt)
  146.     {
  147.         $this->createdAt $createdAt;
  148.         return $this;
  149.     }
  150.     public function getCreatedAt()
  151.     {
  152.         return $this->createdAt;
  153.     }
  154.     public function setUpdatedAt(\DateTime $updatedAt)
  155.     {
  156.         $this->updatedAt $updatedAt;
  157.         return $this;
  158.     }
  159.     public function getUpdatedAt()
  160.     {
  161.         return $this->updatedAt;
  162.     }
  163.     /**
  164.      * @ORM\Id
  165.      * @ORM\GeneratedValue
  166.      * @ORM\Column(type="integer")
  167.      * @Groups({"DocFile:EL", "DocFile:Read", "ElTask:Read", "ElExam:Read-Solution"})
  168.      */
  169.     private $id;
  170.     /**
  171.      * @ORM\Column(type="string", length=255, nullable=true)
  172.      * @Groups({"DocFile:EL", "DocFile:Read", "DocFile:Write", "ElTask:Read", "ElExam:Read-Solution"})
  173.      * @EsUploadable()
  174.      */
  175.     protected $fileName;
  176.     /**
  177.      * @ORM\Column(type="string", length=32)
  178.      * @Groups({"DocFile:EL", "DocFile:Read", "DocFile:Write", "ElTask:Read", "ElExam:Read-Solution"})
  179.      */
  180.     private $docFileType;
  181.     public const DOCFILE_TYPE_FOLDER "FOLDER";
  182.     public const DOCFILE_TYPE_URL "URL";
  183.     public const DOCFILE_TYPE_DICOM "DICOM";
  184.     /**
  185.      * @ORM\ManyToOne(targetEntity=DocFile::class, inversedBy="childrens")
  186.      * @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
  187.      * @Groups({"DocFile:Read", "DocFile:Write", "ElTask:Read", "ElExam:Read-Solution"})
  188.      * @ApiProperty(readableLink=false, writableLink=false)
  189.      */
  190.     private $parent;
  191.     /**
  192.      * @ORM\OneToMany(targetEntity=DocFile::class, mappedBy="parent")
  193.      */
  194.     private $childrens;
  195.     /**
  196.      * @ORM\Column(type="integer", nullable=true)
  197.      * @Groups({"DocFile:EL", "DocFile:Read", "DocFile:Write", "ElTask:Read", "ElExam:Read-Solution"})
  198.      */
  199.     private $size;
  200.     /**
  201.      * @ORM\ManyToOne(targetEntity=Container::class)
  202.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  203.      * @Groups({"DocFile:Write"})
  204.      */
  205.     private $container;
  206.     /**
  207.      * @ORM\ManyToOne(targetEntity=User::class)
  208.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  209.      * @Groups({"DocFile:Read"})
  210.      */
  211.     private $user;
  212.     /**
  213.      * @ORM\ManyToMany(targetEntity=UserGroup::class)
  214.      * @Groups({"DocFile:Read", "DocFile:Write"})
  215.      */
  216.     private $userGroups;
  217.     /**
  218.      * @ORM\ManyToMany(targetEntity=DocFileTag::class, inversedBy="docFiles", cascade={"persist"})
  219.      * @Groups({"DocFile:Read", "DocFile:Write"})
  220.      */
  221.     private $docFileTags;
  222.     /**
  223.      * @var string
  224.      * @Groups({"DocFile:BulkOperation"})
  225.      */
  226.     private $operation;
  227.     public const DOCFILE_OPERATION_COPY "COPY";
  228.     public const DOCFILE_OPERATION_MOVE "MOVE";
  229.     public const DOCFILE_OPERATION_DELETE "DELETE";
  230.     public const DOCFILE_OPERATION_DOWNLOAD "DOWNLOAD";
  231.     /**
  232.      * @var int[]
  233.      * @Groups({"DocFile:BulkOperation"})
  234.      */
  235.     private $source;
  236.     /**
  237.      * @var ?int
  238.      * @Groups({"DocFile:BulkOperation"})
  239.      */
  240.     private $target;
  241.     /**
  242.      * @ORM\Column(type="string", length=255)
  243.      * @Groups({"DocFile:EL", "DocFile:Read", "DocFile:Write", "ElTask:Read", "ElExam:Read-Solution"})
  244.      */
  245.     private $origFileName;
  246.     /**
  247.      * @ORM\Column(type="json", nullable=true)
  248.      * @Groups({"DocFile:Read"})
  249.      */
  250.     private $path = [];
  251.     /**
  252.      * @ORM\OneToMany(targetEntity=DocFileBlock::class, mappedBy="docFile", orphanRemoval=true, cascade={"persist"})
  253.      * @Groups({"DocFile:Read"})
  254.      */
  255.     private $docFileBlocks;
  256.     /**
  257.      * @ORM\OneToMany(targetEntity=CommonComment::class, mappedBy="docFile")
  258.      */
  259.     private $commonComments;
  260.     /**
  261.      * @ORM\Column(type="boolean", nullable=true)
  262.      * @Groups({"DocFile:Read", "DocFile:Write", "ElTask:Read", "ElExam:Read-Solution"})
  263.      */
  264.     private $isPublic;
  265.     /**
  266.      * @ORM\Column(type="boolean", nullable=true)
  267.      * @Groups({"DocFile:EL", "DocFile:Read", "DocFile:Write", "ElTask:Read", "ElExam:Read-Solution"})
  268.      */
  269.     private $isDownload true;
  270.     /**
  271.      * @ORM\ManyToMany(targetEntity=User::class)
  272.      * @Groups({"DocFile:EL", "DocFile:Read", "DocFile:Write"})
  273.      */
  274.     private $authors;
  275.     /**
  276.      * @ORM\Column(type="boolean", nullable=true)
  277.      * @Groups({"DocFile:Read", "DocFile:Write", "ElTask:Read", "ElExam:Read-Solution"})
  278.      */
  279.     private $isShowDocHub;
  280.     /**
  281.      * @ORM\Column(type="boolean", nullable=true)
  282.      * @Groups({"DocFile:Read", "DocFile:Write", "ElTask:Read", "ElExam:Read-Solution"})
  283.      */
  284.     private $isActive;
  285.     /**
  286.      * @ORM\Column(type="boolean", nullable=true)
  287.      * @Groups({"DocFile:Read", "DocFile:Write", "ElTask:Read", "ElExam:Read-Solution"})
  288.      */
  289.     private $isCommentEnable true;
  290.     /**
  291.      * @ORM\Column(type="string", length=255, nullable=true)
  292.      * @Groups({"DocFile:EL", "DocFile:Read", "DocFile:Write", "ElTask:Read", "ElExam:Read-Solution"})
  293.      * @EsUploadable()
  294.      */
  295.     private $imageName;
  296.     /**
  297.      * @ORM\Column(type="string", length=255, nullable=true)
  298.      * @Groups({"DocFile:Read", "DocFile:Write"})
  299.      */
  300.     private $url;
  301.     /**
  302.      * @ORM\Column(type="json", nullable=true)
  303.      * @Groups({"DocFile:Read-Dicom", "DocFile:Write"})
  304.      */
  305.     private $dicomFileInfo = [];
  306.     /**
  307.      * @ORM\ManyToOne(targetEntity=CommonCategory::class)
  308.      * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
  309.      *
  310.      * @Groups({"DocFile:Read", "DocFile:Write"})
  311.      */
  312.     private $docFileCategory;
  313.     /**
  314.      * @ORM\Column(type="string", length=32, nullable=true)
  315.      * @Groups({"DocFile:Read", "DocFile:Write"})
  316.      */
  317.     private $reminderDurationType;
  318.     public const DOCFILE_REMINDERDURATIONTYPE_DAY "DAY";
  319.     public const DOCFILE_REMINDERDURATIONTYPE_MONTH "MONTH";
  320.     public const DOCFILE_REMINDERDURATIONTYPE_YEAR "YEAR";
  321.     /**
  322.      * @ORM\Column(type="integer", nullable=true)
  323.      * @Groups({"DocFile:Read", "DocFile:Write"})
  324.      */
  325.     private $reminderDuration;
  326.     /**
  327.      * @ORM\Column(type="boolean", nullable=true)
  328.      * @Groups({"DocFile:Read", "DocFile:Write"})
  329.      */
  330.     private $isReminderRepeat;
  331.     /**
  332.      * @ORM\Column(type="datetime", nullable=true)
  333.      * @Groups({"DocFile:Read"})
  334.      */
  335.     private $nextReminder;
  336.     /**
  337.      * @ORM\OneToMany(targetEntity=DocFileVersion::class, mappedBy="docFile", orphanRemoval=true, cascade={"persist"})
  338.      * @Groups({"DocFile:Versions", "DocFile:Write"})
  339.      */
  340.     private $docFileVersions;
  341.     /**
  342.      * @var int
  343.      * @Groups({"DocFile:AiAssistantUpload"})
  344.      */
  345.     private $docFileId;
  346.     /**
  347.      * @var string
  348.      * @Groups({"DocFile:AiAssistantQuery"})
  349.      */
  350.     private $aiAssistantQuestion;
  351.     /**
  352.      * @var string
  353.      * @Groups({"DocFile:AiAssistantQuery"})
  354.      */
  355.     private $aiAssistantFileId;
  356.     /**
  357.      * @ORM\OneToMany(targetEntity=DocFileSaved::class, mappedBy="docFile")
  358.      */
  359.     private $docFileSaved;
  360.     /**
  361.      * @ORM\Column(type="string", length=255, nullable=true)
  362.      */
  363.     private $aiFileId;
  364.     public function __construct()
  365.     {
  366.         $this->childrens = new ArrayCollection();
  367.         $this->userGroups = new ArrayCollection();
  368.         $this->docFileTags = new ArrayCollection();
  369.         $this->docFileBlocks = new ArrayCollection();
  370.         $this->commonComments = new ArrayCollection();
  371.         $this->isDownload true;
  372.         $this->isShowDocHub true;
  373.         $this->isCommentEnable true;
  374.         $this->authors = new ArrayCollection();
  375.         $this->docFileVersions = new ArrayCollection();
  376.     }
  377.     public function getId(): ?int
  378.     {
  379.         return $this->id;
  380.     }
  381.     public function getFileName(): ?string
  382.     {
  383.         return $this->fileName;
  384.     }
  385.     public function setFileName(?string $fileName): self
  386.     {
  387.         $this->fileName $fileName;
  388.         return $this;
  389.     }
  390.     public function getDocFileType(): ?string
  391.     {
  392.         return $this->docFileType;
  393.     }
  394.     public function setDocFileType(string $docFileType): self
  395.     {
  396.         $this->docFileType $docFileType;
  397.         return $this;
  398.     }
  399.     public function getParent(): ?self
  400.     {
  401.         return $this->parent;
  402.     }
  403.     public function setParent(?self $parent): self
  404.     {
  405.         $this->parent $parent;
  406.         return $this;
  407.     }
  408.     /**
  409.      * @return Collection|self[]
  410.      */
  411.     public function getChildrens(): Collection
  412.     {
  413.         return $this->childrens;
  414.     }
  415.     public function addChildren(self $children): self
  416.     {
  417.         if (!$this->childrens->contains($children)) {
  418.             $this->childrens[] = $children;
  419.             $children->setParent($this);
  420.         }
  421.         return $this;
  422.     }
  423.     public function removeChildren(self $children): self
  424.     {
  425.         if ($this->childrens->removeElement($children)) {
  426.             // set the owning side to null (unless already changed)
  427.             if ($children->getParent() === $this) {
  428.                 $children->setParent(null);
  429.             }
  430.         }
  431.         return $this;
  432.     }
  433.     public function getSize(): ?int
  434.     {
  435.         return $this->size;
  436.     }
  437.     public function setSize(?int $size): self
  438.     {
  439.         $this->size $size;
  440.         return $this;
  441.     }
  442.     public function getContainer(): ?Container
  443.     {
  444.         return $this->container;
  445.     }
  446.     public function setContainer(?Container $container): self
  447.     {
  448.         $this->container $container;
  449.         return $this;
  450.     }
  451.     public function getUser(): ?User
  452.     {
  453.         return $this->user;
  454.     }
  455.     public function setUser(?User $user): self
  456.     {
  457.         $this->user $user;
  458.         return $this;
  459.     }
  460.     /**
  461.      * @return Collection|UserGroup[]
  462.      */
  463.     public function getUserGroups(): Collection
  464.     {
  465.         return $this->userGroups;
  466.     }
  467.     /**
  468.      * @Groups({"DocFile:EL"})
  469.      * @SerializedName("groups")
  470.      */
  471.     public function getUserGroupsArray()
  472.     {
  473.         $groups = [];
  474.         foreach ($this->userGroups as $group) {
  475.             if (!$group->getIsGenerated()) {
  476.                 $groups[] = $group->getId();
  477.             }
  478.         }
  479.         return $groups;
  480.     }
  481.     public function addUserGroup(UserGroup $userGroup): self
  482.     {
  483.         if (!$this->userGroups->contains($userGroup)) {
  484.             $this->userGroups[] = $userGroup;
  485.         }
  486.         return $this;
  487.     }
  488.     public function removeUserGroup(UserGroup $userGroup): self
  489.     {
  490.         $this->userGroups->removeElement($userGroup);
  491.         return $this;
  492.     }
  493.     public function removeAllUserGroups(): self
  494.     {
  495.         foreach ($this->userGroups as $userGroup) {
  496.             $this->removeUserGroup($userGroup);
  497.         }
  498.         return $this;
  499.     }
  500.     /**
  501.      * @return Collection|DocFileTag[]
  502.      */
  503.     public function getDocFileTags(): Collection
  504.     {
  505.         return $this->docFileTags;
  506.     }
  507.     /**
  508.      * @Groups({"DocFile:EL"})
  509.      * @SerializedName("tags")
  510.      */
  511.     public function getTagsArray()
  512.     {
  513.         $tags = [];
  514.         foreach ($this->docFileTags as $tag) {
  515.             $tags[] = $tag->getName();
  516.         }
  517.         return $tags;
  518.     }
  519.     public function addDocFileTag(DocFileTag $docFileTag): self
  520.     {
  521.         if (!$this->docFileTags->contains($docFileTag)) {
  522.             $this->docFileTags[] = $docFileTag;
  523.         }
  524.         return $this;
  525.     }
  526.     public function removeDocFileTag(DocFileTag $docFileTag): self
  527.     {
  528.         $this->docFileTags->removeElement($docFileTag);
  529.         return $this;
  530.     }
  531.     public function reAttachTags(): self
  532.     {
  533.         $tags $this->docFileTags;
  534.         foreach ($tags as $tag) {
  535.             $nt = clone $tag;
  536.             $nt->setContainer($this->getContainer());
  537.             $this->removeDocFileTag($tag);
  538.             $this->addDocFileTag($nt);
  539.         }
  540.         return $this;
  541.     }
  542.     /**
  543.      * Get the value of operation
  544.      *
  545.      * @return  string
  546.      */
  547.     public function getOperation()
  548.     {
  549.         return $this->operation;
  550.     }
  551.     /**
  552.      * Set the value of operation
  553.      *
  554.      * @param  string  $operation
  555.      *
  556.      * @return  self
  557.      */
  558.     public function setOperation(string $operation)
  559.     {
  560.         $this->operation $operation;
  561.         return $this;
  562.     }
  563.     /**
  564.      * Get the value of source
  565.      *
  566.      * @return  int[]
  567.      */
  568.     public function getSource()
  569.     {
  570.         return $this->source;
  571.     }
  572.     /**
  573.      * Set the value of source
  574.      *
  575.      * @param  int[]  $source
  576.      *
  577.      * @return  self
  578.      */
  579.     public function setSource(array $source)
  580.     {
  581.         $this->source $source;
  582.         return $this;
  583.     }
  584.     /**
  585.      * Get the value of target
  586.      *
  587.      * @return  ?int
  588.      */
  589.     public function getTarget()
  590.     {
  591.         return $this->target;
  592.     }
  593.     /**
  594.      * Set the value of target
  595.      *
  596.      * @param  ?int $target
  597.      *
  598.      * @return  self
  599.      */
  600.     public function setTarget(?int $target)
  601.     {
  602.         $this->target $target;
  603.         return $this;
  604.     }
  605.     public function getOrigFileName(): ?string
  606.     {
  607.         return $this->origFileName;
  608.     }
  609.     public function setOrigFileName(string $origFileName): self
  610.     {
  611.         $this->origFileName $origFileName;
  612.         return $this;
  613.     }
  614.     public function getPath(): ?array
  615.     {
  616.         return $this->path;
  617.     }
  618.     public function setPath(?array $path): self
  619.     {
  620.         $this->path $path;
  621.         return $this;
  622.     }
  623.     /**
  624.      * @Groups({"DocFile:AllParents"})
  625.      */
  626.     public function getAllParents(): ?array
  627.     {
  628.         $parents = [];
  629.         $parent $this->getParent();
  630.         if ($parent) {
  631.             do {
  632.                 $parents[] = $parent;
  633.                 $parent $parent->getParent();
  634.             } while ($parent);
  635.         }
  636.         return $parents;
  637.     }
  638.     /**
  639.      * @return Collection|DocFileBlock[]
  640.      */
  641.     public function getDocFileBlocks(): Collection
  642.     {
  643.         return $this->docFileBlocks;
  644.     }
  645.     public function addDocFileBlock(DocFileBlock $docFileBlock): self
  646.     {
  647.         if (!$this->docFileBlocks->contains($docFileBlock)) {
  648.             $this->docFileBlocks[] = $docFileBlock;
  649.             $docFileBlock->setDocFile($this);
  650.         }
  651.         return $this;
  652.     }
  653.     public function removeDocFileBlock(DocFileBlock $docFileBlock): self
  654.     {
  655.         if ($this->docFileBlocks->removeElement($docFileBlock)) {
  656.             // set the owning side to null (unless already changed)
  657.             if ($docFileBlock->getDocFile() === $this) {
  658.                 $docFileBlock->setDocFile(null);
  659.             }
  660.         }
  661.         return $this;
  662.     }
  663.     /**
  664.      * @return Collection|CommonComment[]
  665.      */
  666.     public function getCommonComments(): Collection
  667.     {
  668.         return $this->commonComments;
  669.     }
  670.     public function addCommonComment(CommonComment $commonComment): self
  671.     {
  672.         if (!$this->commonComments->contains($commonComment)) {
  673.             $this->commonComments[] = $commonComment;
  674.             $commonComment->setDocFile($this);
  675.         }
  676.         return $this;
  677.     }
  678.     public function removeCommonComment(CommonComment $commonComment): self
  679.     {
  680.         if ($this->commonComments->removeElement($commonComment)) {
  681.             // set the owning side to null (unless already changed)
  682.             if ($commonComment->getDocFile() === $this) {
  683.                 $commonComment->setDocFile(null);
  684.             }
  685.         }
  686.         return $this;
  687.     }
  688.     public function getIsPostEnable()
  689.     {
  690.         return (count($this->userGroups) < 1);
  691.     }
  692.     public function getPostText()
  693.     {
  694.         return $this->getOrigFileName();
  695.     }
  696.     public function getPostPoster()
  697.     {
  698.         return '';
  699.     }
  700.     public function getPostMetadata()
  701.     {
  702.         $authors = [];
  703.         foreach ($this->getAuthors() as $a) {
  704.             $authors[] = $a->getMetadata();
  705.         }
  706.         return [
  707.             'docFile' => [
  708.                 'id' => $this->getId(),
  709.                 'origFileName' => $this->getOrigFileName(),
  710.                 'fileName' => $this->getFileName(),
  711.                 'docFileType' => $this->getDocFileType(),
  712.                 'size' => $this->getSize(),
  713.                 'path' => $this->getPath(),
  714.                 'imageName' => $this->getImageName(),
  715.                 'isImage' => $this->getIsImage(),
  716.                 'tags' => $this->getTagsArray(),
  717.                 'docFileCategory' => $this->getDocFileCategory() ? $this->getDocFileCategory()->getMeta() : null,
  718.                 'authors' => $authors
  719.             ]
  720.         ];
  721.     }
  722.     public function getPostSource()
  723.     {
  724.         return CommonComment::SOURCE_DOCFILEBLOCK;
  725.     }
  726.     public function getPostSubSource()
  727.     {
  728.         return Newsfeed::POSTSUBTYPE_DOCUMENT;
  729.     }
  730.     public function getPostUserGroups()
  731.     {
  732.         return $this->getUserGroups();
  733.     }
  734.     public function getIsPublic(): ?bool
  735.     {
  736.         return $this->isPublic;
  737.     }
  738.     public function setIsPublic(?bool $isPublic): self
  739.     {
  740.         $this->isPublic $isPublic;
  741.         return $this;
  742.     }
  743.     public function getIsDownload(): ?bool
  744.     {
  745.         return $this->isDownload;
  746.     }
  747.     public function setIsDownload(?bool $isDownload): self
  748.     {
  749.         $this->isDownload $isDownload;
  750.         return $this;
  751.     }
  752.     /**
  753.      * @return Collection<int, User>
  754.      */
  755.     public function getAuthors(): Collection
  756.     {
  757.         return $this->authors;
  758.     }
  759.     public function addAuthor(User $author): self
  760.     {
  761.         if (!$this->authors->contains($author)) {
  762.             $this->authors[] = $author;
  763.         }
  764.         return $this;
  765.     }
  766.     public function removeAuthor(User $author): self
  767.     {
  768.         $this->authors->removeElement($author);
  769.         return $this;
  770.     }
  771.     public function removeAllAuthors(): self
  772.     {
  773.         foreach ($this->authors as $author) {
  774.             $this->removeAuthor($author);
  775.         }
  776.         return $this;
  777.     }
  778.     public function getIsShowDocHub(): ?bool
  779.     {
  780.         return $this->isShowDocHub;
  781.     }
  782.     public function setIsShowDocHub(?bool $isShowDocHub): self
  783.     {
  784.         $this->isShowDocHub $isShowDocHub;
  785.         return $this;
  786.     }
  787.     public function getIsActive(): ?bool
  788.     {
  789.         return $this->isActive;
  790.     }
  791.     public function setIsActive(?bool $isActive): self
  792.     {
  793.         $this->isActive $isActive;
  794.         return $this;
  795.     }
  796.     public function getIsCommentEnable(): ?bool
  797.     {
  798.         return $this->isCommentEnable;
  799.     }
  800.     public function setIsCommentEnable(?bool $isCommentEnable): self
  801.     {
  802.         $this->isCommentEnable $isCommentEnable;
  803.         return $this;
  804.     }
  805.     /**
  806.      * @Groups({"DocFile:EL", "DocFile:Read", "DocFile:Write", "ElTask:Read", "ElExam:Read-Solution"})
  807.      */
  808.     public function getIsImage(): bool
  809.     {
  810.         $ext strtolower(pathinfo($this->getFileName(), PATHINFO_EXTENSION));
  811.         return in_array($extUpload::IMAGE_TYPES);
  812.     }
  813.     public function getImageName(): ?string
  814.     {
  815.         return $this->imageName;
  816.     }
  817.     public function setImageName(?string $imageName): self
  818.     {
  819.         $this->imageName $imageName;
  820.         return $this;
  821.     }
  822.     /**
  823.      * @Groups({"DocFile:EL"})
  824.      */
  825.     public function getCntId()
  826.     {
  827.         return $this->container->getId();
  828.     }
  829.     public function getUrl(): ?string
  830.     {
  831.         return $this->url;
  832.     }
  833.     public function setUrl(?string $url): self
  834.     {
  835.         $this->url $url;
  836.         return $this;
  837.     }
  838.     public function getDicomFileInfo(): ?array
  839.     {
  840.         return $this->dicomFileInfo;
  841.     }
  842.     public function setDicomFileInfo(?array $dicomFileInfo): self
  843.     {
  844.         $this->dicomFileInfo $dicomFileInfo;
  845.         return $this;
  846.     }
  847.     public function getDocFileCategory(): ?CommonCategory
  848.     {
  849.         return $this->docFileCategory;
  850.     }
  851.     public function setDocFileCategory(?CommonCategory $docFileCategory): self
  852.     {
  853.         $this->docFileCategory $docFileCategory;
  854.         return $this;
  855.     }
  856.     public function getReminderDurationType(): ?string
  857.     {
  858.         return $this->reminderDurationType;
  859.     }
  860.     public function setReminderDurationType(?string $reminderDurationType): self
  861.     {
  862.         $this->reminderDurationType $reminderDurationType;
  863.         return $this;
  864.     }
  865.     public function getReminderDuration(): ?int
  866.     {
  867.         return $this->reminderDuration;
  868.     }
  869.     public function setReminderDuration(?int $reminderDuration): self
  870.     {
  871.         $this->reminderDuration $reminderDuration;
  872.         return $this;
  873.     }
  874.     public function getIsReminderRepeat(): ?bool
  875.     {
  876.         return $this->isReminderRepeat;
  877.     }
  878.     public function setIsReminderRepeat(?bool $isReminderRepeat): self
  879.     {
  880.         $this->isReminderRepeat $isReminderRepeat;
  881.         return $this;
  882.     }
  883.     public function getNextReminder(): ?\DateTimeInterface
  884.     {
  885.         return $this->nextReminder;
  886.     }
  887.     public function setNextReminder(?\DateTimeInterface $nextReminder): self
  888.     {
  889.         $this->nextReminder $nextReminder;
  890.         return $this;
  891.     }
  892.     /**
  893.      * @return Collection<int, DocFileVersion>
  894.      */
  895.     public function getDocFileVersions(): Collection
  896.     {
  897.         return $this->docFileVersions;
  898.     }
  899.     public function addDocFileVersion(DocFileVersion $docFileVersion): self
  900.     {
  901.         if (!$this->docFileVersions->contains($docFileVersion)) {
  902.             $this->docFileVersions[] = $docFileVersion;
  903.             $docFileVersion->setDocFile($this);
  904.         }
  905.         return $this;
  906.     }
  907.     public function removeDocFileVersion(DocFileVersion $docFileVersion): self
  908.     {
  909.         if ($this->docFileVersions->removeElement($docFileVersion)) {
  910.             // set the owning side to null (unless already changed)
  911.             if ($docFileVersion->getDocFile() === $this) {
  912.                 $docFileVersion->setDocFile(null);
  913.             }
  914.         }
  915.         return $this;
  916.     }
  917.     public function getDocFileId()
  918.     {
  919.         return $this->docFileId;
  920.     }
  921.     public function setDocFileId(int $docFileId)
  922.     {
  923.         $this->docFileId $docFileId;
  924.         return $this;
  925.     }
  926.     public function getAiAssistantQuestion()
  927.     {
  928.         return $this->aiAssistantQuestion;
  929.     }
  930.     public function setAiAssistantQuestion(string $aiAssistantQuestion)
  931.     {
  932.         $this->aiAssistantQuestion $aiAssistantQuestion;
  933.         return $this;
  934.     }
  935.     public function getAiAssistantFileId()
  936.     {
  937.         return $this->aiAssistantFileId;
  938.     }
  939.     public function setAiAssistantFileId(string $aiAssistantFileId)
  940.     {
  941.         $this->aiAssistantFileId $aiAssistantFileId;
  942.         return $this;
  943.     }
  944.     /**
  945.      * @return Collection<int, DocFileSaved>
  946.      */
  947.     public function getDocFileSaved(): Collection
  948.     {
  949.         return $this->docFileSaved;
  950.     }
  951.     public function addNewsfeedSaved(DocFileSaved $docFileSaved): self
  952.     {
  953.         if (!$this->docFileSaved->contains($docFileSaved)) {
  954.             $this->docFileSaved[] = $docFileSaved;
  955.             $docFileSaved->setDocFile($this);
  956.         }
  957.         return $this;
  958.     }
  959.     public function removeDocFileSaved(DocFileSaved $docFileSaved): self
  960.     {
  961.         if ($this->docFileSaved->removeElement($docFileSaved)) {
  962.             // set the owning side to null (unless already changed)
  963.             if ($docFileSaved->getDocFile() === $this) {
  964.                 $docFileSaved->setDocFile(null);
  965.             }
  966.         }
  967.         return $this;
  968.     }
  969.     public function getAiFileId(): ?string
  970.     {
  971.         return $this->aiFileId;
  972.     }
  973.     public function setAiFileId(?string $aiFileId): self
  974.     {
  975.         $this->aiFileId $aiFileId;
  976.         return $this;
  977.     }
  978. }