src/Entity/ApiClient.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Symfony\Component\Security\Core\User\UserInterface;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6. * @ORM\Entity
  7. * @ORM\Table(name="malys_api_client")
  8. * @ORM\HasLifecycleCallbacks()
  9. */
  10. class ApiClient implements UserInterface {
  11. /**
  12. * @ORM\Id
  13. * @ORM\GeneratedValue(strategy="AUTO")
  14. * @ORM\Column(type="integer")
  15. */
  16. private $id;
  17. /**
  18. * @ORM\Column(type="string", unique=true)
  19. */
  20. private $name;
  21. /**
  22. * @ORM\Column(type="string", unique=true)
  23. */
  24. private $username;
  25. /**
  26. * @ORM\Column(type="string", unique=true)
  27. */
  28. private $apiKey;
  29. /**
  30. * @var boolean
  31. *
  32. * @ORM\Column(name="enabled", type="boolean" )
  33. */
  34. protected $enabled = true;
  35. public function getUsername() {
  36. return $this->username;
  37. }
  38. public function getRoles() {
  39. return array( 'ROLE_API_CLIENT' );
  40. }
  41. public function getPassword() {
  42. return null;
  43. }
  44. public function getSalt() {
  45. return null;
  46. }
  47. public function eraseCredentials() {
  48. }
  49. /**
  50. * @var \DateTime
  51. *
  52. * @ORM\Column(name="createdAt", type="datetime", nullable=false)
  53. */
  54. protected $createdAt;
  55. /**
  56. * @var \DateTime
  57. *
  58. * @ORM\Column(name="updatedAt", type="datetime", nullable=true)
  59. */
  60. protected $updatedAt;
  61. /**
  62. * Set createdAt
  63. *
  64. * @return $this
  65. * @ORM\PrePersist
  66. */
  67. public function setCreatedAt() {
  68. $this->createdAt = new \DateTime();
  69. $this->updatedAt = new \DateTime();
  70. return $this;
  71. }
  72. /**
  73. * @return \DateTime
  74. */
  75. public function getUpdatedAt() {
  76. return $this->updatedAt;
  77. }
  78. /**
  79. * Set updatedAt
  80. *
  81. * @return $this
  82. * @ORM\PreUpdate
  83. */
  84. public function setUpdatedAt() {
  85. $this->updatedAt = new \DateTime();
  86. return $this;
  87. }
  88. /**
  89. * @return mixed
  90. */
  91. public function getApiKey() {
  92. return $this->apiKey;
  93. }
  94. /**
  95. * @param mixed $apiKey
  96. */
  97. public function setApiKey( $apiKey ) {
  98. $this->apiKey = $apiKey;
  99. $this->username = $apiKey;
  100. }
  101. /**
  102. * @return bool
  103. */
  104. public function isEnabled() {
  105. return $this->enabled;
  106. }
  107. /**
  108. * @param bool $enabled
  109. */
  110. public function setEnabled( $enabled ) {
  111. $this->enabled = $enabled;
  112. }
  113. /**
  114. * @return mixed
  115. */
  116. public function getName() {
  117. return $this->name;
  118. }
  119. /**
  120. * @param mixed $name
  121. */
  122. public function setName( $name ) {
  123. $this->name = $name;
  124. }
  125. /**
  126. * @return mixed
  127. */
  128. public function getId() {
  129. return $this->id;
  130. }
  131. /**
  132. * @param mixed $id
  133. */
  134. public function setId( $id ) {
  135. $this->id = $id;
  136. }
  137. }
  138. ?>