<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* DocumentPoste
*
* @ORM\Table(name="rec_document_poste")
* @ORM\Entity(repositoryClass="App\Repository\RecDocumentPosteRepository")
*
*/
class RecDocumentPoste
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @Assert\File( maxSize="10M", mimeTypes={"application/pdf", "image/png"} )
*/
public $file;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="hiddenName", type="string", length=255)
*/
private $hiddenName;
/**
* @ORM\ManyToOne(targetEntity="RecPoste", inversedBy="document")
* @ORM\JoinColumn(name="poste_id", referencedColumnName="id")
*/
protected $poste;
/**
* @ORM\Column(name="validate", type="boolean")
*/
protected $validate;
public function __construct()
{
$this->validate = false;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
* @return RecDocument
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set path
*
* @param string $path
* @return RecDocument
*/
public function setHiddenName($hidden)
{
$this->hiddenName = $hidden;
return $this;
}
/**
* Get path
*
* @return string
*/
public function getHiddenName()
{
return $this->hiddenName;
}
public function getAbsolutePath()
{
return $this->getUploadRootDir();
}
public function getWebPath()
{
return "/".$this->getUploadDir().'/'.$this->hiddenName;
}
protected function getUploadRootDir()
{
return __DIR__.'/../../data/'.$this->getUploadDir();
}
public function getUploadDir()
{
return 'files';
}
public function getThumbnail()
{
return ;
}
public function remove()
{
echo $this->getId();die;
}
public function removeFile()
{
if(file_exists($this->getUploadRootDir().'/'.$this->hiddenName))
unlink($this->getUploadRootDir().'/'.$this->hiddenName);
}
/**
* Set validate
*
* @param boolean $validate
* @return RecDocumentPoste
*/
public function setValidate($validate)
{
$this->validate = $validate;
return $this;
}
/**
* Get validate
*
* @return boolean
*/
public function getValidate()
{
return $this->validate;
}
/**
* Set poste
*
* @param \App\Entity\RecPoste $poste
* @return RecDocumentPoste
*/
public function setPoste(\App\Entity\RecPoste $poste = null)
{
$this->poste = $poste;
return $this;
}
/**
* Get poste
*
* @return \Dosi\RecrutementBundle\Entity\RecPoste
*/
public function getPoste()
{
return $this->poste;
}
public function isValidate(): ?bool
{
return $this->validate;
}
}