From b0da721a5238ece3056ae7af760e9455f7af3e11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 3 Oct 2016 21:39:01 +0200 Subject: Changed relation between API client and refresh token Fix #2350 --- src/Wallabag/ApiBundle/Entity/Client.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/Wallabag/ApiBundle/Entity') diff --git a/src/Wallabag/ApiBundle/Entity/Client.php b/src/Wallabag/ApiBundle/Entity/Client.php index 3e2f491c..92b2f762 100644 --- a/src/Wallabag/ApiBundle/Entity/Client.php +++ b/src/Wallabag/ApiBundle/Entity/Client.php @@ -25,6 +25,11 @@ class Client extends BaseClient */ protected $name; + /** + * @ORM\OneToMany(targetEntity="RefreshToken", mappedBy="client", cascade={"remove"}) + */ + protected $refreshTokens; + public function __construct() { parent::__construct(); -- cgit v1.2.3 From ee32248f43baef7e995c9e420cd00a137e626cf0 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sat, 8 Oct 2016 00:02:22 +0200 Subject: Ensure access_token are removed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When we remove the client, we should ensure that access_token are also removed. To ensure that, I created a test that generated an access_token. So when we remove the client, this association should be cascaded and shouldn’t generate an error. Also I moved some Api related stuff to the ApiBundle (like the developer controler and ClientType form) --- src/Wallabag/ApiBundle/Entity/Client.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/Wallabag/ApiBundle/Entity') diff --git a/src/Wallabag/ApiBundle/Entity/Client.php b/src/Wallabag/ApiBundle/Entity/Client.php index 92b2f762..f7898ac8 100644 --- a/src/Wallabag/ApiBundle/Entity/Client.php +++ b/src/Wallabag/ApiBundle/Entity/Client.php @@ -30,6 +30,11 @@ class Client extends BaseClient */ protected $refreshTokens; + /** + * @ORM\OneToMany(targetEntity="AccessToken", mappedBy="client", cascade={"remove"}) + */ + protected $accessTokens; + public function __construct() { parent::__construct(); -- cgit v1.2.3 From 8dc4cd0f25838d074a1b512392f2087a44d26f54 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 9 Oct 2016 20:51:37 +0200 Subject: Fix entities definition As per Doctrine said in the debug tool bar: - The field Wallabag\ApiBundle\Entity\Client#refreshTokens is on the inverse side of a bi-directional relationship, but the specified mappedBy association on the target-entity Wallabag\ApiBundle\Entity\RefreshToken#client does not contain the required 'inversedBy="refreshTokens"' attribute. - The field Wallabag\ApiBundle\Entity\Client#accessTokens is on the inverse side of a bi-directional relationship, but the specified mappedBy association on the target-entity Wallabag\ApiBundle\Entity\AccessToken#client does not contain the required 'inversedBy="accessTokens"' attribute. --- src/Wallabag/ApiBundle/Entity/AccessToken.php | 2 +- src/Wallabag/ApiBundle/Entity/RefreshToken.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Wallabag/ApiBundle/Entity') diff --git a/src/Wallabag/ApiBundle/Entity/AccessToken.php b/src/Wallabag/ApiBundle/Entity/AccessToken.php index 2ff63a83..c09a0c80 100644 --- a/src/Wallabag/ApiBundle/Entity/AccessToken.php +++ b/src/Wallabag/ApiBundle/Entity/AccessToken.php @@ -19,7 +19,7 @@ class AccessToken extends BaseAccessToken protected $id; /** - * @ORM\ManyToOne(targetEntity="Client") + * @ORM\ManyToOne(targetEntity="Client", inversedBy="accessTokens") * @ORM\JoinColumn(nullable=false) */ protected $client; diff --git a/src/Wallabag/ApiBundle/Entity/RefreshToken.php b/src/Wallabag/ApiBundle/Entity/RefreshToken.php index 6d0cab68..822a02d8 100644 --- a/src/Wallabag/ApiBundle/Entity/RefreshToken.php +++ b/src/Wallabag/ApiBundle/Entity/RefreshToken.php @@ -19,7 +19,7 @@ class RefreshToken extends BaseRefreshToken protected $id; /** - * @ORM\ManyToOne(targetEntity="Client") + * @ORM\ManyToOne(targetEntity="Client", inversedBy="refreshTokens") * @ORM\JoinColumn(nullable=false) */ protected $client; -- cgit v1.2.3