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