<?php
namespace App\Entity;
use App\Entity\Wiki;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity()
*
* @ORM\Table(name="wiki_image")
*
* @ORM\HasLifecycleCallbacks
*/
class WikiImage
{
/**
* @ORM\Id
*
* @ORM\Column(type="bigint")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Wiki", inversedBy="images")
*
* @ORM\JoinColumn(name="wiki_id", referencedColumnName="id")
*/
protected $wiki;
/**
* @ORM\Column(type="boolean")
*/
protected $main;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $alt;
public function __construct(/**
* @ORM\Column(type="string")
*
* @Assert\File()
*/
protected $file)
{
$this->main = false;
}
public function getId()
{
return $this->id;
}
public function getFile()
{
return $this->file;
}
public function setFile($file): void
{
$this->file = $file;
}
public function getWiki()
{
return $this->wiki;
}
public function setWiki(Wiki $wiki): void
{
$this->wiki = $wiki;
}
public function isMain()
{
return $this->main;
}
public function setMain($main): void
{
$this->main = $main;
}
public function getWebPath()
{
return substr(strstr((string) $this->file, '/public/'), 7);
}
public function getAlt()
{
return $this->alt;
}
public function setAlt($alt): void
{
$this->alt = $alt;
}
/**
* @ORM\PreRemove
*/
public function unlinkFile()
{
return unlink($this->file);
}
}