<?php
declare(strict_types=1);
/*
* Copyright (C) Office National de Publication et de Communication - All Rights Reserved
*
* Unauthorized copying of this file, via any medium is strictly prohibited by law
* This file is proprietary and confidential
*/
namespace App\Entity;
use App\Entity\Common\AdresseTrait;
use App\Entity\Common\IdTrait;
use App\Validator\Constraints as AppAssert;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\FicheProspectRepository")
*/
class FicheProspect
{
use AdresseTrait;
use IdTrait;
/** @ORM\Column(type="datetime", nullable=false) */
private $date;
/** @ORM\Column(type="string", nullable=false)
* @Assert\Length(max=30)
*/
private $nom;
/** @ORM\Column(type="string", nullable=false)
* @Assert\Length(max=50)
*/
private $adresse;
/**
* @ORM\Column(type="string", nullable=false)
* @Assert\Length(max=6)
*/
private $codePostal;
/** @ORM\Column(type="string", nullable=false)
* @Assert\Length(max=30)
*/
private $ville;
/** @ORM\Column(type="string", nullable=false)
* @Assert\Length(max=10)
*/
private $telephone;
/**
* @ORM\Column(type="string", length=150, nullable=false)
* @Assert\Email
*/
private $email;
/**
* @ORM\Column(type="string", nullable=true)
* @Assert\Length(max=100)
* @Assert\Url
*/
private $siteWeb;
/** @ORM\Column(type="string", nullable=true)
* @Assert\Length(max=30)
*/
private $responsable;
/**
* @ORM\Column(type="string", nullable=false)
* @Assert\Length(max=50)
* @Assert\NotBlank
*/
private $categorie;
/**
* @ORM\Column(type="text", nullable=true)
* @Assert\Length(max=300)
* @AppAssert\DoesNotContainsLink
*/
private $description;
/** @ORM\Column(type="boolean", nullable=false) */
private $autoriseContact;
/**
* @ORM\ManyToOne(targetEntity="Etablissement")
* @ORM\JoinColumn(name="etablissement_id", referencedColumnName="id", nullable=false)
*/
private $etablissement;
public function __construct()
{
$this->date = new DateTime();
}
public function setNom(string $nom): void
{
$this->nom = $nom;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setTelephone(string $telephone): void
{
$this->telephone = $telephone;
}
public function getTelephone(): ?string
{
return $this->telephone;
}
public function setEmail(string $email): void
{
$this->email = $email;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setSiteWeb(string $siteWeb): void
{
$this->siteWeb = $siteWeb;
}
public function getSiteWeb(): ?string
{
return $this->siteWeb;
}
public function setResponsable(string $responsable): void
{
$this->responsable = $responsable;
}
public function getResponsable(): ?string
{
return $this->responsable;
}
public function setCategorie(string $categorie): void
{
$this->categorie = $categorie;
}
public function getCategorie(): ?string
{
return $this->categorie;
}
public function setDescription(string $description): void
{
$this->description = $description;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setAutoriseContact(bool $autoriseContact): void
{
$this->autoriseContact = $autoriseContact;
}
public function getAutoriseContact(): ?bool
{
return $this->autoriseContact;
}
public function setEtablissement(Etablissement $etablissement): void
{
$this->etablissement = $etablissement;
$this->nom = $this->nom ?: $etablissement->getDenomination();
$this->adresse = $this->adresse ?: trim(implode(' ', [
$etablissement->getAdresse1(),
$etablissement->getAdresse2(),
$etablissement->getAdresse3(),
]));
$this->codePostal = $this->codePostal ?: $etablissement->getCodePostal();
$this->ville = $this->ville ?: $etablissement->getVille()->getLibelle();
}
public function getEtablissement(): ?Etablissement
{
return $this->etablissement;
}
}