src/JuridicusBundle/Entity/Titel.php line 16

Open in your IDE?
  1. <?php
  2. namespace JF\JuridicusBundle\Entity;
  3. use JF\JuridicusBundle\Utils\Juridicus;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. /**
  8.  * Titel
  9.  * 
  10.  * @ORM\Entity
  11.  * @UniqueEntity("name") 
  12.  */
  13. class Titel
  14. {
  15.     const CLASSNAME __CLASS__;
  16.     
  17.     /**
  18.      * @var array
  19.      */
  20.     private static $default_alias_map = array(
  21.         'DR.' => array( 'Dr''Dr-' ),
  22.         'Prof.' => array( 'Professor' ),
  23.         'Prof.Dr.' => array( 'ProfDr''Prof Dr.''Prof Dr', ),
  24.         'Prof.Dr.Dr.' => array( 'Prof.Dr.Dr''Prof Dr Dr')
  25.     );
  26.     /**
  27.      * Get Default Aliases
  28.      *
  29.      * @return array
  30.      */
  31.     public static function getDefaultAliases()
  32.     {
  33.         return self::$default_alias_map;
  34.     }
  35.         
  36.     /**
  37.      * @var integer
  38.      */
  39.     private $id;
  40.     /**
  41.      * @var string
  42.      * @Assert\NotBlank
  43.      * @Assert\Length(max="64")
  44.      */
  45.     private $name;
  46.     /**
  47.      * @var string
  48.      * @Assert\Length(max="64")     
  49.      */
  50.     private $slug;
  51.     /**
  52.      * @var \Doctrine\Common\Collections\Collection
  53.      */
  54.     private $aliases;
  55.     /**
  56.      * @var \JF\JuridicusBundle\Entity\Titel
  57.      * @Assert\Valid
  58.      */
  59.     private $alias_for;
  60.     /**
  61.      * Constructor
  62.      */
  63.     public function __construct()
  64.     {
  65.         $this->aliases = new \Doctrine\Common\Collections\ArrayCollection();
  66.         $this->pruefer = new \Doctrine\Common\Collections\ArrayCollection();        
  67.     }
  68.     
  69.     /**
  70.      * Get id
  71.      *
  72.      * @return integer 
  73.      */
  74.     public function getId()
  75.     {
  76.         return $this->id;
  77.     }
  78.     /**
  79.      * Set name
  80.      *
  81.      * @param string $name
  82.      * @return Titel
  83.      */
  84.     public function setName($name)
  85.     {
  86.         $this->name $name;
  87.     
  88.         return $this;
  89.     }
  90.     /**
  91.      * Get name
  92.      *
  93.      * @return string 
  94.      */
  95.     public function getName()
  96.     {
  97.         return $this->name;
  98.     }
  99.     /**
  100.      * Get visible name
  101.      *
  102.      * @return string 
  103.      */
  104.     public function getVisibleName()
  105.     {
  106.         if (isset($this->alias_for))
  107.         {
  108.             return $this->alias_for->getName();
  109.         }
  110.         return $this->getName();
  111.     }
  112.     /**
  113.      * Set slug
  114.      *
  115.      * @param string $slug
  116.      * @return Titel
  117.      */
  118.     public function setSlug($slug)
  119.     {
  120.         $this->slug $slug;
  121.     
  122.         return $this;
  123.     }
  124.     /**
  125.      * Get slug
  126.      *
  127.      * @return string 
  128.      */
  129.     public function getSlug()
  130.     {
  131.         return $this->slug;
  132.     }
  133.     /**
  134.      * Add aliases [INVERSE SIDE]
  135.      *
  136.      * @param \JF\JuridicusBundle\Entity\Titel $aliases
  137.      * @return Titel
  138.      */
  139.     public function addAliase(\JF\JuridicusBundle\Entity\Titel $aliases)
  140.     {
  141.         $this->aliases[] = $aliases;
  142.         $aliases->setAliasFor($this);
  143.         
  144.         return $this;
  145.     }
  146.     /**
  147.      * Remove aliases [INVERSE SIDE]
  148.      *
  149.      * @param \JF\JuridicusBundle\Entity\Titel $aliases
  150.      */
  151.     public function removeAliase(\JF\JuridicusBundle\Entity\Titel $aliases)
  152.     {
  153.         $this->aliases->removeElement($aliases);
  154.         $aliases->setAliasFor(null);
  155.     }
  156.     /**
  157.      * Get aliases
  158.      *
  159.      * @return \Doctrine\Common\Collections\Collection 
  160.      */
  161.     public function getAliases()
  162.     {
  163.         return $this->aliases;
  164.     }
  165.     /**
  166.      * Set alias_for
  167.      *
  168.      * @param \JF\JuridicusBundle\Entity\Titel $aliasFor
  169.      * @return Titel
  170.      */
  171.     public function setAliasFor(\JF\JuridicusBundle\Entity\Titel $aliasFor null)
  172.     {
  173.         $this->alias_for $aliasFor;
  174.     
  175.         return $this;
  176.     }
  177.     /**
  178.      * Get alias_for
  179.      *
  180.      * @return \JF\JuridicusBundle\Entity\Titel 
  181.      */
  182.     public function getAliasFor()
  183.     {
  184.         return $this->alias_for;
  185.     }
  186.      
  187.     /**
  188.      * Compare 2 Titel Entities
  189.      *
  190.      * @param Titel
  191.      * @return boolean
  192.      */
  193.     public function equalsTitel $t )
  194.     {
  195.         return $this->name == $t->name;        
  196.     }
  197.     /**
  198.      * String Representation
  199.      *
  200.      * @return string
  201.      */
  202.     public function __toString()
  203.     {
  204.         if (isset($this->name))
  205.         {
  206.             return $this->name;
  207.         }
  208.         else 
  209.         {
  210.             return 'Neuer Titel';
  211.         }
  212.     }
  213.     
  214.     /**
  215.      * @var \Doctrine\Common\Collections\Collection
  216.      */
  217.     private $pruefer;
  218.     /**
  219.      * Add pruefer [INVERSE SIDE]
  220.      *
  221.      * @param \JF\JuridicusBundle\Entity\Pruefer $pruefer
  222.      * @return Titel
  223.      */
  224.     public function addPruefer(\JF\JuridicusBundle\Entity\Pruefer $pruefer)
  225.     {
  226.         $this->pruefer[] = $pruefer;
  227.     
  228.         return $this;
  229.     }
  230.     /**
  231.      * Remove pruefer [INVERSE SIDE]
  232.      *
  233.      * @param \JF\JuridicusBundle\Entity\Pruefer $pruefer
  234.      */
  235.     public function removePruefer(\JF\JuridicusBundle\Entity\Pruefer $pruefer)
  236.     {
  237.         $this->pruefer->removeElement($pruefer);
  238.         $pruefer->setTitel(null);
  239.     }
  240.     /**
  241.      * Get pruefer
  242.      *
  243.      * @return \Doctrine\Common\Collections\Collection 
  244.      */
  245.     public function getPruefer()
  246.     {
  247.         return $this->pruefer;
  248.     }
  249. }