src/JuridicusBundle/Entity/ProtokollGesetz.php line 16

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. * ProtokollGesetz
  8. *
  9. * @ORM\Entity
  10. * @UniqueEntity(fields={"sortierung","protokoll_infothek_pruefer"}, message="Dieser Eintrag existiert bereits.")
  11. */
  12. class ProtokollGesetz extends ProtokollGesetzBase
  13. {
  14. const CLASSNAME = __CLASS__;
  15. /**
  16. * @var Gesetz
  17. */
  18. private $gesetz;
  19. /**
  20. * @Assert\IsFalse(
  21. * groups = {"admin"},
  22. * message = "Die Kombination aus Paragraph und Gesetz darf nicht leer sein."
  23. * )
  24. * changedFrom Assert\False
  25. */
  26. public function isEmpty()
  27. {
  28. return empty($this->paragraph) && empty($this->gesetz);
  29. }
  30. /**
  31. * @Assert\IsFalse(
  32. * groups = {"finish"},
  33. * message = "Paragraph und Gesetz müssen ausgewählt werden."
  34. * )
  35. * changedFrom Assert\False
  36. */
  37. public function isIncomplete()
  38. {
  39. return empty($this->paragraph) ^ empty($this->gesetz);
  40. }
  41. /**
  42. * @var \JF\JuridicusBundle\Entity\ProtokollInfothekPruefer
  43. * @Assert\NotNull(message = "Der Prüfer darf nicht leer sein.")
  44. */
  45. protected $protokoll_infothek_pruefer;
  46. /**
  47. * Set protokoll_infothek_pruefer
  48. *
  49. * @param \JF\JuridicusBundle\Entity\ProtokollInfothekPruefer $protokollInfothekPruefer
  50. * @return ProtokollGesetz
  51. */
  52. public function setProtokollInfothekPruefer(ProtokollInfothekPruefer $protokollInfothekPruefer = null)
  53. {
  54. $this->protokoll_infothek_pruefer = $protokollInfothekPruefer;
  55. return $this;
  56. }
  57. /**
  58. * Get protokoll_infothek_pruefer
  59. *
  60. * @return \JF\JuridicusBundle\Entity\ProtokollInfothekPruefer
  61. */
  62. public function getProtokollInfothekPruefer()
  63. {
  64. return $this->protokoll_infothek_pruefer;
  65. }
  66. /**
  67. * Set gesetz
  68. *
  69. * @param \JF\JuridicusBundle\Entity\Gesetz $gesetz
  70. * @return ProtokollGesetzBase
  71. */
  72. public function setGesetz(Gesetz $gesetz = null)
  73. {
  74. $this->gesetz = $gesetz;
  75. return $this;
  76. }
  77. /**
  78. * Get gesetz
  79. *
  80. * @return \JF\JuridicusBundle\Entity\Gesetz
  81. */
  82. public function getGesetz()
  83. {
  84. return $this->gesetz;
  85. }
  86. /**
  87. * @return string
  88. */
  89. public function getAbsoluteLink()
  90. {
  91. if ($this->gesetz && $this->paragraph) {
  92. return sprintf('https://dejure.org/%s/%s.html', $this->getGesetz()->getLink(), $this->paragraph);
  93. } else {
  94. return '#';
  95. }
  96. }
  97. /**
  98. *
  99. * @return string
  100. */
  101. public function getKurzbezeichnung()
  102. {
  103. if ($this->gesetz && $this->paragraph) {
  104. return sprintf('§%s %s', $this->getParagraph(), $this->getGesetz()->getExtendedKuerzel());
  105. } else {
  106. return 'unvollständig';
  107. }
  108. }
  109. /**
  110. *
  111. * @return string
  112. */
  113. public function __toString()
  114. {
  115. return $this->getKurzbezeichnung();
  116. }
  117. }