<?phpnamespace JF\JuridicusBundle\Entity;use JF\JuridicusBundle\Utils\Juridicus;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Validator\Constraints as Assert;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;/** * Titel * * @ORM\Entity * @UniqueEntity("name") */class Titel{ const CLASSNAME = __CLASS__; /** * @var array */ private static $default_alias_map = array( 'DR.' => array( 'Dr', 'Dr-' ), 'Prof.' => array( 'Professor' ), 'Prof.Dr.' => array( 'ProfDr', 'Prof Dr.', 'Prof Dr', ), 'Prof.Dr.Dr.' => array( 'Prof.Dr.Dr', 'Prof Dr Dr') ); /** * Get Default Aliases * * @return array */ public static function getDefaultAliases() { return self::$default_alias_map; } /** * @var integer */ private $id; /** * @var string * @Assert\NotBlank * @Assert\Length(max="64") */ private $name; /** * @var string * @Assert\Length(max="64") */ private $slug; /** * @var \Doctrine\Common\Collections\Collection */ private $aliases; /** * @var \JF\JuridicusBundle\Entity\Titel * @Assert\Valid */ private $alias_for; /** * Constructor */ public function __construct() { $this->aliases = new \Doctrine\Common\Collections\ArrayCollection(); $this->pruefer = new \Doctrine\Common\Collections\ArrayCollection(); } /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set name * * @param string $name * @return Titel */ public function setName($name) { $this->name = $name; return $this; } /** * Get name * * @return string */ public function getName() { return $this->name; } /** * Get visible name * * @return string */ public function getVisibleName() { if (isset($this->alias_for)) { return $this->alias_for->getName(); } return $this->getName(); } /** * Set slug * * @param string $slug * @return Titel */ public function setSlug($slug) { $this->slug = $slug; return $this; } /** * Get slug * * @return string */ public function getSlug() { return $this->slug; } /** * Add aliases [INVERSE SIDE] * * @param \JF\JuridicusBundle\Entity\Titel $aliases * @return Titel */ public function addAliase(\JF\JuridicusBundle\Entity\Titel $aliases) { $this->aliases[] = $aliases; $aliases->setAliasFor($this); return $this; } /** * Remove aliases [INVERSE SIDE] * * @param \JF\JuridicusBundle\Entity\Titel $aliases */ public function removeAliase(\JF\JuridicusBundle\Entity\Titel $aliases) { $this->aliases->removeElement($aliases); $aliases->setAliasFor(null); } /** * Get aliases * * @return \Doctrine\Common\Collections\Collection */ public function getAliases() { return $this->aliases; } /** * Set alias_for * * @param \JF\JuridicusBundle\Entity\Titel $aliasFor * @return Titel */ public function setAliasFor(\JF\JuridicusBundle\Entity\Titel $aliasFor = null) { $this->alias_for = $aliasFor; return $this; } /** * Get alias_for * * @return \JF\JuridicusBundle\Entity\Titel */ public function getAliasFor() { return $this->alias_for; } /** * Compare 2 Titel Entities * * @param Titel * @return boolean */ public function equals( Titel $t ) { return $this->name == $t->name; } /** * String Representation * * @return string */ public function __toString() { if (isset($this->name)) { return $this->name; } else { return 'Neuer Titel'; } } /** * @var \Doctrine\Common\Collections\Collection */ private $pruefer; /** * Add pruefer [INVERSE SIDE] * * @param \JF\JuridicusBundle\Entity\Pruefer $pruefer * @return Titel */ public function addPruefer(\JF\JuridicusBundle\Entity\Pruefer $pruefer) { $this->pruefer[] = $pruefer; return $this; } /** * Remove pruefer [INVERSE SIDE] * * @param \JF\JuridicusBundle\Entity\Pruefer $pruefer */ public function removePruefer(\JF\JuridicusBundle\Entity\Pruefer $pruefer) { $this->pruefer->removeElement($pruefer); $pruefer->setTitel(null); } /** * Get pruefer * * @return \Doctrine\Common\Collections\Collection */ public function getPruefer() { return $this->pruefer; }}