src/JuridicusBundle/Entity/PrueferPruefung.php line 13

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.  * PrueferPruefung
  8.  * @UniqueEntity(fields={"pruefung","pruefer"}, message="Ein Prüfer kann nur einmal an einer Prüfung teilnehmen.")
  9.  */
  10. class PrueferPruefung
  11. {
  12.     const CLASSNAME __CLASS__;
  13.     
  14.     /**
  15.      *
  16.      * @var array
  17.      */
  18.     private static $fach_map = array(
  19.         'Strafrecht' => array(
  20.             's''sr''srecht''srav' ,'str''strr''strafr''strafrp''starfrecht''wahlsrecht',
  21.             'strafr''srafr''srtrafr''stafr''srafrecht'
  22.         ),
  23.         'Zivilrecht' => array(
  24.             'z''zrecht''zr''zrav''zruvortrag''zrecht''zivi''zivil''zivilr''zivr''zivillr',
  25.             'zraktenvortrag''zivilerecht'
  26.         ),
  27.         'Öffentliches Recht' => array(
  28.             'ö''ör''örav''örecht''öfrecht''öff''öffr''öffrecht''örsteuerr''öffentlichesr',
  29.             'öffentrech''öffentlr''öffentlich''öffentliche''öffentliches',
  30.             'öfftlrecht''öffentlrecht',
  31.             'örpflicht''örwahl''öffentlichesrecht',
  32.         ),
  33.         'Arbeitsrecht' => array(
  34.             'arbeitsrecht''arecht''arbeitsr',
  35.         ),
  36.         'Verwaltungsrecht' => array(
  37.             'verwaltungsrecht''vrecht''verwaltungsr'
  38.         )
  39.     );
  40.     /**
  41.      * Vereinheitlicht den Namen eines Faches (Auto-Korrektur)
  42.      *
  43.      * @param string $fach
  44.      * @return string|null
  45.      */
  46.     public static function unifyFach($fach)
  47.     {
  48.         if (empty($fach)) {
  49.             return null;
  50.         }
  51.         $fach2 mb_strtolower($fach,'UTF-8');
  52.         $fach2 preg_replace('#[^a-zäöüß]#'''$fach2);
  53.         foreach(self::$fach_map as $key => $array) {
  54.             if (in_array($fach2$array)) {
  55.                 return $key;
  56.             }
  57.             $key2 mb_strtolower($key'UTF-8');
  58.             $key2 preg_replace('#[^a-zäöüß]#'''$key2);
  59.             if (strpos($fach2$key2) !== false) {
  60.                 return $key;
  61.             }
  62.             $n similar_text($fach2$key2$percent);
  63.             if ($percent 80) {
  64.                 return $key;
  65.             }
  66.         }
  67.         return $fach;
  68.     }
  69.     /**
  70.      * @var integer
  71.      */
  72.     private $id;
  73.     /**
  74.      * @var boolean
  75.      * @Assert\NotNull()
  76.      */
  77.     private $vorsitz false;
  78.     /**
  79.      * @var integer
  80.      */
  81.     private $sortierung;
  82.     /**
  83.      * @var string
  84.      * @Assert\Length(max="18")
  85.      */
  86.     private $fach;
  87.     /**
  88.      * @var \JF\JuridicusBundle\Entity\Pruefer
  89.      * @Assert\Valid()
  90.      * @Assert\NotNull()
  91.      */
  92.     private $pruefer;
  93.     /**
  94.      * @var \JF\JuridicusBundle\Entity\Pruefung
  95.      * @Assert\Valid()
  96.      * @Assert\NotNull()
  97.      */
  98.     private $pruefung;
  99.     /**
  100.      * Get id
  101.      *
  102.      * @return integer
  103.      */
  104.     public function getId()
  105.     {
  106.         return $this->id;
  107.     }
  108.     /**
  109.      * Set vorsitz
  110.      *
  111.      * @param boolean $vorsitz
  112.      * @return PrueferPruefung
  113.      */
  114.     public function setVorsitz($vorsitz true)
  115.     {
  116.         $this->vorsitz = (bool) $vorsitz;
  117.         return $this;
  118.     }
  119.     /**
  120.      * Get vorsitz
  121.      *
  122.      * @return boolean
  123.      */
  124.     public function getVorsitz()
  125.     {
  126.         return $this->vorsitz;
  127.     }
  128.     /**
  129.      * Set sortierung
  130.      *
  131.      * @param integer $sortierung
  132.      * @return PrueferPruefung
  133.      */
  134.     public function setSortierung($sortierung)
  135.     {
  136.         $this->sortierung $sortierung;
  137.         return $this;
  138.     }
  139.     /**
  140.      * Get sortierung
  141.      *
  142.      * @return integer
  143.      */
  144.     public function getSortierung()
  145.     {
  146.         return $this->sortierung;
  147.     }
  148.     /**
  149.      * Set fach - impliziert Auto-Korrektur
  150.      *
  151.      * @param string $fach
  152.      * @return PrueferPruefung
  153.      */
  154.     public function setFach($fach)
  155.     {
  156.         $this->fach self::unifyFach($fach);
  157.         return $this;
  158.     }
  159.     /**
  160.      * Get fach
  161.      *
  162.      * @return string
  163.      */
  164.     public function getFach()
  165.     {
  166.         return $this->fach;
  167.     }
  168.     /**
  169.      * Set pruefer [OWNING SIDE]
  170.      *
  171.      * @param \JF\JuridicusBundle\Entity\Pruefer $pruefer
  172.      * @return PrueferPruefung
  173.      */
  174.     public function setPruefer(Pruefer $pruefer null)
  175.     {
  176.         $this->pruefer $pruefer;
  177.         return $this;
  178.     }
  179.     /**
  180.      * Get pruefer
  181.      *
  182.      * @return \JF\JuridicusBundle\Entity\Pruefer
  183.      */
  184.     public function getPruefer()
  185.     {
  186.         return $this->pruefer;
  187.     }
  188.     /**
  189.      * Set pruefung [OWNING SIDE]
  190.      *
  191.      * @param \JF\JuridicusBundle\Entity\Pruefung $pruefung
  192.      * @return PrueferPruefung
  193.      */
  194.     public function setPruefung(Pruefung $pruefung null)
  195.     {
  196.         $this->pruefung $pruefung;
  197.         return $this;
  198.     }
  199.     /**
  200.      * Get pruefung
  201.      *
  202.      * @return \JF\JuridicusBundle\Entity\Pruefung
  203.      */
  204.     public function getPruefung()
  205.     {
  206.         return $this->pruefung;
  207.     }
  208.     /**
  209.      *
  210.      * @param \JF\JuridicusBundle\Entity\PrueferPruefung $compare
  211.      * @return boolean
  212.      */
  213.     public function equals(PrueferPruefung $compare)
  214.     {
  215.          return true
  216.              && $this->getVorsitz() == $compare->getVorsitz()
  217.             && $this->getSortierung() == $compare->getSortierung()
  218.              && $this->getFach() == $compare->getFach()
  219.              && $this->getPruefer()->getId() == $compare->getPruefer()->getId()
  220.              && $this->getPruefung()->getId() == $compare->getPruefung()->getId()
  221.          ;
  222.     }
  223.     /**
  224.      * String Representation
  225.      *
  226.      * @return string
  227.      */
  228.     public function __toString()
  229.     {
  230.          return $this->getPruefer() ? $this->getPruefer()->getFullText() : 'n-a';
  231.     }
  232. }