src/Entity/MediaObject.php line 53
<?phpnamespace App\Entity;use ApiPlatform\Metadata\ApiProperty;use ApiPlatform\Metadata\ApiResource;use ApiPlatform\Metadata\Get;use ApiPlatform\Metadata\GetCollection;use ApiPlatform\Metadata\Post;use App\Controller\CreateMediaObjectAction;use App\Repository\MediaObjectRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;use Vich\UploaderBundle\Mapping\Annotation as Vich;use Symfony\Component\Validator\Constraints as Assert;use ApiPlatform\OpenApi\Model;use Symfony\Component\HttpFoundation\File\File;#[ORM\Entity(repositoryClass: MediaObjectRepository::class)]#[ApiResource(types: ['https://schema.org/MediaObject'],operations: [new Get(),new GetCollection(),new Post(controller: CreateMediaObjectAction::class,openapi: new Model\Operation(requestBody: new Model\RequestBody(content: new \ArrayObject(['multipart/form-data' => ['schema' => ['type' => 'object','properties' => ['file' => ['type' => 'string','format' => 'binary']]]]]))),validationContext: ['groups' => ['Default', 'media_object_create']],deserialize: false)],normalizationContext: ['groups' => ['media_object:read']])]class MediaObject{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ApiProperty(types: ['https://schema.org/contentUrl'])]#[Groups(['media_object:read'])]public ?string $contentUrl = null;#[Vich\UploadableField(mapping: "media_object", fileNameProperty: "filePath")]#[Assert\NotNull(groups: ['media_object_create'])]public ?File $file = null;#[ORM\Column(length: 255)]#[Groups(['media_object:read', 'media_object_create'])]private ?string $name = '';#[ORM\Column(type: Types::TEXT)]private ?string $filePath = '';#[ORM\OneToMany(mappedBy: 'mainImage', targetEntity: Course::class)]private Collection $courses;#[ORM\ManyToMany(targetEntity: Lesson::class, mappedBy: 'assets')]private Collection $lessons;#[ORM\OneToMany(mappedBy: 'video', targetEntity: HealthInfoVideo::class)]private Collection $healthInfoVideos;#[ORM\OneToMany(mappedBy: 'video', targetEntity: BreakRoomVideo::class)]private Collection $breakRoomVideos;#[ORM\OneToMany(mappedBy: 'icon', targetEntity: Badge::class)]private Collection $badges;#[ORM\OneToMany(mappedBy: 'articulate', targetEntity: Lesson::class)]private Collection $articulateLesson;#[ORM\OneToMany(mappedBy: 'image', targetEntity: LandingpageElement::class)]private Collection $landingpageElements;public function __construct(){$this->courses = new ArrayCollection();$this->lessons = new ArrayCollection();$this->healthInfoVideos = new ArrayCollection();$this->breakRoomVideos = new ArrayCollection();$this->badges = new ArrayCollection();$this->filePath = '';$this->articulateLesson = new ArrayCollection();$this->landingpageElements = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function __toString(): string{return $this->name;}public function getName(): ?string{return $this->name;}public function setName(string $name): self{$this->name = $name;return $this;}public function getFilePath(): ?string{return $this->filePath;}public function setFilePath(?string $filePath): self{if (!is_null($filePath)) {$this->filePath = $filePath;}return $this;}/*** @return Collection<int, Course>*/public function getCourses(): Collection{return $this->courses;}public function addCourse(Course $course): self{if (!$this->courses->contains($course)) {$this->courses->add($course);$course->setMainImage($this);}return $this;}public function removeCourse(Course $course): self{if ($this->courses->removeElement($course)) {// set the owning side to null (unless already changed)if ($course->getMainImage() === $this) {$course->setMainImage(null);}}return $this;}/*** @return Collection<int, Lesson>*/public function getLessons(): Collection{return $this->lessons;}public function addLesson(Lesson $lesson): self{if (!$this->lessons->contains($lesson)) {$this->lessons->add($lesson);$lesson->addAsset($this);}return $this;}public function removeLesson(Lesson $lesson): self{if ($this->lessons->removeElement($lesson)) {$lesson->removeAsset($this);}return $this;}/*** @return Collection<int, HealthInfoVideo>*/public function getHealthInfoVideos(): Collection{return $this->healthInfoVideos;}public function addHealthInfoVideo(HealthInfoVideo $healthInfoVideo): self{if (!$this->healthInfoVideos->contains($healthInfoVideo)) {$this->healthInfoVideos->add($healthInfoVideo);$healthInfoVideo->setVideo($this);}return $this;}public function removeHealthInfoVideo(HealthInfoVideo $healthInfoVideo): self{if ($this->healthInfoVideos->removeElement($healthInfoVideo)) {// set the owning side to null (unless already changed)if ($healthInfoVideo->getVideo() === $this) {$healthInfoVideo->setVideo(null);}}return $this;}/*** @return Collection<int, BreakRoomVideo>*/public function getBreakRoomVideos(): Collection{return $this->breakRoomVideos;}public function addBreakRoomVideo(BreakRoomVideo $breakRoomVideo): self{if (!$this->breakRoomVideos->contains($breakRoomVideo)) {$this->breakRoomVideos->add($breakRoomVideo);$breakRoomVideo->setVideo($this);}return $this;}public function removeBreakRoomVideo(BreakRoomVideo $breakRoomVideo): self{if ($this->breakRoomVideos->removeElement($breakRoomVideo)) {// set the owning side to null (unless already changed)if ($breakRoomVideo->getVideo() === $this) {$breakRoomVideo->setVideo(null);}}return $this;}/*** @return Collection<int, Badge>*/public function getBadges(): Collection{return $this->badges;}public function addBadge(Badge $badge): self{if (!$this->badges->contains($badge)) {$this->badges->add($badge);$badge->setIcon($this);}return $this;}public function removeBadge(Badge $badge): self{if ($this->badges->removeElement($badge)) {// set the owning side to null (unless already changed)if ($badge->getIcon() === $this) {$badge->setIcon(null);}}return $this;}/*** @return Collection<int, Lesson>*/public function getArticulateLesson(): Collection{return $this->articulateLesson;}public function addArticulateLesson(Lesson $articulateLesson): self{if (!$this->articulateLesson->contains($articulateLesson)) {$this->articulateLesson->add($articulateLesson);$articulateLesson->setArticulate($this);}return $this;}public function removeArticulateLesson(Lesson $articulateLesson): self{if ($this->articulateLesson->removeElement($articulateLesson)) {// set the owning side to null (unless already changed)if ($articulateLesson->getArticulate() === $this) {$articulateLesson->setArticulate(null);}}return $this;}/*** @return Collection<int, LandingpageElement>*/public function getLandingpageElements(): Collection{return $this->landingpageElements;}public function addLandingpageElement(LandingpageElement $landingpageElement): self{if (!$this->landingpageElements->contains($landingpageElement)) {$this->landingpageElements->add($landingpageElement);$landingpageElement->setImage($this);}return $this;}public function removeLandingpageElement(LandingpageElement $landingpageElement): self{if ($this->landingpageElements->removeElement($landingpageElement)) {// set the owning side to null (unless already changed)if ($landingpageElement->getImage() === $this) {$landingpageElement->setImage(null);}}return $this;}}