<?php
namespace App\Entity\Vetoadom;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* SecteurZone
*
* @ORM\Table(name="secteur_zone", uniqueConstraints={@ORM\UniqueConstraint(name="nom", columns={"nom"})}, indexes={@ORM\Index(name="FK_secteur_zone_sous_secteur", columns={"sous_secteur_id"}), @ORM\Index(name="FK_secteur_zone_secteur", columns={"secteur_id"}), @ORM\Index(name="FK_secteur_zone_pays", columns={"pays_id"}), @ORM\Index(name="FK_secteur_zone_zone_type", columns={"zone_type_id"}), @ORM\Index(name="FK_secteur_zone_calcul_ville", columns={"calcul_ville_id"})})
* @ORM\Entity(repositoryClass="App\Repository\Vetoadom\SecteurZoneRepository")
* @ORM\HasLifecycleCallbacks()
* @UniqueEntity(
* groups={"nom"},
* fields={"nom"},
* errorPath="nom",
* message="page_admin_params_secteur_section_zones.secteur_zone_nom_exist"
* )
*/
class SecteurZone
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="nom", type="string", length=80, nullable=false)
* @Assert\NotBlank(
* groups={"nom"},
* message="common.blank"
* )
* @Assert\Length(
* groups={"nom"},
* max=80,
* maxMessage="common.too_long"
* )
*/
private $nom;
/**
* @var string
*
* @ORM\Column(name="text_prise_appel_langue1", type="text", length=65535, nullable=false)
* @Assert\NotBlank(
* groups={"textPriseAppelLangue1"},
* message="common.blank"
* )
*/
private $textPriseAppelLangue1;
/**
* @var string|null
*
* @ORM\Column(name="text_prise_appel_langue2", type="text", length=65535, nullable=true)
* @Assert\NotBlank(
* groups={"textPriseAppelLangue2"},
* message="common.blank"
* )
*/
private $textPriseAppelLangue2;
/**
* @var string
*
* @ORM\Column(name="site_internet", type="string", length=100, nullable=false)
* @Assert\NotBlank(
* groups={"siteInternet"},
* message="common.blank"
* )
* @Assert\Url(
* groups={"siteInternet"},
* message="common.format_wrong"
* )
* @Assert\Length(
* groups={"siteInternet"},
* max=100,
* maxMessage="common.too_long"
* )
*/
private $siteInternet;
/**
* @var string
*
* @ORM\Column(name="telephone", type="string", length=30, nullable=false)
* @Assert\NotBlank(
* groups={"telephone"},
* message="common.blank"
* )
* @Assert\Regex(
* groups={"telephone"},
* pattern="/^\d{1,30}$/",
* message="common.format_wrong"
* )
*/
private $telephone;
/**
* @var string|null
*
* @ORM\Column(name="calcul_adresse1", type="string", length=38, nullable=true)
* @Assert\NotBlank(
* groups={"calculAdresse1"},
* message="common.blank"
* )
* @Assert\Length(
* groups={"calculAdresse1"},
* max=38,
* maxMessage="common.too_long"
* )
*/
private $calculAdresse1;
/**
* @var string|null
*
* @ORM\Column(name="calcul_adresse2", type="string", length=38, nullable=true)
* @Assert\Length(
* groups={"calculAdresse2"},
* max=38,
* maxMessage="common.too_long"
* )
*/
private $calculAdresse2;
/**
* @var \Ville
*
* @ORM\ManyToOne(targetEntity="Ville")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="calcul_ville_id", referencedColumnName="id")
* })
* @Assert\NotBlank(
* groups={"calculVille"},
* message="common.blank"
* )
*/
private $calculVille;
/**
* @var string|null
*
* @ORM\Column(name="calcul_x", type="string", precision=10, scale=2, nullable=true, options={"unsigned"=true})
* @Assert\NotBlank(
* groups={"calculX"},
* message="common.blank"
* )
*/
private $calculX;
/**
* @var string|null
*
* @ORM\Column(name="calcul_y", type="string", precision=10, scale=2, nullable=true, options={"unsigned"=true})
* @Assert\NotBlank(
* groups={"calculY"},
* message="common.blank"
* )
*/
private $calculY;
/**
* @var \DateTime
*
* @ORM\Column(name="date_creation", type="datetime", nullable=false)
*/
private $dateCreation;
/**
* @var \DateTime
*
* @ORM\Column(name="date_modification", type="datetime", nullable=false, options={"default"="CURRENT_TIMESTAMP"})
*/
private $dateModification;
/**
* @var \Secteur
*
* @ORM\ManyToOne(targetEntity="Secteur", inversedBy="secteurZone")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="secteur_id", referencedColumnName="id")
* })
*/
private $secteur;
/**
* @var \SousSecteur
*
* @ORM\ManyToOne(targetEntity="SousSecteur")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="sous_secteur_id", referencedColumnName="id")
* })
* @Assert\NotBlank(
* groups={"sousSecteur"},
* message="common.blank"
* )
*/
private $sousSecteur;
/**
* @var \Pays
*
* @ORM\ManyToOne(targetEntity="Pays")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="pays_id", referencedColumnName="id")
* })
* @Assert\NotBlank(
* groups={"pays"},
* message="common.blank"
* )
*/
private $pays;
/**
* @var \ZoneType
*
* @ORM\ManyToOne(targetEntity="ZoneType")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="zone_type_id", referencedColumnName="id")
* })
* @Assert\NotBlank(
* groups={"zoneType"},
* message="common.blank"
* )
*/
private $zoneType;
/**
* One SecteurZone has many Document. This is the inverse side.
* @ORM\OneToMany(targetEntity="Document", mappedBy="secteurZone")
*/
private $documents;
/**
* One SecteurZone has many SecteurZoneVille. This is the inverse side.
* @ORM\OneToMany(targetEntity="SecteurZoneVille", mappedBy="secteurZone")
*/
private $secteurZoneVille;
public function __construct()
{
$this->documents = new ArrayCollection();
$this->secteurZoneVille = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(string $nom): self
{
#if ($nom === '') $nom = null;
$this->nom = $nom;
return $this;
}
public function getTextPriseAppelLangue1(): ?string
{
return $this->textPriseAppelLangue1;
}
public function setTextPriseAppelLangue1(string $textPriseAppelLangue1): self
{
$this->textPriseAppelLangue1 = $textPriseAppelLangue1;
return $this;
}
public function getTextPriseAppelLangue2(): ?string
{
return $this->textPriseAppelLangue2;
}
public function setTextPriseAppelLangue2(?string $textPriseAppelLangue2): self
{
$this->textPriseAppelLangue2 = $textPriseAppelLangue2;
return $this;
}
public function getSiteInternet(): ?string
{
return $this->siteInternet;
}
public function setSiteInternet(string $siteInternet): self
{
$this->siteInternet = $siteInternet;
return $this;
}
public function getTelephone(): ?string
{
return $this->telephone;
}
public function setTelephone(string $telephone): self
{
$this->telephone = $telephone;
return $this;
}
public function getDateCreation(): ?\DateTimeInterface
{
return $this->dateCreation;
}
public function setDateCreation(\DateTimeInterface $dateCreation): self
{
$this->dateCreation = $dateCreation;
return $this;
}
public function getDateModification(): ?\DateTimeInterface
{
return $this->dateModification;
}
public function setDateModification(\DateTimeInterface $dateModification): self
{
$this->dateModification = $dateModification;
return $this;
}
public function getSecteur(): ?Secteur
{
return $this->secteur;
}
public function setSecteur(?Secteur $secteur): self
{
$this->secteur = $secteur;
return $this;
}
public function getSousSecteur(): ?SousSecteur
{
return $this->sousSecteur;
}
public function setSousSecteur(?SousSecteur $sousSecteur): self
{
$this->sousSecteur = $sousSecteur;
return $this;
}
public function getPays(): ?Pays
{
return $this->pays;
}
public function setPays(?Pays $pays): self
{
$this->pays = $pays;
return $this;
}
public function getZoneType(): ?ZoneType
{
return $this->zoneType;
}
public function setZoneType(?ZoneType $zoneType): self
{
$this->zoneType = $zoneType;
return $this;
}
public function getCalculAdresse1(): ?string
{
return $this->calculAdresse1;
}
public function setCalculAdresse1(?string $calculAdresse1): self
{
$this->calculAdresse1 = $calculAdresse1;
return $this;
}
public function getCalculAdresse2(): ?string
{
return $this->calculAdresse2;
}
public function setCalculAdresse2(?string $calculAdresse2): self
{
if ($calculAdresse2 === '') $calculAdresse2 = null;
$this->calculAdresse2 = $calculAdresse2;
return $this;
}
public function getCalculX(): ?string
{
return $this->calculX;
}
public function setCalculX(?string $calculX): self
{
if ($calculX === '') $calculX = null;
$this->calculX = $calculX;
return $this;
}
public function getCalculY(): ?string
{
return $this->calculY;
}
public function setCalculY(?string $calculY): self
{
if ($calculY === '') $calculY = null;
$this->calculY = $calculY;
return $this;
}
public function getCalculVille(): ?Ville
{
return $this->calculVille;
}
public function setCalculVille(?Ville $calculVille): self
{
$this->calculVille = $calculVille;
return $this;
}
/**
* Helpers
*/
/**
* @return Collection|Document[]
*/
public function getDocumentsCollection(): Collection
{
return $this->documents;
}
/**
* @param string $type
* @return Collection|Document[]
*/
public function getDocumentsActiveByType(string $type): Collection
{
return $this->getDocumentsCollection()->filter(function (Document $document) use ($type){
return $document->getActive() && $document->getDocumentType()->getType() == $type;
});
}
/**
* @return Collection|SecteurZoneVille[]
*/
public function getSecteurZoneVilleCollection(): Collection
{
return $this->secteurZoneVille;
}
public function getSiteProtocol(): string
{
return $this->getSiteInternet() == null ? 'https' : parse_url($this->getSiteInternet(),PHP_URL_SCHEME);
}
public function getSiteHost(): ?string
{
return $this->getSiteInternet() == null ? null : str_replace($this->getSiteProtocol().'://','',$this->getSiteInternet());
}
/**
* @ORM\PrePersist
*/
public function setCreatedAtValue()
{
$this->dateCreation = new \DateTimeImmutable();
}
}