src/Entity/WorkroomResource.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Common\LibraryVoterInterface;
  4. use App\Entity\Common\ResourceFileInterface;
  5. use App\Entity\Traits\BaseDateAtTrait;
  6. use App\Entity\Traits\ResourceActionsTrait;
  7. use App\Entity\Traits\ResourceFileTrait;
  8. use App\Repository\WorkroomResourceRepository;
  9. use App\Security\Voter\Library\WorkroomLibraryVoter;
  10. use Doctrine\ORM\Mapping as ORM;
  11. #[ORM\Entity(repositoryClassWorkroomResourceRepository::class)]
  12. #[ORM\HasLifecycleCallbacks]
  13. class WorkroomResource implements LibraryVoterInterfaceResourceFileInterface
  14. {
  15.     use ResourceFileTrait;
  16.     use ResourceActionsTrait;
  17.     use BaseDateAtTrait;
  18.     public const PRIVATE_FOLDER_NAME 'workroom';
  19.     #[ORM\Id]
  20.     #[ORM\GeneratedValue]
  21.     #[ORM\Column(type'integer')]
  22.     private $id;
  23.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'personalResources')]
  24.     private $user;
  25.     #[ORM\ManyToOne(targetEntityWorkroom::class, inversedBy'workroomResources')]
  26.     private $workroom;
  27.     #[ORM\ManyToOne(targetEntityWorkroomFolder::class, inversedBy'workroomResources')]
  28.     private $workroomFolder;
  29.     #[ORM\OneToOne(targetEntityReadingCard::class, inversedBy'workroomResource'cascade: ['remove'])]
  30.     #[ORM\JoinColumn(name'reading_card_id'referencedColumnName'id'nullabletrueonDelete'CASCADE')]
  31.     private $readingCard;
  32.     public function getId(): ?int
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getUser(): ?User
  37.     {
  38.         return $this->user;
  39.     }
  40.     public function setUser(?User $user): self
  41.     {
  42.         $this->user $user;
  43.         return $this;
  44.     }
  45.     public function getWorkroom(): ?Workroom
  46.     {
  47.         return $this->workroom;
  48.     }
  49.     /**
  50.      * @return $this
  51.      */
  52.     public function setWorkroom(?Workroom $workroom): self
  53.     {
  54.         $this->workroom $workroom;
  55.         return $this;
  56.     }
  57.     public function getWorkroomFolder(): ?WorkroomFolder
  58.     {
  59.         return $this->workroomFolder;
  60.     }
  61.     public function setWorkroomFolder(?WorkroomFolder $workroomFolder): self
  62.     {
  63.         $this->workroomFolder $workroomFolder;
  64.         return $this;
  65.     }
  66.     public function getParent(): ?WorkroomFolder
  67.     {
  68.         return $this->getWorkroomFolder();
  69.     }
  70.     public function setParent(?WorkroomFolder $personalFolder): self
  71.     {
  72.         return $this->setWorkroomFolder($personalFolder);
  73.     }
  74.     public function getReadingCard(): ?ReadingCard
  75.     {
  76.         return $this->readingCard;
  77.     }
  78.     public function setReadingCard(?ReadingCard $readingCard): self
  79.     {
  80.         // unset the owning side of the relation if necessary
  81.         if ($readingCard === null && $this->readingCard !== null) {
  82.             $this->readingCard->setWorkroomResource(null);
  83.         }
  84.         // set the owning side of the relation if necessary
  85.         if ($readingCard !== null && $readingCard->getWorkroomResource() !== $this) {
  86.             $readingCard->setWorkroomResource($this);
  87.         }
  88.         $this->readingCard $readingCard;
  89.         return $this;
  90.     }
  91.     public function getLibraryVoter(): string
  92.     {
  93.         return WorkroomLibraryVoter::class;
  94.     }
  95.     public function getPrivateFileIdentificator(): ?int
  96.     {
  97.         return $this->getWorkroom() ? $this->getWorkroom()->getId() : null;
  98.     }
  99. }