<?phpnamespace App\Entity;use App\Repository\ImageRepository;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=ImageRepository::class) */class Image{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="text") */ private $path; /** * @ORM\Column(type="text", nullable=true) */ private $storageKey; /** * @ORM\Column(type="datetime") */ private $createdAt; /** * @ORM\ManyToOne(targetEntity=Recommendation::class, inversedBy="images") */ private $recommendation; public function __construct() { if(is_null($this->id)){ $this->createdAt = new \DateTime(); } } public function getId(): ?int { return $this->id; } public function getPath(): ?string { return $this->path; } public function setPath(string $path): self { $this->path = $path; return $this; } public function getStorageKey(): ?string { return $this->storageKey; } public function setStorageKey(?string $storageKey): self { $this->storageKey = $storageKey; return $this; } public function getCreatedAt(): ?\DateTimeInterface { return $this->createdAt; } public function setCreatedAt(\DateTimeInterface $createdAt): self { $this->createdAt = $createdAt; return $this; } public function getRecommendation(): ?Recommendation { return $this->recommendation; } public function setRecommendation(?Recommendation $recommendation): self { $this->recommendation = $recommendation; return $this; } public function getImage(): ?string { if(!empty($this->getStorageKey()) && strpos($this->getStorageKey(),'http') === false){ return $_ENV['SELECTEL_STORAGE_PUBLIC_DOMAIN']."/".$this->getStorageKey(); } else { return "https://".$_SERVER['SERVER_NAME']."/".$this->getPath(); } }}