src/AppBundle/Entity/Configuration.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\AppBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5. * Configuration
  6. *
  7. * @ORM\Table(name="configuration")
  8. * @ORM\Entity(repositoryClass="App\AppBundle\Repository\ConfigurationRepository")
  9. */
  10. class Configuration implements \JsonSerializable,\Serializable
  11. {
  12. const VISIBILITY_PUBLIC ="public";
  13. const VISIBILITY_PRIVATE="private";
  14. const VISIBILITY_PREDEFINED_ANALYSIS="predefinedAnalysis";
  15. /**
  16. * @var int
  17. *
  18. * @ORM\Column(name="id", type="integer")
  19. * @ORM\Id
  20. * @ORM\GeneratedValue(strategy="AUTO")
  21. */
  22. private $id;
  23. /**
  24. * @var string
  25. *
  26. * @ORM\Column(name="name", type="string",length=255)
  27. */
  28. private $name;
  29. /**
  30. * Many configurations have one dataset
  31. * @ORM\ManyToOne(targetEntity="App\AppBundle\Entity\Dataset", inversedBy="configurations")
  32. * @ORM\JoinColumn(name="dataset", referencedColumnName="id", nullable=true)
  33. */
  34. private $dataset;
  35. /**
  36. * Many configurations have one user
  37. * @ORM\ManyToOne(targetEntity="App\AppBundle\Entity\User", inversedBy="configurations")
  38. * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=true)
  39. */
  40. private $user;
  41. /**
  42. * @var string
  43. * @ORM\Column(name="visibility", type="string", length=255, options={"default":"private"})
  44. */
  45. private $visibility;
  46. /**
  47. * @var boolean
  48. * @ORM\Column(name="enabled", type="boolean", options={"default":1})
  49. */
  50. private $enabled;
  51. /**
  52. * @var string
  53. * @ORM\Column(name="configuration", type="text")
  54. */
  55. private $configuration ;
  56. /**
  57. * Get id
  58. *
  59. * @return int
  60. */
  61. public function getId()
  62. {
  63. return $this->id;
  64. }
  65. /**
  66. * @return string
  67. */
  68. public function getName()
  69. {
  70. return $this->name;
  71. }
  72. /**
  73. * @param string $name
  74. */
  75. public function setName($name)
  76. {
  77. $this->name = $name;
  78. }
  79. /**
  80. * @return mixed
  81. */
  82. public function getDataset()
  83. {
  84. return $this->dataset;
  85. }
  86. /**
  87. * @param mixed $dataset
  88. */
  89. public function setDataset($dataset)
  90. {
  91. $this->dataset = $dataset;
  92. }
  93. /**
  94. * @return mixed
  95. */
  96. public function getUser()
  97. {
  98. return $this->user;
  99. }
  100. /**
  101. * @param mixed $user
  102. */
  103. public function setUser($user)
  104. {
  105. $this->user = $user;
  106. }
  107. public function __toString()
  108. {
  109. return $this->getName();
  110. }
  111. /**
  112. * @return string
  113. */
  114. public function getVisibility()
  115. {
  116. return $this->visibility;
  117. }
  118. /**
  119. * @param string $visibility
  120. */
  121. public function setVisibility($visibility)
  122. {
  123. $this->visibility = $visibility;
  124. }
  125. /**
  126. * @return bool
  127. */
  128. public function isEnabled()
  129. {
  130. return $this->enabled;
  131. }
  132. /**
  133. * @param bool $enabled
  134. */
  135. public function setEnabled($enabled)
  136. {
  137. $this->enabled = $enabled;
  138. }
  139. /**
  140. * @return string
  141. */
  142. public function getConfiguration()
  143. {
  144. return $this->configuration;
  145. }
  146. /**
  147. * @param string $configuration
  148. */
  149. public function setConfiguration($configuration)
  150. {
  151. $this->configuration = $configuration;
  152. }
  153. /** @see \Serializable::serialize() */
  154. public function serialize()
  155. {
  156. return serialize(array(
  157. $this->id,
  158. $this->enabled,
  159. $this->user,
  160. $this->name,
  161. $this->visibility,
  162. $this->dataset,
  163. $this->configuration
  164. ));
  165. }
  166. /**
  167. * Constructs the object
  168. * @link http://php.net/manual/en/serializable.unserialize.php
  169. * @param string $serialized <p>
  170. * The string representation of the object.
  171. * </p>
  172. * @return void
  173. * @since 5.1.0
  174. */
  175. public function unserialize($serialized)
  176. {
  177. list (
  178. $this->id,
  179. $this->enabled,
  180. $this->user,
  181. $this->name,
  182. $this->visibility,
  183. $this->dataset,
  184. $this->configuration
  185. ) = unserialize($serialized);
  186. }
  187. /**
  188. * Specify data which should be serialized to JSON
  189. * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
  190. * @return mixed data which can be serialized by <b>json_encode</b>,
  191. * which is a value of any type other than a resource.
  192. * @since 5.4.0
  193. */
  194. public function jsonSerialize()
  195. {
  196. return json_encode(array(
  197. "id"=>$this->id,
  198. "enabled"=>$this->enabled,
  199. "user"=>$this->user->getId(),
  200. "name"=>$this->name,
  201. "visibility"=>$this->visibility,
  202. "dataset"=>$this->dataset->getId(),
  203. "configuration"=>$this->configuration),
  204. JSON_PRETTY_PRINT);
  205. }
  206. }