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