Migrate to Doctrine attributes

This commit is contained in:
Yassine Guedidi
2025-04-05 12:55:51 +02:00
parent 0d93add058
commit 41767e8fbc
16 changed files with 201 additions and 334 deletions

View File

@ -4,29 +4,22 @@ namespace Wallabag\Entity\Api;
use Doctrine\ORM\Mapping as ORM;
use FOS\OAuthServerBundle\Entity\AccessToken as BaseAccessToken;
use Wallabag\Entity\User;
/**
* @ORM\Table("oauth2_access_tokens")
* @ORM\Entity
*/
#[ORM\Table('oauth2_access_tokens')]
#[ORM\Entity]
class AccessToken extends BaseAccessToken
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected $id;
/**
* @ORM\ManyToOne(targetEntity="Wallabag\Entity\Api\Client", inversedBy="accessTokens")
* @ORM\JoinColumn(nullable=false)
*/
#[ORM\JoinColumn(nullable: false)]
#[ORM\ManyToOne(targetEntity: Client::class, inversedBy: 'accessTokens')]
protected $client;
/**
* @ORM\ManyToOne(targetEntity="Wallabag\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")
*/
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
#[ORM\ManyToOne(targetEntity: User::class)]
protected $user;
}

View File

@ -4,29 +4,22 @@ namespace Wallabag\Entity\Api;
use Doctrine\ORM\Mapping as ORM;
use FOS\OAuthServerBundle\Entity\AuthCode as BaseAuthCode;
use Wallabag\Entity\User;
/**
* @ORM\Table("oauth2_auth_codes")
* @ORM\Entity
*/
#[ORM\Table('oauth2_auth_codes')]
#[ORM\Entity]
class AuthCode extends BaseAuthCode
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected $id;
/**
* @ORM\ManyToOne(targetEntity="Wallabag\Entity\Api\Client")
* @ORM\JoinColumn(nullable=false)
*/
#[ORM\JoinColumn(nullable: false)]
#[ORM\ManyToOne(targetEntity: Client::class)]
protected $client;
/**
* @ORM\ManyToOne(targetEntity="Wallabag\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")
*/
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
#[ORM\ManyToOne(targetEntity: User::class)]
protected $user;
}

View File

@ -9,43 +9,34 @@ use JMS\Serializer\Annotation\SerializedName;
use JMS\Serializer\Annotation\VirtualProperty;
use OpenApi\Annotations as OA;
use Wallabag\Entity\User;
use Wallabag\Repository\Api\ClientRepository;
/**
* @ORM\Table("oauth2_clients")
* @ORM\Entity(repositoryClass="Wallabag\Repository\Api\ClientRepository")
*/
#[ORM\Table('oauth2_clients')]
#[ORM\Entity(repositoryClass: ClientRepository::class)]
class Client extends BaseClient
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected $id;
/**
* @var string
*
* @ORM\Column(name="name", type="text", nullable=false)
*
* @OA\Property(
* description="Name of the API client",
* type="string",
* example="Default Client",
* )
*
* @Groups({"user_api_with_client"})
*/
#[ORM\Column(name: 'name', type: 'text', nullable: false)]
protected $name;
/**
* @ORM\OneToMany(targetEntity="Wallabag\Entity\Api\RefreshToken", mappedBy="client", cascade={"remove"})
*/
#[ORM\OneToMany(targetEntity: RefreshToken::class, mappedBy: 'client', cascade: ['remove'])]
protected $refreshTokens;
/**
* @ORM\OneToMany(targetEntity="Wallabag\Entity\Api\AccessToken", mappedBy="client", cascade={"remove"})
*/
#[ORM\OneToMany(targetEntity: AccessToken::class, mappedBy: 'client', cascade: ['remove'])]
protected $accessTokens;
/**
@ -62,9 +53,7 @@ class Client extends BaseClient
*/
protected $secret;
/**
* @ORM\ManyToOne(targetEntity="Wallabag\Entity\User", inversedBy="clients")
*/
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'clients')]
private $user;
public function __construct(User $user)

View File

@ -4,29 +4,22 @@ namespace Wallabag\Entity\Api;
use Doctrine\ORM\Mapping as ORM;
use FOS\OAuthServerBundle\Entity\RefreshToken as BaseRefreshToken;
use Wallabag\Entity\User;
/**
* @ORM\Table("oauth2_refresh_tokens")
* @ORM\Entity
*/
#[ORM\Table('oauth2_refresh_tokens')]
#[ORM\Entity]
class RefreshToken extends BaseRefreshToken
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected $id;
/**
* @ORM\ManyToOne(targetEntity="Wallabag\Entity\Api\Client", inversedBy="refreshTokens")
* @ORM\JoinColumn(nullable=false)
*/
#[ORM\JoinColumn(nullable: false)]
#[ORM\ManyToOne(targetEntity: Client::class, inversedBy: 'refreshTokens')]
protected $client;
/**
* @ORM\ManyToOne(targetEntity="Wallabag\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")
*/
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
#[ORM\ManyToOne(targetEntity: User::class)]
protected $user;
}