vendor/sulu/form-bundle/Entity/FormFieldTranslation.php line 17

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of Sulu.
  4. *
  5. * (c) Sulu GmbH
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace Sulu\Bundle\FormBundle\Entity;
  11. /**
  12. * Form field translation entity.
  13. */
  14. class FormFieldTranslation
  15. {
  16. /**
  17. * @var null|string
  18. */
  19. private $title;
  20. /**
  21. * @var string
  22. */
  23. private $locale;
  24. /**
  25. * @var null|int
  26. */
  27. private $id;
  28. /**
  29. * @var FormField
  30. */
  31. private $field;
  32. /**
  33. * @var null|string
  34. */
  35. private $placeholder;
  36. /**
  37. * @var null|string
  38. */
  39. private $defaultValue;
  40. /**
  41. * @var null|string
  42. */
  43. private $shortTitle;
  44. /**
  45. * @var string|null
  46. */
  47. private $options;
  48. public function setTitle(?string $title): self
  49. {
  50. if ($title) {
  51. // this is a replacement for enterMode br which does not longer exist in ckeditor 5
  52. // see also https://github.com/sulu/sulu/issues/5214
  53. $title = \str_replace(
  54. ['</p><p>', '<p>', '</p>'],
  55. ['<br/><br/>', '', ''],
  56. $title
  57. );
  58. }
  59. $this->title = $title;
  60. return $this;
  61. }
  62. public function getTitle(): ?string
  63. {
  64. return $this->title;
  65. }
  66. public function setLocale(string $locale): self
  67. {
  68. $this->locale = $locale;
  69. return $this;
  70. }
  71. public function getLocale(): string
  72. {
  73. return $this->locale;
  74. }
  75. public function getId(): ?int
  76. {
  77. return $this->id;
  78. }
  79. public function setField(FormField $field): FormFieldTranslation
  80. {
  81. $this->field = $field;
  82. return $this;
  83. }
  84. public function getField(): FormField
  85. {
  86. return $this->field;
  87. }
  88. public function getPlaceholder(): ?string
  89. {
  90. return $this->placeholder;
  91. }
  92. public function setPlaceholder(?string $placeholder): self
  93. {
  94. $this->placeholder = $placeholder;
  95. return $this;
  96. }
  97. /**
  98. * @return mixed|null
  99. */
  100. public function getDefaultValue()
  101. {
  102. return $this->defaultValue;
  103. }
  104. /**
  105. * @param mixed|null $defaultValue
  106. */
  107. public function setDefaultValue($defaultValue): self
  108. {
  109. $this->defaultValue = $defaultValue;
  110. return $this;
  111. }
  112. public function getShortTitle(): ?string
  113. {
  114. return $this->shortTitle;
  115. }
  116. public function setShortTitle(?string $shortTitle): self
  117. {
  118. $this->shortTitle = $shortTitle;
  119. return $this;
  120. }
  121. /**
  122. * @return mixed[]
  123. */
  124. public function getOptions(): array
  125. {
  126. if (!$this->options) {
  127. return [];
  128. }
  129. return \json_decode($this->options, true);
  130. }
  131. /**
  132. * @param mixed[] $options
  133. */
  134. public function setOptions(?array $options): self
  135. {
  136. if (\is_array($options)) {
  137. $options = \json_encode($options);
  138. }
  139. $this->options = $options;
  140. return $this;
  141. }
  142. /**
  143. * @return mixed
  144. */
  145. public function getOption(string $key)
  146. {
  147. if (isset($this->getOptions()[$key])) {
  148. return $this->getOptions()[$key];
  149. }
  150. }
  151. }