X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FUserBundle%2FEntity%2FUser.php;h=f93c59c7e9aab09959091044e1dc85df10641470;hb=3b68f6ca727f52f9dc84fa1a134c092b44c49103;hp=d2efd20080b4bee41b3d7b6badbbe94a7770c675;hpb=3d3ed955f11006a408c6596eb9151a0afb28e721;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/UserBundle/Entity/User.php b/src/Wallabag/UserBundle/Entity/User.php index d2efd200..f93c59c7 100644 --- a/src/Wallabag/UserBundle/Entity/User.php +++ b/src/Wallabag/UserBundle/Entity/User.php @@ -1,40 +1,57 @@ entries = new ArrayCollection(); - $this->tags = new ArrayCollection(); - $this->roles = array('ROLE_USER'); - } - - /** - * @ORM\PrePersist - * @ORM\PreUpdate - */ - public function timestamps() - { - if (is_null($this->createdAt)) { - $this->createdAt = new \DateTime(); - } - - $this->updatedAt = new \DateTime(); + $this->roles = ['ROLE_USER']; } /** @@ -136,7 +184,7 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf } /** - * @return string + * @return \DateTime */ public function getCreatedAt() { @@ -144,7 +192,7 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf } /** - * @return string + * @return \DateTime */ public function getUpdatedAt() { @@ -171,26 +219,6 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf return $this->entries; } - /** - * @param Entry $entry - * - * @return User - */ - public function addTag(Tag $tag) - { - $this->tags[] = $tag; - - return $this; - } - - /** - * @return ArrayCollection - */ - public function getTags() - { - return $this->tags; - } - public function isEqualTo(UserInterface $user) { return $this->username === $user->getUsername(); @@ -267,4 +295,65 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf return false; } + + /** + * @param Client $client + * + * @return User + */ + public function addClient(Client $client) + { + $this->clients[] = $client; + + return $this; + } + + /** + * @return ArrayCollection + */ + public function getClients() + { + return $this->clients; + } + + /** + * Only used by the API when creating a new user it'll also return the first client (which was also created at the same time). + * + * @return Client + */ + public function getFirstClient() + { + if (!empty($this->clients)) { + return $this->clients->first(); + } + } + + /** + * Set dn. + * + * @param string $dn + * + * @return User + */ + public function setDn($dn) + { + $this->dn = $dn; + + return $this; + } + + /** + * Get dn. + * + * @return string + */ + public function getDn() + { + return $this->dn; + } + + public function isLdapUser() + { + return $this->dn !== null; + } }