src/Entity/Vetoadom/SecteurZone.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Vetoadom;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. /**
  9.  * SecteurZone
  10.  *
  11.  * @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"})})
  12.  * @ORM\Entity(repositoryClass="App\Repository\Vetoadom\SecteurZoneRepository")
  13.  * @ORM\HasLifecycleCallbacks()
  14.  * @UniqueEntity(
  15.  *     groups={"nom"},
  16.  *     fields={"nom"},
  17.  *     errorPath="nom",
  18.  *     message="page_admin_params_secteur_section_zones.secteur_zone_nom_exist"
  19.  *  )
  20.  */
  21. class SecteurZone
  22. {
  23.     /**
  24.      * @var int
  25.      *
  26.      * @ORM\Column(name="id", type="integer", nullable=false)
  27.      * @ORM\Id
  28.      * @ORM\GeneratedValue(strategy="IDENTITY")
  29.      */
  30.     private $id;
  31.     /**
  32.      * @var string
  33.      *
  34.      * @ORM\Column(name="nom", type="string", length=80, nullable=false)
  35.      * @Assert\NotBlank(
  36.      *      groups={"nom"},
  37.      *      message="common.blank"
  38.      *   )
  39.      * @Assert\Length(
  40.      *      groups={"nom"},
  41.      *      max=80,
  42.      *      maxMessage="common.too_long"
  43.      *   )
  44.      */
  45.     private $nom;
  46.     /**
  47.      * @var string
  48.      *
  49.      * @ORM\Column(name="text_prise_appel_langue1", type="text", length=65535, nullable=false)
  50.      * @Assert\NotBlank(
  51.      *       groups={"textPriseAppelLangue1"},
  52.      *       message="common.blank"
  53.      *    )
  54.      */
  55.     private $textPriseAppelLangue1;
  56.     /**
  57.      * @var string|null
  58.      *
  59.      * @ORM\Column(name="text_prise_appel_langue2", type="text", length=65535, nullable=true)
  60.      * @Assert\NotBlank(
  61.      *        groups={"textPriseAppelLangue2"},
  62.      *        message="common.blank"
  63.      *     )
  64.      */
  65.     private $textPriseAppelLangue2;
  66.     /**
  67.      * @var string
  68.      *
  69.      * @ORM\Column(name="site_internet", type="string", length=100, nullable=false)
  70.      * @Assert\NotBlank(
  71.      *          groups={"siteInternet"},
  72.      *          message="common.blank"
  73.      *       )
  74.      * @Assert\Url(
  75.      *        groups={"siteInternet"},
  76.      *        message="common.format_wrong"
  77.      *     )
  78.      * @Assert\Length(
  79.      *       groups={"siteInternet"},
  80.      *       max=100,
  81.      *       maxMessage="common.too_long"
  82.      *    )
  83.      */
  84.     private $siteInternet;
  85.     /**
  86.      * @var string
  87.      *
  88.      * @ORM\Column(name="telephone", type="string", length=30, nullable=false)
  89.      * @Assert\NotBlank(
  90.      *         groups={"telephone"},
  91.      *         message="common.blank"
  92.      *      )
  93.      * @Assert\Regex(
  94.      *        groups={"telephone"},
  95.      *        pattern="/^\d{1,30}$/",
  96.      *        message="common.format_wrong"
  97.      *     )
  98.      */
  99.     private $telephone;
  100.     /**
  101.      * @var string|null
  102.      *
  103.      * @ORM\Column(name="calcul_adresse1", type="string", length=38, nullable=true)
  104.      * @Assert\NotBlank(
  105.      *     groups={"calculAdresse1"},
  106.      *     message="common.blank"
  107.      *  )
  108.      * @Assert\Length(
  109.      *      groups={"calculAdresse1"},
  110.      *      max=38,
  111.      *      maxMessage="common.too_long"
  112.      *   )
  113.      */
  114.     private $calculAdresse1;
  115.     /**
  116.      * @var string|null
  117.      *
  118.      * @ORM\Column(name="calcul_adresse2", type="string", length=38, nullable=true)
  119.      * @Assert\Length(
  120.      *       groups={"calculAdresse2"},
  121.      *       max=38,
  122.      *       maxMessage="common.too_long"
  123.      *    )
  124.      */
  125.     private $calculAdresse2;
  126.     /**
  127.      * @var \Ville
  128.      *
  129.      * @ORM\ManyToOne(targetEntity="Ville")
  130.      * @ORM\JoinColumns({
  131.      *    @ORM\JoinColumn(name="calcul_ville_id", referencedColumnName="id")
  132.      *  })
  133.      * @Assert\NotBlank(
  134.      *      groups={"calculVille"},
  135.      *      message="common.blank"
  136.      *   )
  137.      */
  138.     private $calculVille;
  139.     /**
  140.      * @var string|null
  141.      *
  142.      * @ORM\Column(name="calcul_x", type="string", precision=10, scale=2, nullable=true, options={"unsigned"=true})
  143.      * @Assert\NotBlank(
  144.      *       groups={"calculX"},
  145.      *       message="common.blank"
  146.      *    )
  147.      */
  148.     private $calculX;
  149.     /**
  150.      * @var string|null
  151.      *
  152.      * @ORM\Column(name="calcul_y", type="string", precision=10, scale=2, nullable=true, options={"unsigned"=true})
  153.      * @Assert\NotBlank(
  154.      *      groups={"calculY"},
  155.      *      message="common.blank"
  156.      *   )
  157.      */
  158.     private $calculY;
  159.     /**
  160.      * @var \DateTime
  161.      *
  162.      * @ORM\Column(name="date_creation", type="datetime", nullable=false)
  163.      */
  164.     private $dateCreation;
  165.     /**
  166.      * @var \DateTime
  167.      *
  168.      * @ORM\Column(name="date_modification", type="datetime", nullable=false, options={"default"="CURRENT_TIMESTAMP"})
  169.      */
  170.     private $dateModification;
  171.     /**
  172.      * @var \Secteur
  173.      *
  174.      * @ORM\ManyToOne(targetEntity="Secteur", inversedBy="secteurZone")
  175.      * @ORM\JoinColumns({
  176.      *   @ORM\JoinColumn(name="secteur_id", referencedColumnName="id")
  177.      * })
  178.      */
  179.     private $secteur;
  180.     /**
  181.      * @var \SousSecteur
  182.      *
  183.      * @ORM\ManyToOne(targetEntity="SousSecteur")
  184.      * @ORM\JoinColumns({
  185.      *   @ORM\JoinColumn(name="sous_secteur_id", referencedColumnName="id")
  186.      * })
  187.      * @Assert\NotBlank(
  188.      *         groups={"sousSecteur"},
  189.      *         message="common.blank"
  190.      *      )
  191.      */
  192.     private $sousSecteur;
  193.     /**
  194.      * @var \Pays
  195.      *
  196.      * @ORM\ManyToOne(targetEntity="Pays")
  197.      * @ORM\JoinColumns({
  198.      *   @ORM\JoinColumn(name="pays_id", referencedColumnName="id")
  199.      * })
  200.      * @Assert\NotBlank(
  201.      *          groups={"pays"},
  202.      *          message="common.blank"
  203.      *       )
  204.      */
  205.     private $pays;
  206.     /**
  207.      * @var \ZoneType
  208.      *
  209.      * @ORM\ManyToOne(targetEntity="ZoneType")
  210.      * @ORM\JoinColumns({
  211.      *   @ORM\JoinColumn(name="zone_type_id", referencedColumnName="id")
  212.      * })
  213.      * @Assert\NotBlank(
  214.      *           groups={"zoneType"},
  215.      *           message="common.blank"
  216.      *        )
  217.      */
  218.     private $zoneType;
  219.     /**
  220.      * One SecteurZone has many Document. This is the inverse side.
  221.      * @ORM\OneToMany(targetEntity="Document", mappedBy="secteurZone")
  222.      */
  223.     private $documents;
  224.     /**
  225.      * One SecteurZone has many SecteurZoneVille. This is the inverse side.
  226.      * @ORM\OneToMany(targetEntity="SecteurZoneVille", mappedBy="secteurZone")
  227.      */
  228.     private $secteurZoneVille;
  229.     public function __construct()
  230.     {
  231.         $this->documents = new ArrayCollection();
  232.         $this->secteurZoneVille = new ArrayCollection();
  233.     }
  234.     public function getId(): ?int
  235.     {
  236.         return $this->id;
  237.     }
  238.     public function getNom(): ?string
  239.     {
  240.         return $this->nom;
  241.     }
  242.     public function setNom(string $nom): self
  243.     {
  244.         #if ($nom === '') $nom = null;
  245.         $this->nom $nom;
  246.         return $this;
  247.     }
  248.     public function getTextPriseAppelLangue1(): ?string
  249.     {
  250.         return $this->textPriseAppelLangue1;
  251.     }
  252.     public function setTextPriseAppelLangue1(string $textPriseAppelLangue1): self
  253.     {
  254.         $this->textPriseAppelLangue1 $textPriseAppelLangue1;
  255.         return $this;
  256.     }
  257.     public function getTextPriseAppelLangue2(): ?string
  258.     {
  259.         return $this->textPriseAppelLangue2;
  260.     }
  261.     public function setTextPriseAppelLangue2(?string $textPriseAppelLangue2): self
  262.     {
  263.         $this->textPriseAppelLangue2 $textPriseAppelLangue2;
  264.         return $this;
  265.     }
  266.     public function getSiteInternet(): ?string
  267.     {
  268.         return $this->siteInternet;
  269.     }
  270.     public function setSiteInternet(string $siteInternet): self
  271.     {
  272.         $this->siteInternet $siteInternet;
  273.         return $this;
  274.     }
  275.     public function getTelephone(): ?string
  276.     {
  277.         return $this->telephone;
  278.     }
  279.     public function setTelephone(string $telephone): self
  280.     {
  281.         $this->telephone $telephone;
  282.         return $this;
  283.     }
  284.     public function getDateCreation(): ?\DateTimeInterface
  285.     {
  286.         return $this->dateCreation;
  287.     }
  288.     public function setDateCreation(\DateTimeInterface $dateCreation): self
  289.     {
  290.         $this->dateCreation $dateCreation;
  291.         return $this;
  292.     }
  293.     public function getDateModification(): ?\DateTimeInterface
  294.     {
  295.         return $this->dateModification;
  296.     }
  297.     public function setDateModification(\DateTimeInterface $dateModification): self
  298.     {
  299.         $this->dateModification $dateModification;
  300.         return $this;
  301.     }
  302.     public function getSecteur(): ?Secteur
  303.     {
  304.         return $this->secteur;
  305.     }
  306.     public function setSecteur(?Secteur $secteur): self
  307.     {
  308.         $this->secteur $secteur;
  309.         return $this;
  310.     }
  311.     public function getSousSecteur(): ?SousSecteur
  312.     {
  313.         return $this->sousSecteur;
  314.     }
  315.     public function setSousSecteur(?SousSecteur $sousSecteur): self
  316.     {
  317.         $this->sousSecteur $sousSecteur;
  318.         return $this;
  319.     }
  320.     public function getPays(): ?Pays
  321.     {
  322.         return $this->pays;
  323.     }
  324.     public function setPays(?Pays $pays): self
  325.     {
  326.         $this->pays $pays;
  327.         return $this;
  328.     }
  329.     public function getZoneType(): ?ZoneType
  330.     {
  331.         return $this->zoneType;
  332.     }
  333.     public function setZoneType(?ZoneType $zoneType): self
  334.     {
  335.         $this->zoneType $zoneType;
  336.         return $this;
  337.     }
  338.     public function getCalculAdresse1(): ?string
  339.     {
  340.         return $this->calculAdresse1;
  341.     }
  342.     public function setCalculAdresse1(?string $calculAdresse1): self
  343.     {
  344.         $this->calculAdresse1 $calculAdresse1;
  345.         return $this;
  346.     }
  347.     public function getCalculAdresse2(): ?string
  348.     {
  349.         return $this->calculAdresse2;
  350.     }
  351.     public function setCalculAdresse2(?string $calculAdresse2): self
  352.     {
  353.         if ($calculAdresse2 === ''$calculAdresse2 null;
  354.         $this->calculAdresse2 $calculAdresse2;
  355.         return $this;
  356.     }
  357.     public function getCalculX(): ?string
  358.     {
  359.         return $this->calculX;
  360.     }
  361.     public function setCalculX(?string $calculX): self
  362.     {
  363.         if ($calculX === ''$calculX null;
  364.         $this->calculX $calculX;
  365.         return $this;
  366.     }
  367.     public function getCalculY(): ?string
  368.     {
  369.         return $this->calculY;
  370.     }
  371.     public function setCalculY(?string $calculY): self
  372.     {
  373.         if ($calculY === ''$calculY null;
  374.         $this->calculY $calculY;
  375.         return $this;
  376.     }
  377.     public function getCalculVille(): ?Ville
  378.     {
  379.         return $this->calculVille;
  380.     }
  381.     public function setCalculVille(?Ville $calculVille): self
  382.     {
  383.         $this->calculVille $calculVille;
  384.         return $this;
  385.     }
  386.     /**
  387.      * Helpers
  388.      */
  389.     /**
  390.      * @return Collection|Document[]
  391.      */
  392.     public function getDocumentsCollection(): Collection
  393.     {
  394.         return $this->documents;
  395.     }
  396.     /**
  397.      * @param string $type
  398.      * @return Collection|Document[]
  399.      */
  400.     public function getDocumentsActiveByType(string $type): Collection
  401.     {
  402.         return $this->getDocumentsCollection()->filter(function (Document $document) use ($type){
  403.             return $document->getActive() && $document->getDocumentType()->getType() == $type;
  404.         });
  405.     }
  406.     /**
  407.      * @return Collection|SecteurZoneVille[]
  408.      */
  409.     public function getSecteurZoneVilleCollection(): Collection
  410.     {
  411.         return $this->secteurZoneVille;
  412.     }
  413.     public function getSiteProtocol(): string
  414.     {
  415.         return $this->getSiteInternet() == null 'https' parse_url($this->getSiteInternet(),PHP_URL_SCHEME);
  416.     }
  417.     public function getSiteHost(): ?string
  418.     {
  419.         return $this->getSiteInternet() == null null str_replace($this->getSiteProtocol().'://','',$this->getSiteInternet());
  420.     }
  421.     /**
  422.      * @ORM\PrePersist
  423.      */
  424.     public function setCreatedAtValue()
  425.     {
  426.         $this->dateCreation = new \DateTimeImmutable();
  427.     }
  428. }