src/JuridicusBundle/Entity/ProtokollGesetz.php line 16

Open in your IDE?
  1. <?php
  2. namespace JF\JuridicusBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  6. /**
  7.  * ProtokollGesetz
  8.  *
  9.  * @ORM\Entity
  10.  * @UniqueEntity(fields={"sortierung","protokoll_infothek_pruefer"}, message="Dieser Eintrag existiert bereits.")
  11.  */
  12. class ProtokollGesetz extends ProtokollGesetzBase
  13. {
  14.     const CLASSNAME __CLASS__;
  15.     
  16.     /**
  17.      * @var Gesetz
  18.      */
  19.     private $gesetz;
  20.     /**
  21.      * @Assert\IsFalse(
  22.      *      groups = {"admin"},
  23.      *      message = "Die Kombination aus Paragraph und Gesetz darf nicht leer sein."
  24.      * )
  25.      * changedFrom Assert\False
  26.      */
  27.     public function isEmpty()
  28.     {
  29.         return empty($this->paragraph) && empty($this->gesetz);
  30.     }
  31.     /**
  32.      * @Assert\IsFalse(
  33.      *      groups = {"finish"},
  34.      *      message = "Paragraph und Gesetz müssen ausgewählt werden."
  35.      * )
  36.      * changedFrom Assert\False
  37.      */
  38.     public function isIncomplete()
  39.     {
  40.         return empty($this->paragraph) ^ empty($this->gesetz);
  41.     }
  42.     /**
  43.      * @var \JF\JuridicusBundle\Entity\ProtokollInfothekPruefer
  44.      * @Assert\NotNull(message = "Der Prüfer darf nicht leer sein.")
  45.      */
  46.     protected $protokoll_infothek_pruefer;
  47.     /**
  48.      * Set protokoll_infothek_pruefer
  49.      *
  50.      * @param \JF\JuridicusBundle\Entity\ProtokollInfothekPruefer $protokollInfothekPruefer
  51.      * @return ProtokollGesetz
  52.      */
  53.     public function setProtokollInfothekPruefer(ProtokollInfothekPruefer $protokollInfothekPruefer null)
  54.     {
  55.         $this->protokoll_infothek_pruefer $protokollInfothekPruefer;
  56.         return $this;
  57.     }
  58.     /**
  59.      * Get protokoll_infothek_pruefer
  60.      *
  61.      * @return \JF\JuridicusBundle\Entity\ProtokollInfothekPruefer
  62.      */
  63.     public function getProtokollInfothekPruefer()
  64.     {
  65.         return $this->protokoll_infothek_pruefer;
  66.     }
  67.     /**
  68.      * Set gesetz
  69.      *
  70.      * @param \JF\JuridicusBundle\Entity\Gesetz $gesetz
  71.      * @return ProtokollGesetzBase
  72.      */
  73.     public function setGesetz(Gesetz $gesetz null)
  74.     {
  75.         $this->gesetz $gesetz;
  76.         return $this;
  77.     }
  78.     /**
  79.      * Get gesetz
  80.      *
  81.      * @return \JF\JuridicusBundle\Entity\Gesetz
  82.      */
  83.     public function getGesetz()
  84.     {
  85.         return $this->gesetz;
  86.     }
  87.     /**
  88.      * @return string
  89.      */
  90.     public function getAbsoluteLink()
  91.     {
  92.         if ($this->gesetz && $this->paragraph) {
  93.             return sprintf('https://dejure.org/%s/%s.html'$this->getGesetz()->getLink(), $this->paragraph);
  94.         } else {
  95.             return '#';
  96.         }
  97.     }
  98.     /**
  99.      *
  100.      * @return string
  101.      */
  102.     public function getKurzbezeichnung()
  103.     {
  104.         if ($this->gesetz && $this->paragraph) {
  105.             return sprintf('§%s %s'$this->getParagraph(), $this->getGesetz()->getExtendedKuerzel());
  106.         } else {
  107.             return 'unvollständig';
  108.         }
  109.     }
  110.     /**
  111.      *
  112.      * @return string
  113.      */
  114.     public function __toString()
  115.     {
  116.         return $this->getKurzbezeichnung();
  117.     }
  118. }