<?php
namespace App\Entity;
use App\Repository\PieceJointeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=PieceJointeRepository::class)
*/
class PieceJointe
{
const SAVE_PATH = 'uploads/pieces_jointes/';
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $filename;
/**
* @ORM\Column(type="string", length=128, nullable=true)
*/
private $descriptionCourte;
/**
* @ORM\ManyToOne(targetEntity=Lot::class, inversedBy="pjs")
*/
private $lot;
/**
* @ORM\ManyToOne(targetEntity=Programme::class, inversedBy="pjs")
*/
private $programme;
/**
* @ORM\Column(type="integer")
*/
private $ordre = 0;
/**
* @ORM\Column(type="boolean")
*/
private $showPublic = false;
/**
* @ORM\Column(type="boolean")
*/
private $estUnPlan = false;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $estImageAdmin = false;
/**
* @ORM\ManyToOne(targetEntity=PieceJointe::class, inversedBy="pieceJointeFille")
*/
private $pieceJointeMere;
/**
* @ORM\OneToMany(targetEntity=PieceJointe::class, mappedBy="pieceJointeMere")
*/
private $pieceJointeFille;
public function __construct()
{
$this->pieceJointeFille = new ArrayCollection();
$this->showPublic = true;
}
public function __clone()
{
if ($this->id) {
$this->id = null;
}
}
public function getId(): ?int
{
return $this->id;
}
public function getFilename(): ?string
{
return $this->filename;
}
public function getUnserializedFilename(): ?string
{
if (is_string($this->filename)) {
$unserialized = @unserialize($this->filename);
if ($unserialized !== false || $this->filename === 'b:0;') {
$fullPath = is_array($unserialized) && isset($unserialized[0]) ? $unserialized[0] : null;
if ($fullPath) {
return basename($fullPath);
}
}
}
return $this->filename ? basename($this->filename) : null;
}
public function setFilename(?string $filename): self
{
$this->filename = $filename;
return $this;
}
public function getFilenamePdf()
{
$data = json_decode($this->getFilename(), true);
return $data;
}
public function getDescriptionCourte(): ?string
{
return $this->descriptionCourte;
}
public function setDescriptionCourte(?string $descriptionCourte): self
{
$this->descriptionCourte = $descriptionCourte;
return $this;
}
public function getLot(): ?Lot
{
return $this->lot;
}
public function setLot(?Lot $lot): self
{
$this->lot = $lot;
return $this;
}
public function getProgramme(): ?Programme
{
return $this->programme;
}
public function setProgramme(?Programme $programme): self
{
$this->programme = $programme;
return $this;
}
public function getOrdre(): ?int
{
return $this->ordre;
}
public function setOrdre(int $ordre): self
{
$this->ordre = $ordre;
return $this;
}
public function getEstUnPlan(): ?bool
{
return $this->estUnPlan;
}
public function setEstUnPlan(bool $estUnPlan): self
{
$this->estUnPlan = $estUnPlan;
return $this;
}
public function getShowPublic(): ?bool
{
return $this->showPublic;
}
public function setShowPublic(bool $showPublic): self
{
$this->showPublic = $showPublic;
return $this;
}
public function getEstImageAdmin(): ?bool
{
return $this->estImageAdmin;
}
public function setEstImageAdmin(?bool $estImageAdmin): self
{
$this->estImageAdmin = $estImageAdmin;
return $this;
}
public function getPieceJointeMere(): ?self
{
return $this->pieceJointeMere;
}
public function setPieceJointeMere(?self $pieceJointeMere): self
{
$this->pieceJointeMere = $pieceJointeMere;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getPieceJointeFille(): Collection
{
return $this->pieceJointeFille;
}
public function addPieceJointeFille(self $pieceJointeFille): self
{
if (!$this->pieceJointeFille->contains($pieceJointeFille)) {
$this->pieceJointeFille[] = $pieceJointeFille;
$pieceJointeFille->setPieceJointeMere($this);
}
return $this;
}
public function removePieceJointeFille(self $pieceJointeFille): self
{
if ($this->pieceJointeFille->removeElement($pieceJointeFille)) {
// set the owning side to null (unless already changed)
if ($pieceJointeFille->getPieceJointeMere() === $this) {
$pieceJointeFille->setPieceJointeMere(null);
}
}
return $this;
}
}