src/Entity/Media/Document.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Media;
  3. use App\Entity\Federation\Boat;
  4. use App\Entity\Federation\Skipper;
  5. use App\Entity\User\Alert;
  6. use App\Entity\User\User;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use App\Entity\Federation\Team;
  13. use App\Entity\Federation\Classe;
  14. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  15. use App\Entity\Federation\Race;
  16. use App\Entity\Media\Import;
  17. use App\Entity\Site\AccessSite;
  18. /**
  19.  * @ORM\Entity(repositoryClass="App\Repository\Media\DocumentRepository")
  20.  * @ORM\Table(name="documents")
  21.  * @ORM\HasLifecycleCallbacks
  22.  */
  23. class Document
  24. {
  25.     const THUMBNAIL_NAME 'thumb.0000000.jpg';
  26.     /**
  27.      * @ORM\Id
  28.      * @ORM\Column(type="integer", name="id")
  29.      * @ORM\GeneratedValue(strategy="AUTO")
  30.      */
  31.     private $id;
  32.     /**
  33.      * @ORM\Column(type="string", length=255, nullable=true, name="title")
  34.      * @Assert\NotBlank(groups={"DocumentTypeSingle"})
  35.      */
  36.     private $title;
  37.     /**
  38.      * @ORM\Column(type="text", nullable=true, name="description")
  39.      */
  40.     private $description;
  41.     
  42.     /**
  43.      * @ORM\Column(type="datetime", nullable=true, name="publicationDate")
  44.      */
  45.     private $publicationDate;
  46.     
  47.     /**
  48.      * @ORM\Column(type="string", length=255, nullable=true, name="copyright")
  49.      */
  50.     private $copyright;
  51.     
  52.     /**
  53.      * @ORM\Column(type="string", length=500, nullable=true, name="legend")
  54.      */
  55.     private $legend;
  56.     
  57.     /**
  58.      * @ORM\Column(type="string", length=255, nullable=true, name="author")
  59.      */
  60.     private $author;
  61.     
  62.     /**
  63.      * @ORM\Column(type="string", length=255, nullable=true, name="localization")
  64.      */
  65.     private $localization;
  66.     
  67.     /**
  68.      * @ORM\Column(type="string", length=255, nullable=true)
  69.      */
  70.     private $originalName;
  71.         
  72.     /**
  73.      * @ORM\Column(type="string", length=255, nullable=true, unique=true)
  74.      */
  75.     private $directoryName;
  76.     
  77.     /**
  78.      * @ORM\Column(type="array", nullable=true)
  79.      */
  80.     private $file;
  81.     
  82.     /**
  83.      * @ORM\Column(type="array", nullable=true)
  84.      */
  85.     private $attachment;
  86.     
  87.     /**
  88.      * @ORM\ManyToOne(targetEntity="App\Entity\Media\Document", inversedBy="documentsChild", cascade={"persist"})
  89.      */
  90.     private $parentDocument;
  91.     
  92.     /**
  93.      * @ORM\Column(type="datetime", nullable=true, name="date") 
  94.      */
  95.     private $date;
  96.     
  97.     /**
  98.      * @ORM\Column(type="boolean", nullable=true, name="notify")
  99.      */
  100.     private $notify 0;
  101.     
  102.     /**
  103.      * @ORM\OneToMany(targetEntity="App\Entity\Media\Share", mappedBy="document", cascade={"remove"})
  104.      */
  105.     private $shares;
  106.      /**
  107.      * @ORM\Column(type="datetime", nullable=false, name="created_date")
  108.      * @Gedmo\Timestampable(on="create")
  109.      */
  110.     private $createdDate;
  111.     /**
  112.      * @ORM\Column(type="datetime", nullable=true, name="updated_date")
  113.      * @Gedmo\Timestampable(on="update")
  114.      */
  115.     private $updatedDate;
  116.     /**
  117.      * @ORM\Column(type="integer", nullable=false, name="status")
  118.      */
  119.     private $status 0;
  120.     /**
  121.      * @ORM\OneToMany(targetEntity="App\Entity\Media\Conversion", mappedBy="document", cascade={"persist", "remove"})
  122.      */
  123.     private $conversions;
  124.     
  125.     /**
  126.      * @ORM\OneToMany(targetEntity="App\Entity\Media\Document", mappedBy="parentDocument", cascade={"persist", "remove"})
  127.      */
  128.     private $documentsChild;
  129.     
  130.     /**
  131.      * @ORM\ManyToOne(targetEntity="App\Entity\Federation\Race", inversedBy="documents")
  132.      * @ORM\JoinColumn(name="race_id", referencedColumnName="id")
  133.      */
  134.     private $race;
  135.     /**
  136.      * @ORM\ManyToOne(targetEntity="App\Entity\Media\DocumentType", inversedBy="documents")
  137.      * @ORM\JoinColumn(name="document_type_id", referencedColumnName="id")
  138.      */
  139.     private $documentType;
  140.     /**
  141.      * @ORM\ManyToMany(targetEntity="App\Entity\Federation\Skipper", inversedBy="documents")
  142.      * @ORM\JoinTable(
  143.      *     name="documents_skippers",
  144.      *     joinColumns={@ORM\JoinColumn(name="document_id", referencedColumnName="id", nullable=false)},
  145.      *     inverseJoinColumns={@ORM\JoinColumn(name="skipper_id", referencedColumnName="id", nullable=false)}
  146.      * )
  147.      */
  148.     private $skippers;
  149.     /**
  150.      * @ORM\ManyToMany(targetEntity="App\Entity\Federation\Boat", inversedBy="documents")
  151.      * @ORM\JoinTable(
  152.      *     name="documents_boats",
  153.      *     joinColumns={@ORM\JoinColumn(name="document_id", referencedColumnName="id", nullable=false)},
  154.      *     inverseJoinColumns={@ORM\JoinColumn(name="boat_id", referencedColumnName="id", nullable=false)}
  155.      * )
  156.      */
  157.     private $boats;
  158.     /**
  159.      * @ORM\ManyToMany(targetEntity="App\Entity\Federation\Team", inversedBy="documents")
  160.      * @ORM\JoinTable(
  161.      *     name="documents_teams",
  162.      *     joinColumns={@ORM\JoinColumn(name="document_id", referencedColumnName="id", nullable=false)},
  163.      *     inverseJoinColumns={@ORM\JoinColumn(name="team_id", referencedColumnName="id", nullable=false)}
  164.      * )
  165.      */
  166.     private $teams;
  167.     
  168.     /**
  169.      * @ORM\ManyToMany(targetEntity="App\Entity\Federation\Classe", inversedBy="documents")
  170.      * @ORM\JoinTable(
  171.      *     name="documents_classes",
  172.      *     joinColumns={@ORM\JoinColumn(name="document_id", referencedColumnName="id", nullable=false)},
  173.      *     inverseJoinColumns={@ORM\JoinColumn(name="classe_id", referencedColumnName="id", nullable=false)}
  174.      * )
  175.      */
  176.     private $classes;
  177.     
  178.     /**
  179.      * @ORM\ManyToMany(targetEntity="App\Entity\Media\Category", inversedBy="documents")
  180.      * @ORM\JoinTable(
  181.      *     name="documents_categories",
  182.      *     joinColumns={@ORM\JoinColumn(name="document_id", referencedColumnName="id", nullable=false)},
  183.      *     inverseJoinColumns={@ORM\JoinColumn(name="category_id", referencedColumnName="id", nullable=false)}
  184.      * )
  185.      * @Assert\Count(min = 1, groups={"DocumentTypeSingle"})
  186.      */
  187.     private $categories;
  188.     
  189.     /**
  190.      * @ORM\ManyToMany(targetEntity="App\Entity\Media\Tag", inversedBy="documents")
  191.      * @ORM\JoinTable(
  192.      *     name="documents_tags",
  193.      *     joinColumns={@ORM\JoinColumn(name="document_id", referencedColumnName="id", nullable=false)},
  194.      *     inverseJoinColumns={@ORM\JoinColumn(name="tag_id", referencedColumnName="id", nullable=false)}
  195.      * )
  196.      */
  197.     private $tags;
  198.     
  199.     /**
  200.      * @ORM\Column(type="datetime", nullable=true)
  201.      */
  202.     private $proofSendDate;
  203.     
  204.     /**
  205.      * @ORM\ManyToOne(targetEntity="App\Entity\User\User", inversedBy="proofValidations")
  206.      */
  207.     private $proofValidationUser;
  208.     
  209.     /**
  210.      * @ORM\Column(type="datetime", nullable=true)
  211.      */
  212.     private $proofValidationDate;
  213.     
  214.     /**
  215.      * @ORM\ManyToOne(targetEntity="App\Entity\Media\Import", inversedBy="documents")
  216.      * @ORM\JoinColumn(name="import_id", referencedColumnName="id")
  217.      */
  218.     private $import;
  219.     
  220.     /**
  221.      * @ORM\ManyToOne(targetEntity="App\Entity\Media\Quality", inversedBy="documents")
  222.      * @ORM\JoinColumn(name="quality_id", referencedColumnName="id")
  223.      */
  224.     private $quality;
  225.     /**
  226.      * @ORM\OneToMany(targetEntity="App\Entity\User\Alert", mappedBy="document", cascade={"persist", "remove"})
  227.      */
  228.     private $alerts;
  229.     public function __construct()
  230.     {
  231.         $this->conversions = new ArrayCollection();
  232.         $this->skippers = new ArrayCollection();
  233.         $this->boats = new ArrayCollection();
  234.         $this->teams = new ArrayCollection();
  235.         $this->classes = new ArrayCollection();
  236.         $this->categories = new ArrayCollection();
  237.         $this->tags = new ArrayCollection();
  238.         $this->documentsChild = new ArrayCollection();
  239.         $this->shares = new ArrayCollection();
  240.         $this->alerts = new ArrayCollection();
  241.     }
  242.     public function getId(): ?int
  243.     {
  244.         return $this->id;
  245.     }
  246.     public function getTitle(): ?string
  247.     {
  248.         return $this->title;
  249.     }
  250.     public function setTitle(?string $title): self
  251.     {
  252.         $this->title $title;
  253.         return $this;
  254.     }
  255.     public function getDescription(): ?string
  256.     {
  257.         return $this->description;
  258.     }
  259.     public function setDescription(?string $description): self
  260.     {
  261.         $this->description $description;
  262.         return $this;
  263.     }
  264.     public function getCopyright(): ?string
  265.     {
  266.         return $this->copyright;
  267.     }
  268.     public function setCopyright(?string $copyright): self
  269.     {
  270.         $this->copyright $copyright;
  271.         return $this;
  272.     }
  273.     public function getDirectoryName(): ?string
  274.     {
  275.         return $this->directoryName;
  276.     }
  277.     public function setDirectoryName(?string $directoryName): self
  278.     {
  279.         $this->directoryName $directoryName;
  280.         return $this;
  281.     }
  282.     
  283.     public function getOriginalName(): ?string
  284.     {
  285.         return $this->originalName;
  286.     }
  287.     
  288.     public function setOriginalName(?string $originalName): self
  289.     {
  290.         $this->originalName $originalName;
  291.         
  292.         return $this;
  293.     }
  294.     public function getCreatedDate(): ?\DateTimeInterface
  295.     {
  296.         return $this->createdDate;
  297.     }
  298.     
  299.     public function getUpdatedDate(): ?\DateTimeInterface
  300.     {
  301.         return $this->updatedDate;
  302.     }
  303.     
  304.     public function getStatus(): ?int
  305.     {
  306.         return $this->status;
  307.     }
  308.     public function setStatus(int $status): self
  309.     {
  310.         $this->status $status;
  311.         return $this;
  312.     }
  313.     
  314.     public function isNotify(): ?bool
  315.     {
  316.         return $this->notify;
  317.     }
  318.     
  319.     public function setNotify(bool $notify): self
  320.     {
  321.         $this->notify $notify;
  322.         
  323.         return $this;
  324.     }
  325.     /**
  326.      * @return Collection|Conversion[]
  327.      */
  328.     public function getConversions(): Collection
  329.     {
  330.         return $this->conversions;
  331.     }
  332.     public function addConversion(Conversion $conversion): self
  333.     {
  334.         if (!$this->conversions->contains($conversion)) {
  335.             $this->conversions[] = $conversion;
  336.             $conversion->setDocument($this);
  337.         }
  338.         return $this;
  339.     }
  340.     public function removeConversion(Conversion $conversion): self
  341.     {
  342.         if ($this->conversions->contains($conversion)) {
  343.             $this->conversions->removeElement($conversion);
  344.             // set the owning side to null (unless already changed)
  345.             if ($conversion->getDocument() === $this) {
  346.                 $conversion->setDocument(null);
  347.             }
  348.         }
  349.         return $this;
  350.     }
  351.     
  352.     public function getInProgressConversions()
  353.     {
  354.         $result 0;
  355.         
  356.         if(!empty($this->getConversions()))
  357.         {
  358.             foreach($this->getConversions() as $conversion)
  359.             {
  360.                 if($conversion->getStatus() == && empty($conversion->getFile()) && !empty($conversion->getJob()))
  361.                     $result ++;
  362.             }
  363.         }
  364.         
  365.         return $result;
  366.     }
  367.     
  368.     public function getFinishedConversions()
  369.     {
  370.         $result 0;
  371.         
  372.         if(!empty($this->getConversions()))
  373.         {
  374.             foreach($this->getConversions() as $conversion)
  375.             {
  376.                 if($conversion->getStatus() == && !empty($conversion->getFile() && !empty($conversion->getJob())))
  377.                     $result ++;
  378.                 if($conversion->isInitialFormat())
  379.                     $result ++;
  380.             }
  381.         }
  382.         
  383.         return $result;
  384.     }
  385.     public function getRace(): ?Race
  386.     {
  387.         return $this->race;
  388.     }
  389.     public function setRace(?Race $race): self
  390.     {
  391.         $this->race $race;
  392.         return $this;
  393.     }
  394.     public function getDocumentType(): ?DocumentType
  395.     {
  396.         return $this->documentType;
  397.     }
  398.     public function setDocumentType(?DocumentType $documentType): self
  399.     {
  400.         $this->documentType $documentType;
  401.         return $this;
  402.     }
  403.     /**
  404.      * @return Collection|Skipper[]
  405.      */
  406.     public function getSkippers(): Collection
  407.     {
  408.         return $this->skippers;
  409.     }
  410.     public function addSkipper(Skipper $skipper): self
  411.     {
  412.         if (!$this->skippers->contains($skipper)) {
  413.             $this->skippers[] = $skipper;
  414.         }
  415.         return $this;
  416.     }
  417.     public function removeSkipper(Skipper $skipper): self
  418.     {
  419.         if ($this->skippers->contains($skipper)) {
  420.             $this->skippers->removeElement($skipper);
  421.         }
  422.         return $this;
  423.     }
  424.     /**
  425.      * @return Collection|Boat[]
  426.      */
  427.     public function getBoats(): Collection
  428.     {
  429.         return $this->boats;
  430.     }
  431.     public function addBoat(Boat $boat): self
  432.     {
  433.         if (!$this->boats->contains($boat)) {
  434.             $this->boats[] = $boat;
  435.         }
  436.         return $this;
  437.     }
  438.     public function removeBoat(Boat $boat): self
  439.     {
  440.         if ($this->boats->contains($boat)) {
  441.             $this->boats->removeElement($boat);
  442.         }
  443.         return $this;
  444.     }
  445.     /**
  446.      * @return Collection|Team[]
  447.      */
  448.     public function getTeams(): Collection
  449.     {
  450.         return $this->teams;
  451.     }
  452.     public function addTeam(Team $team): self
  453.     {
  454.         if (!$this->teams->contains($team)) {
  455.             $this->teams[] = $team;
  456.         }
  457.         return $this;
  458.     }
  459.     public function removeTeam(Team $team): self
  460.     {
  461.         if ($this->teams->contains($team)) {
  462.             $this->teams->removeElement($team);
  463.         }
  464.         return $this;
  465.     }
  466.     /**
  467.      * @return Collection|Classe[]
  468.      */
  469.     public function getClasses(): Collection
  470.     {
  471.         return $this->classes;
  472.     }
  473.     public function addClass(Classe $class): self
  474.     {
  475.         if (!$this->classes->contains($class)) {
  476.             $this->classes[] = $class;
  477.         }
  478.         return $this;
  479.     }
  480.     public function removeClass(Classe $class): self
  481.     {
  482.         if ($this->classes->contains($class)) {
  483.             $this->classes->removeElement($class);
  484.         }
  485.         return $this;
  486.     }
  487.     /**
  488.      * @return Collection|Category[]
  489.      */
  490.     public function getCategories(): Collection
  491.     {
  492.         return $this->categories;
  493.     }
  494.     public function addCategory(Category $category): self
  495.     {
  496.         if (!$this->categories->contains($category)) {
  497.             $this->categories[] = $category;
  498.             $category->addDocument($this);
  499.         }
  500.         return $this;
  501.     }
  502.     public function removeCategory(Category $category): self
  503.     {
  504.         if ($this->categories->contains($category)) {
  505.             $this->categories->removeElement($category);
  506.             $category->removeDocument($this);
  507.         }
  508.         return $this;
  509.     }
  510.     
  511.     /**
  512.      * @return Collection|Tag[]
  513.      */
  514.     public function getTags(): Collection
  515.     {
  516.         return $this->tags;
  517.     }
  518.     
  519.     public function addTag(Tag $tag): self
  520.     {
  521.         if (!$this->tags->contains($tag)) {
  522.             $this->tags[] = $tag;
  523.             $tag->addDocument($this);
  524.         }
  525.         
  526.         return $this;
  527.     }
  528.     
  529.     public function removeTag(Tag $tag): self
  530.     {
  531.         if ($this->tags->contains($tag)) {
  532.             $this->tags->removeElement($tag);
  533.             $tag->removeDocument($this);
  534.         }
  535.         
  536.         return $this;
  537.     }
  538.     
  539.     public function getProofValidationDate(): ?\DateTimeInterface
  540.     {
  541.         return $this->proofValidationDate;
  542.     }
  543.     public function setProofValidationDate(?\DateTimeInterface $proofValidationDate): self
  544.     {
  545.         $this->proofValidationDate $proofValidationDate;
  546.         return $this;
  547.     }
  548.     public function getProofValidationUser(): ?User
  549.     {
  550.         return $this->proofValidationUser;
  551.     }
  552.     public function setProofValidationUser(?User $proofValidationUser): self
  553.     {
  554.         $this->proofValidationUser $proofValidationUser;
  555.         return $this;
  556.     }
  557.     public function getLegend(): ?string
  558.     {
  559.         return $this->legend;
  560.     }
  561.     public function setLegend(?string $legend): self
  562.     {
  563.         $this->legend $legend;
  564.         return $this;
  565.     }
  566.     
  567.     public function getAuthor(): ?string
  568.     {
  569.         return $this->author;
  570.     }
  571.     
  572.     public function setAuthor(?string $author): self
  573.     {
  574.         $this->author $author;
  575.         
  576.         return $this;
  577.     }
  578.     
  579.     public function getLocalization(): ?string
  580.     {
  581.         return $this->localization;
  582.     }
  583.     
  584.     public function setLocalization(?string $localization): self
  585.     {
  586.         $this->localization $localization;
  587.         
  588.         return $this;
  589.     }
  590.       
  591.     public function getDate(): ?\DateTimeInterface
  592.     {
  593.         return $this->date;
  594.     }
  595.     
  596.     public function setDate(\DateTimeInterface $date null): self
  597.     {
  598.         $this->date $date;
  599.         
  600.         return $this;
  601.     }
  602.     
  603.     public function getPublicationDate(): ?\DateTimeInterface
  604.     {
  605.         return $this->publicationDate;
  606.     }
  607.     
  608.     public function setPublicationDate(\DateTimeInterface $publicationDate null): self
  609.     {
  610.         $this->publicationDate $publicationDate;
  611.         
  612.         return $this;
  613.     }
  614.     
  615.     public function getProofSendDate(): ?\DateTimeInterface
  616.     {
  617.         return $this->proofSendDate;
  618.     }
  619.     
  620.     public function setProofSendDate(\DateTimeInterface $proofSendDate null): self
  621.     {
  622.         $this->proofSendDate $proofSendDate;
  623.         
  624.         return $this;
  625.     }
  626.     public function getFile(): ?array
  627.     {
  628.         return $this->file;
  629.     }
  630.     public function setFile(?array $file): self
  631.     {
  632.         $this->file $file;
  633.         return $this;
  634.     }
  635.     
  636.     public function getAttachment(): ?array
  637.     {
  638.         return $this->attachment;
  639.     }
  640.     public function setAttachment(?array $attachment): self
  641.     {
  642.         $this->attachment $attachment;
  643.         return $this;
  644.     }
  645.      public function getParentDocument(): ?self
  646.     {
  647.         return $this->parentDocument;
  648.     }
  649.     public function setParentDocument(?self $parentDocument): self
  650.     {
  651.         $this->parentDocument $parentDocument;
  652.         return $this;
  653.     } 
  654.     /**
  655.      * @return Collection|Document[]
  656.      */
  657.     public function getDocumentsChild(): Collection
  658.     {
  659.         return $this->documentsChild;
  660.     }
  661.     public function addDocumentsChild(Document $documentsChild): self
  662.     {
  663.         if (!$this->documentsChild->contains($documentsChild)) {
  664.             $this->documentsChild[] = $documentsChild;
  665.             $documentsChild->setParentDocument($this);
  666.         }
  667.         return $this;
  668.     }
  669.     public function removeDocumentsChild(Document $documentsChild): self
  670.     {
  671.         if ($this->documentsChild->contains($documentsChild)) {
  672.             $this->documentsChild->removeElement($documentsChild);
  673.             // set the owning side to null (unless already changed)
  674.             if ($documentsChild->getParentDocument() === $this) {
  675.                 $documentsChild->setParentDocument(null);
  676.             }
  677.         }
  678.         return $this;
  679.     }
  680.     
  681.     /**
  682.      * @return Collection|Share[]
  683.      */
  684.     public function getShares(): Collection
  685.     {
  686.         return $this->shares;
  687.     }
  688.     
  689.     public function addShare(Share $share): self
  690.     {
  691.         if (!$this->shares->contains($share)) {
  692.             $this->shares[] = $share;
  693.         }
  694.         
  695.         return $this;
  696.     }
  697.     
  698.     public function removeShare(Share $share): self
  699.     {
  700.         if ($this->shares->contains($share)) {
  701.             $this->shares->removeElement($share);
  702.         }
  703.         
  704.         return $this;
  705.     }
  706.     /**
  707.      * @return Collection|Alert[]
  708.      */
  709.     public function getAlerts(): Collection
  710.     {
  711.         return $this->alerts;
  712.     }
  713.     public function addAlert(Alert $alert): self
  714.     {
  715.         if (!$this->alerts->contains($alert)) {
  716.             $this->alerts[] = $alert;
  717.         }
  718.         return $this;
  719.     }
  720.     public function removeAlert(Alert $alert): self
  721.     {
  722.         if ($this->alerts->contains($alert)) {
  723.             $this->alerts->removeElement($alert);
  724.         }
  725.         return $this;
  726.     }
  727.     
  728.     public function getImport(): ?Import
  729.     {
  730.         return $this->import;
  731.     }
  732.     
  733.     public function setImport(?Import $import): self
  734.     {
  735.         $this->import $import;
  736.         
  737.         return $this;
  738.     }
  739.     
  740.     public function getQuality(): ?Quality
  741.     {
  742.         return $this->quality;
  743.     }
  744.     
  745.     public function setQuality(?Quality $quality): self
  746.     {
  747.         $this->quality $quality;
  748.         
  749.         return $this;
  750.     }
  751.     
  752.     public function getRootUri()
  753.     {
  754.         return 'https://'.$this->getRace()->getDirectoryName().'.s3.amazonaws.com';
  755.     }
  756.     
  757.     public function getSecondThumb()
  758.     {
  759.         return $this->getRootUri().'/'.$this->getDirectoryName().'/'.self::THUMBNAIL_NAME;
  760.     }
  761.     
  762.     public function getUri()
  763.     {
  764.         return $this->getRootUri().'/'.$this->getFile()['Key'];
  765.     }
  766.     
  767.     public function getCopyrightLabel()
  768.     {
  769.         return '© '.$this->getCopyright();
  770.     }
  771.     
  772.     public function getThumbnail($relative false)
  773.     {
  774.         $thumbnail false;
  775.         
  776.         if($this->getDocumentType()->getDirectoryName() == 'pictures')
  777.         {
  778.             if(!empty($this->getDocumentsChild()))
  779.             {
  780.                 //Search Thumbnail
  781.                 foreach($this->getDocumentsChild() as $child)
  782.                 {
  783.                     if($child->getQuality()->getCode() == 'BD')
  784.                         $thumbnail .= $child->getFile()['Key'];
  785.                 }
  786.                 
  787.                 if(!$thumbnail)
  788.                 {
  789.                     foreach($this->getDocumentsChild() as $child)
  790.                         $thumbnail .= $child->getFile()['Key'];
  791.                 }
  792.             }
  793.         }
  794.         
  795.         if(!empty($thumbnail) && $relative == false)
  796.             $thumbnail $this->getRootUri().'/'.$thumbnail;
  797.             
  798.         
  799.         return $thumbnail;
  800.     }
  801.     
  802.     public function __clone()
  803.     {
  804.         $this->id null;
  805.     }
  806.     public function checkAccessByAccessSite(AccessSite $accessSite)
  807.     {
  808.         $access false;
  809.         $restrictiveCategory false;
  810.         foreach($this->getCategories() as $category)
  811.             if($category->isRestrictiveCategory())
  812.                 $restrictiveCategory true;
  813.         if($restrictiveCategory)
  814.         {
  815.             $boatsCompare true;
  816.             if(sizeof($accessSite->getBoats()) > 0)
  817.                 foreach($this->getBoats() as $boat)
  818.                     if(!$accessSite->getBoats()->contains($boat))
  819.                         $boatsCompare false;
  820.             $skippersCompare true;
  821.             if(sizeof($accessSite->getSkippers()) > 0)
  822.                 foreach($this->getSkippers() as $boat)
  823.                     if(!$accessSite->getSkippers()->contains($boat))
  824.                         $skippersCompare false;
  825.             $classesCompare true;
  826.             if(sizeof($accessSite->getClasses()) > 0)
  827.                 foreach($this->getClasses() as $boat)
  828.                     if(!$accessSite->getClasses()->contains($boat))
  829.                         $classesCompare false;
  830.             if($boatsCompare && $skippersCompare && $classesCompare)
  831.                 $access true;
  832.         } else {
  833.             $access true;
  834.         }
  835.         return $access;
  836.     }
  837.     public function getReferents(): array
  838.     {
  839.         $referents = [];
  840.         if(!empty($this->getBoats()))
  841.         {
  842.             foreach($this->getBoats() as $boat)
  843.                 foreach($boat->getParticipations() as $participation)
  844.                     if($participation->getRace() == $this->getRace())
  845.                         foreach($participation->getReferents() as $referent)
  846.                             $referents[] = $referent;
  847.         }
  848.         return $referents;
  849.     }
  850. }