3 namespace Wallabag\ApiBundle\Entity
;
5 use Doctrine\ORM\Mapping
as ORM
;
6 use FOS\OAuthServerBundle\Entity\Client
as BaseClient
;
7 use Wallabag\UserBundle\Entity\User
;
8 use JMS\Serializer\Annotation\Groups
;
9 use JMS\Serializer\Annotation\SerializedName
;
10 use JMS\Serializer\Annotation\VirtualProperty
;
11 use Symfony\Component\Validator\Constraints
as Assert
;
14 * @ORM\Table("oauth2_clients")
17 class Client
extends BaseClient
21 * @ORM\Column(type="integer")
22 * @ORM\GeneratedValue(strategy="AUTO")
29 * @ORM\Column(name="name", type="text", nullable=false)
31 * @Groups({"user_api_with_client"})
36 * @ORM\OneToMany(targetEntity="RefreshToken", mappedBy="client", cascade={"remove"})
38 protected $refreshTokens;
41 * @ORM\OneToMany(targetEntity="AccessToken", mappedBy="client", cascade={"remove"})
43 protected $accessTokens;
48 * @SerializedName("client_secret")
49 * @Groups({"user_api_with_client"})
54 * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="clients")
55 * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=true)
60 * @ORM\Column(type="string", nullable=true)
65 * @ORM\Column(type="string", nullable=true)
70 * @ORM\Column(type="string", nullable=true)
75 * @ORM\Column(type="datetime", nullable=true)
81 * @param User|null $user
83 public function __construct(User
$user = null)
85 parent
::__construct();
87 $this->createdAt
= new \
DateTime();
95 public function getName()
103 * @param string $name
107 public function setName($name)
117 public function getUser()
124 * @SerializedName("client_id")
125 * @Groups({"user_api_with_client"})
127 public function getClientId()
129 return $this->getId() . '_' . $this->getRandomId();
135 public function getImage()
141 * @param string $image
143 public function setImage($image)
145 $this->image
= $image;
151 public function getDescription()
153 return $this->description
;
157 * @param string $description
159 public function setDescription($description)
161 $this->description
= $description;
167 public function getAppUrl()
169 return $this->appUrl
;
173 * @param string $appUrl
175 public function setAppUrl($appUrl)
177 $this->appUrl
= $appUrl;
183 public function getCreatedAt()
185 return $this->createdAt
;