1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-06-27 16:36:00 +00:00

Migrate to JMS attributes

This commit is contained in:
Yassine Guedidi 2025-04-05 15:12:30 +02:00
parent a1440dffda
commit a766826a69
8 changed files with 96 additions and 183 deletions

View file

@ -15,7 +15,7 @@ return RectorConfig::configure()
]) ])
->withRootFiles() ->withRootFiles()
->withImportNames(importShortClasses: false) ->withImportNames(importShortClasses: false)
->withAttributesSets(symfony: true, doctrine: true, gedmo: true) ->withAttributesSets(symfony: true, doctrine: true, gedmo: true, jms: true)
->withConfiguredRule(ClassPropertyAssignToConstructorPromotionRector::class, [ ->withConfiguredRule(ClassPropertyAssignToConstructorPromotionRector::class, [
'inline_public' => true, 'inline_public' => true,
]) ])

View file

@ -14,12 +14,11 @@ use Wallabag\Repository\AnnotationRepository;
/** /**
* Annotation. * Annotation.
*
* @ExclusionPolicy("none")
*/ */
#[ORM\Table(name: 'annotation')] #[ORM\Table(name: 'annotation')]
#[ORM\Entity(repositoryClass: AnnotationRepository::class)] #[ORM\Entity(repositoryClass: AnnotationRepository::class)]
#[ORM\HasLifecycleCallbacks] #[ORM\HasLifecycleCallbacks]
#[ExclusionPolicy('none')]
class Annotation class Annotation
{ {
use EntityTimestampsTrait; use EntityTimestampsTrait;
@ -34,10 +33,9 @@ class Annotation
/** /**
* @var string * @var string
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'text', type: 'text')] #[ORM\Column(name: 'text', type: 'text')]
#[Groups(['entries_for_user', 'export_all'])]
private $text; private $text;
/** /**
@ -54,32 +52,26 @@ class Annotation
/** /**
* @var string * @var string
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'quote', type: 'text')] #[ORM\Column(name: 'quote', type: 'text')]
#[Assert\Length(max: 10000, maxMessage: 'validator.quote_length_too_high')] #[Assert\Length(max: 10000, maxMessage: 'validator.quote_length_too_high')]
#[Groups(['entries_for_user', 'export_all'])]
private $quote; private $quote;
/** /**
* @var array * @var array
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'ranges', type: 'array')] #[ORM\Column(name: 'ranges', type: 'array')]
#[Groups(['entries_for_user', 'export_all'])]
private $ranges; private $ranges;
/**
* @Exclude
*/
#[ORM\ManyToOne(targetEntity: User::class)] #[ORM\ManyToOne(targetEntity: User::class)]
#[Exclude]
private $user; private $user;
/**
* @Exclude
*/
#[ORM\JoinColumn(name: 'entry_id', referencedColumnName: 'id', onDelete: 'cascade')] #[ORM\JoinColumn(name: 'entry_id', referencedColumnName: 'id', onDelete: 'cascade')]
#[ORM\ManyToOne(targetEntity: Entry::class, inversedBy: 'annotations')] #[ORM\ManyToOne(targetEntity: Entry::class, inversedBy: 'annotations')]
#[Exclude]
private $entry; private $entry;
/* /*
@ -216,10 +208,8 @@ class Annotation
return $this->user; return $this->user;
} }
/** #[VirtualProperty]
* @VirtualProperty #[SerializedName('user')]
* @SerializedName("user")
*/
public function getUserName() public function getUserName()
{ {
return $this->user->getName(); return $this->user->getName();
@ -250,10 +240,8 @@ class Annotation
return $this->entry; return $this->entry;
} }
/** #[VirtualProperty]
* @VirtualProperty #[SerializedName('annotator_schema_version')]
* @SerializedName("annotator_schema_version")
*/
public function getVersion() public function getVersion()
{ {
return 'v1.0'; return 'v1.0';

View file

@ -28,9 +28,9 @@ class Client extends BaseClient
* type="string", * type="string",
* example="Default Client", * example="Default Client",
* ) * )
* @Groups({"user_api_with_client"})
*/ */
#[ORM\Column(name: 'name', type: 'text', nullable: false)] #[ORM\Column(name: 'name', type: 'text', nullable: false)]
#[Groups(['user_api_with_client'])]
protected $name; protected $name;
#[ORM\OneToMany(targetEntity: RefreshToken::class, mappedBy: 'client', cascade: ['remove'])] #[ORM\OneToMany(targetEntity: RefreshToken::class, mappedBy: 'client', cascade: ['remove'])]
@ -47,10 +47,9 @@ class Client extends BaseClient
* type="string", * type="string",
* example="2lmubx2m9vy80ss8c4wwcsg8ok44s88ocwcc8wo0w884oc8440", * example="2lmubx2m9vy80ss8c4wwcsg8ok44s88ocwcc8wo0w884oc8440",
* ) * )
*
* @SerializedName("client_secret")
* @Groups({"user_api_with_client"})
*/ */
#[SerializedName('client_secret')]
#[Groups(['user_api_with_client'])]
protected $secret; protected $secret;
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'clients')] #[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'clients')]
@ -95,17 +94,15 @@ class Client extends BaseClient
} }
/** /**
* @VirtualProperty
*
* @OA\Property( * @OA\Property(
* description="Client secret used for authorization", * description="Client secret used for authorization",
* type="string", * type="string",
* example="3_1lpybsn0od40css4w4ko8gsc8cwwskggs8kgg448ko0owo4c84", * example="3_1lpybsn0od40css4w4ko8gsc8cwwskggs8kgg448ko0owo4c84",
* ) * )
*
* @SerializedName("client_id")
* @Groups({"user_api_with_client"})
*/ */
#[VirtualProperty]
#[SerializedName('client_id')]
#[Groups(['user_api_with_client'])]
public function getClientId() public function getClientId()
{ {
return $this->getId() . '_' . $this->getRandomId(); return $this->getId() . '_' . $this->getRandomId();

View file

@ -21,56 +21,50 @@ class Config
/** /**
* @var int * @var int
*
* @Groups({"config_api"})
*/ */
#[ORM\Column(name: 'id', type: 'integer')] #[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id] #[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')] #[ORM\GeneratedValue(strategy: 'AUTO')]
#[Groups(['config_api'])]
private $id; private $id;
/** /**
* @var int * @var int
*
* @Groups({"config_api"})
*/ */
#[ORM\Column(name: 'items_per_page', type: 'integer', nullable: false)] #[ORM\Column(name: 'items_per_page', type: 'integer', nullable: false)]
#[Assert\NotBlank] #[Assert\NotBlank]
#[Assert\Range(min: 1, max: 100000, maxMessage: 'validator.item_per_page_too_high')] #[Assert\Range(min: 1, max: 100000, maxMessage: 'validator.item_per_page_too_high')]
#[Groups(['config_api'])]
private $itemsPerPage; private $itemsPerPage;
/** /**
* @var string * @var string
*
* @Groups({"config_api"})
*/ */
#[ORM\Column(name: 'language', type: 'string', nullable: false)] #[ORM\Column(name: 'language', type: 'string', nullable: false)]
#[Assert\NotBlank] #[Assert\NotBlank]
#[Groups(['config_api'])]
private $language; private $language;
/** /**
* @var string|null * @var string|null
*
* @Groups({"config_api"})
*/ */
#[ORM\Column(name: 'feed_token', type: 'string', nullable: true)] #[ORM\Column(name: 'feed_token', type: 'string', nullable: true)]
#[Groups(['config_api'])]
private $feedToken; private $feedToken;
/** /**
* @var int|null * @var int|null
*
* @Groups({"config_api"})
*/ */
#[ORM\Column(name: 'feed_limit', type: 'integer', nullable: true)] #[ORM\Column(name: 'feed_limit', type: 'integer', nullable: true)]
#[Assert\Range(min: 1, max: 100000, maxMessage: 'validator.feed_limit_too_high')] #[Assert\Range(min: 1, max: 100000, maxMessage: 'validator.feed_limit_too_high')]
#[Groups(['config_api'])]
private $feedLimit; private $feedLimit;
/** /**
* @var float|null * @var float|null
*
* @Groups({"config_api"})
*/ */
#[ORM\Column(name: 'reading_speed', type: 'float', nullable: true)] #[ORM\Column(name: 'reading_speed', type: 'float', nullable: true)]
#[Groups(['config_api'])]
private $readingSpeed; private $readingSpeed;
/** /**
@ -81,58 +75,51 @@ class Config
/** /**
* @var int|null * @var int|null
*
* @Groups({"config_api"})
*/ */
#[ORM\Column(name: 'action_mark_as_read', type: 'integer', nullable: true, options: ['default' => 0])] #[ORM\Column(name: 'action_mark_as_read', type: 'integer', nullable: true, options: ['default' => 0])]
#[Groups(['config_api'])]
private $actionMarkAsRead; private $actionMarkAsRead;
/** /**
* @var int|null * @var int|null
*
* @Groups({"config_api"})
*/ */
#[ORM\Column(name: 'list_mode', type: 'integer', nullable: true)] #[ORM\Column(name: 'list_mode', type: 'integer', nullable: true)]
#[Groups(['config_api'])]
private $listMode; private $listMode;
/** /**
* @var int|null * @var int|null
*
* @Groups({"config_api"})
*/ */
#[ORM\Column(name: 'display_thumbnails', type: 'integer', nullable: true, options: ['default' => 1])] #[ORM\Column(name: 'display_thumbnails', type: 'integer', nullable: true, options: ['default' => 1])]
#[Groups(['config_api'])]
private $displayThumbnails; private $displayThumbnails;
/** /**
* @var string|null * @var string|null
*
* @Groups({"config_api"})
*/ */
#[ORM\Column(name: 'font', type: 'text', nullable: true)] #[ORM\Column(name: 'font', type: 'text', nullable: true)]
#[Groups(['config_api'])]
private $font; private $font;
/** /**
* @var float|null * @var float|null
*
* @Groups({"config_api"})
*/ */
#[ORM\Column(name: 'fontsize', type: 'float', nullable: true)] #[ORM\Column(name: 'fontsize', type: 'float', nullable: true)]
#[Groups(['config_api'])]
private $fontsize; private $fontsize;
/** /**
* @var float|null * @var float|null
*
* @Groups({"config_api"})
*/ */
#[ORM\Column(name: 'line_height', type: 'float', nullable: true)] #[ORM\Column(name: 'line_height', type: 'float', nullable: true)]
#[Groups(['config_api'])]
private $lineHeight; private $lineHeight;
/** /**
* @var float|null * @var float|null
*
* @Groups({"config_api"})
*/ */
#[ORM\Column(name: 'max_width', type: 'float', nullable: true)] #[ORM\Column(name: 'max_width', type: 'float', nullable: true)]
#[Groups(['config_api'])]
private $maxWidth; private $maxWidth;
/** /**

View file

@ -18,7 +18,6 @@ use Wallabag\Repository\EntryRepository;
/** /**
* Entry. * Entry.
* *
* @XmlRoot("entry")
* @Hateoas\Relation("self", href = "expr('/api/entries/' ~ object.getId())") * @Hateoas\Relation("self", href = "expr('/api/entries/' ~ object.getId())")
*/ */
#[ORM\Table(name: '`entry`')] #[ORM\Table(name: '`entry`')]
@ -32,6 +31,7 @@ use Wallabag\Repository\EntryRepository;
#[ORM\Index(columns: ['user_id', 'is_starred', 'starred_at'])] #[ORM\Index(columns: ['user_id', 'is_starred', 'starred_at'])]
#[ORM\Entity(repositoryClass: EntryRepository::class)] #[ORM\Entity(repositoryClass: EntryRepository::class)]
#[ORM\HasLifecycleCallbacks] #[ORM\HasLifecycleCallbacks]
#[XmlRoot('entry')]
class Entry class Entry
{ {
use EntityTimestampsTrait; use EntityTimestampsTrait;
@ -39,40 +39,36 @@ class Entry
/** @Serializer\XmlAttribute */ /** @Serializer\XmlAttribute */
/** /**
* @var int * @var int
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'id', type: 'integer')] #[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id] #[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')] #[ORM\GeneratedValue(strategy: 'AUTO')]
#[Groups(['entries_for_user', 'export_all'])]
private $id; private $id;
/** /**
* @var string|null * @var string|null
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'uid', type: 'string', length: 23, nullable: true)] #[ORM\Column(name: 'uid', type: 'string', length: 23, nullable: true)]
#[Groups(['entries_for_user', 'export_all'])]
private $uid; private $uid;
/** /**
* @var string|null * @var string|null
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'title', type: 'text', nullable: true)] #[ORM\Column(name: 'title', type: 'text', nullable: true)]
#[Groups(['entries_for_user', 'export_all'])]
private $title; private $title;
/** /**
* Define the url fetched by wallabag (the final url after potential redirections). * Define the url fetched by wallabag (the final url after potential redirections).
* *
* @var string|null * @var string|null
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'url', type: 'text', nullable: true)] #[ORM\Column(name: 'url', type: 'text', nullable: true)]
#[Assert\NotBlank] #[Assert\NotBlank]
#[Assert\Url(message: "The url '{{ value }}' is not a valid url")] #[Assert\Url(message: "The url '{{ value }}' is not a valid url")]
#[Groups(['entries_for_user', 'export_all'])]
private $url; private $url;
/** /**
@ -85,20 +81,18 @@ class Entry
* From where user retrieved/found the url (an other article, a twitter, or the given_url if non are provided). * From where user retrieved/found the url (an other article, a twitter, or the given_url if non are provided).
* *
* @var string|null * @var string|null
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'origin_url', type: 'text', nullable: true)] #[ORM\Column(name: 'origin_url', type: 'text', nullable: true)]
#[Groups(['entries_for_user', 'export_all'])]
private $originUrl; private $originUrl;
/** /**
* Define the url entered by the user (without redirections). * Define the url entered by the user (without redirections).
* *
* @var string|null * @var string|null
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'given_url', type: 'text', nullable: true)] #[ORM\Column(name: 'given_url', type: 'text', nullable: true)]
#[Groups(['entries_for_user', 'export_all'])]
private $givenUrl; private $givenUrl;
/** /**
@ -109,159 +103,134 @@ class Entry
/** /**
* @var bool * @var bool
*
* @Exclude
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'is_archived', type: 'boolean')] #[ORM\Column(name: 'is_archived', type: 'boolean')]
#[Exclude]
#[Groups(['entries_for_user', 'export_all'])]
private $isArchived = false; private $isArchived = false;
/** /**
* @var \DateTimeInterface|null * @var \DateTimeInterface|null
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'archived_at', type: 'datetime', nullable: true)] #[ORM\Column(name: 'archived_at', type: 'datetime', nullable: true)]
#[Groups(['entries_for_user', 'export_all'])]
private $archivedAt; private $archivedAt;
/** /**
* @var bool * @var bool
*
* @Exclude
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'is_starred', type: 'boolean')] #[ORM\Column(name: 'is_starred', type: 'boolean')]
#[Exclude]
#[Groups(['entries_for_user', 'export_all'])]
private $isStarred = false; private $isStarred = false;
/** /**
* @var string|null * @var string|null
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'content', type: 'text', nullable: true)] #[ORM\Column(name: 'content', type: 'text', nullable: true)]
#[Groups(['entries_for_user', 'export_all'])]
private $content; private $content;
/** /**
* @var \DateTimeInterface * @var \DateTimeInterface
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'created_at', type: 'datetime')] #[ORM\Column(name: 'created_at', type: 'datetime')]
#[Groups(['entries_for_user', 'export_all'])]
private $createdAt; private $createdAt;
/** /**
* @var \DateTimeInterface * @var \DateTimeInterface
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'updated_at', type: 'datetime')] #[ORM\Column(name: 'updated_at', type: 'datetime')]
#[Groups(['entries_for_user', 'export_all'])]
private $updatedAt; private $updatedAt;
/** /**
* @var \DateTimeInterface|null * @var \DateTimeInterface|null
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'published_at', type: 'datetime', nullable: true)] #[ORM\Column(name: 'published_at', type: 'datetime', nullable: true)]
#[Groups(['entries_for_user', 'export_all'])]
private $publishedAt; private $publishedAt;
/** /**
* @var array|null * @var array|null
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'published_by', type: 'array', nullable: true)] #[ORM\Column(name: 'published_by', type: 'array', nullable: true)]
#[Groups(['entries_for_user', 'export_all'])]
private $publishedBy; private $publishedBy;
/** /**
* @var \DateTimeInterface|null * @var \DateTimeInterface|null
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'starred_at', type: 'datetime', nullable: true)] #[ORM\Column(name: 'starred_at', type: 'datetime', nullable: true)]
#[Groups(['entries_for_user', 'export_all'])]
private $starredAt; private $starredAt;
/**
* @Groups({"entries_for_user", "export_all"})
*/
#[ORM\JoinTable] #[ORM\JoinTable]
#[ORM\OneToMany(targetEntity: Annotation::class, mappedBy: 'entry', cascade: ['persist', 'remove'])] #[ORM\OneToMany(targetEntity: Annotation::class, mappedBy: 'entry', cascade: ['persist', 'remove'])]
#[Groups(['entries_for_user', 'export_all'])]
private $annotations; private $annotations;
/** /**
* @var string|null * @var string|null
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'mimetype', type: 'text', nullable: true)] #[ORM\Column(name: 'mimetype', type: 'text', nullable: true)]
#[Groups(['entries_for_user', 'export_all'])]
private $mimetype; private $mimetype;
/** /**
* @var string|null * @var string|null
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'language', type: 'string', length: 20, nullable: true)] #[ORM\Column(name: 'language', type: 'string', length: 20, nullable: true)]
#[Groups(['entries_for_user', 'export_all'])]
private $language; private $language;
/** /**
* @var int * @var int
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'reading_time', type: 'integer', nullable: false)] #[ORM\Column(name: 'reading_time', type: 'integer', nullable: false)]
#[Groups(['entries_for_user', 'export_all'])]
private $readingTime = 0; private $readingTime = 0;
/** /**
* @var string|null * @var string|null
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'domain_name', type: 'text', nullable: true)] #[ORM\Column(name: 'domain_name', type: 'text', nullable: true)]
#[Groups(['entries_for_user', 'export_all'])]
private $domainName; private $domainName;
/** /**
* @var string|null * @var string|null
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'preview_picture', type: 'text', nullable: true)] #[ORM\Column(name: 'preview_picture', type: 'text', nullable: true)]
#[Groups(['entries_for_user', 'export_all'])]
private $previewPicture; private $previewPicture;
/** /**
* @var string|null * @var string|null
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'http_status', type: 'string', length: 3, nullable: true)] #[ORM\Column(name: 'http_status', type: 'string', length: 3, nullable: true)]
#[Groups(['entries_for_user', 'export_all'])]
private $httpStatus; private $httpStatus;
/** /**
* @var array|null * @var array|null
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'headers', type: 'array', nullable: true)] #[ORM\Column(name: 'headers', type: 'array', nullable: true)]
#[Groups(['entries_for_user', 'export_all'])]
private $headers; private $headers;
/** /**
* @var bool * @var bool
*
* @Exclude
*
* @Groups({"entries_for_user", "export_all"})
*/ */
#[ORM\Column(name: 'is_not_parsed', type: 'boolean', options: ['default' => false])] #[ORM\Column(name: 'is_not_parsed', type: 'boolean', options: ['default' => false])]
#[Exclude]
#[Groups(['entries_for_user', 'export_all'])]
private $isNotParsed = false; private $isNotParsed = false;
/**
* @Exclude
*
* @Groups({"export_all"})
*/
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'entries')] #[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'entries')]
#[Exclude]
#[Groups(['export_all'])]
private $user; private $user;
#[ORM\JoinTable(name: 'entry_tag')] #[ORM\JoinTable(name: 'entry_tag')]
@ -400,11 +369,9 @@ class Entry
return $this->isArchived; return $this->isArchived;
} }
/** #[VirtualProperty]
* @VirtualProperty #[SerializedName('is_archived')]
* @SerializedName("is_archived") #[Groups(['entries_for_user', 'export_all'])]
* @Groups({"entries_for_user", "export_all"})
*/
public function is_Archived() public function is_Archived()
{ {
return (int) $this->isArchived(); return (int) $this->isArchived();
@ -441,11 +408,9 @@ class Entry
return $this->isStarred; return $this->isStarred;
} }
/** #[VirtualProperty]
* @VirtualProperty #[SerializedName('is_starred')]
* @SerializedName("is_starred") #[Groups(['entries_for_user', 'export_all'])]
* @Groups({"entries_for_user", "export_all"})
*/
public function is_Starred() public function is_Starred()
{ {
return (int) $this->isStarred(); return (int) $this->isStarred();
@ -490,28 +455,22 @@ class Entry
return $this->user; return $this->user;
} }
/** #[VirtualProperty]
* @VirtualProperty #[SerializedName('user_name')]
* @SerializedName("user_name")
*/
public function getUserName() public function getUserName()
{ {
return $this->user->getUserName(); return $this->user->getUserName();
} }
/** #[VirtualProperty]
* @VirtualProperty #[SerializedName('user_email')]
* @SerializedName("user_email")
*/
public function getUserEmail() public function getUserEmail()
{ {
return $this->user->getEmail(); return $this->user->getEmail();
} }
/** #[VirtualProperty]
* @VirtualProperty #[SerializedName('user_id')]
* @SerializedName("user_id")
*/
public function getUserId() public function getUserId()
{ {
return $this->user->getId(); return $this->user->getId();
@ -666,11 +625,9 @@ class Entry
return $tags; return $tags;
} }
/** #[VirtualProperty]
* @VirtualProperty #[SerializedName('tags')]
* @SerializedName("tags") #[Groups(['entries_for_user', 'export_all'])]
* @Groups({"entries_for_user", "export_all"})
*/
public function getSerializedTags() public function getSerializedTags()
{ {
$data = []; $data = [];
@ -820,12 +777,11 @@ class Entry
* Used in the entries filter so it's more explicit for the end user than the uid. * Used in the entries filter so it's more explicit for the end user than the uid.
* Also used in the API. * Also used in the API.
* *
* @VirtualProperty
* @SerializedName("is_public")
* @Groups({"entries_for_user"})
*
* @return bool * @return bool
*/ */
#[VirtualProperty]
#[SerializedName('is_public')]
#[Groups(['entries_for_user'])]
public function isPublic() public function isPublic()
{ {
return null !== $this->uid; return null !== $this->uid;

View file

@ -12,38 +12,33 @@ use Wallabag\Repository\TagRepository;
/** /**
* Tag. * Tag.
*
* @XmlRoot("tag")
* @ExclusionPolicy("all")
*/ */
#[ORM\Table(name: '`tag`')] #[ORM\Table(name: '`tag`')]
#[ORM\Index(columns: ['label'])] #[ORM\Index(columns: ['label'])]
#[ORM\Entity(repositoryClass: TagRepository::class)] #[ORM\Entity(repositoryClass: TagRepository::class)]
#[XmlRoot('tag')]
#[ExclusionPolicy('all')]
class Tag implements \Stringable class Tag implements \Stringable
{ {
/** /**
* @var int * @var int
*
* @Expose
*/ */
#[ORM\Column(name: 'id', type: 'integer')] #[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id] #[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')] #[ORM\GeneratedValue(strategy: 'AUTO')]
#[Expose]
private $id; private $id;
/** /**
* @var string * @var string
*
* @Expose
*/ */
#[ORM\Column(name: 'label', type: 'text')] #[ORM\Column(name: 'label', type: 'text')]
#[Expose]
private $label; private $label;
/**
* @Expose
*/
#[ORM\Column(length: 128, unique: true)] #[ORM\Column(length: 128, unique: true)]
#[Gedmo\Slug(fields: ['label'], prefix: 't:')] #[Gedmo\Slug(fields: ['label'], prefix: 't:')]
#[Expose]
private $slug; private $slug;
#[ORM\ManyToMany(targetEntity: Entry::class, mappedBy: 'tags', cascade: ['persist'])] #[ORM\ManyToMany(targetEntity: Entry::class, mappedBy: 'tags', cascade: ['persist'])]

View file

@ -12,11 +12,10 @@ use Wallabag\Repository\TaggingRuleRepository;
/** /**
* Tagging rule. * Tagging rule.
*
* @XmlRoot("tagging_rule")
*/ */
#[ORM\Table(name: '`tagging_rule`')] #[ORM\Table(name: '`tagging_rule`')]
#[ORM\Entity(repositoryClass: TaggingRuleRepository::class)] #[ORM\Entity(repositoryClass: TaggingRuleRepository::class)]
#[XmlRoot('tagging_rule')]
class TaggingRule implements RuleInterface class TaggingRule implements RuleInterface
{ {
/** /**
@ -34,27 +33,23 @@ class TaggingRule implements RuleInterface
* allowed_variables={"title", "url", "isArchived", "isStarred", "content", "language", "mimetype", "readingTime", "domainName"}, * allowed_variables={"title", "url", "isArchived", "isStarred", "content", "language", "mimetype", "readingTime", "domainName"},
* allowed_operators={">", "<", ">=", "<=", "=", "is", "!=", "and", "not", "or", "matches", "notmatches"} * allowed_operators={">", "<", ">=", "<=", "=", "is", "!=", "and", "not", "or", "matches", "notmatches"}
* ) * )
*
* @Groups({"export_tagging_rule"})
*/ */
#[ORM\Column(name: 'rule', type: 'string', nullable: false)] #[ORM\Column(name: 'rule', type: 'string', nullable: false)]
#[Assert\NotBlank] #[Assert\NotBlank]
#[Assert\Length(max: 255)] #[Assert\Length(max: 255)]
#[Groups(['export_tagging_rule'])]
private $rule; private $rule;
/** /**
* @var array<string> * @var array<string>
*
* @Groups({"export_tagging_rule"})
*/ */
#[ORM\Column(name: 'tags', type: 'simple_array', nullable: false)] #[ORM\Column(name: 'tags', type: 'simple_array', nullable: false)]
#[Assert\NotBlank] #[Assert\NotBlank]
#[Groups(['export_tagging_rule'])]
private $tags = []; private $tags = [];
/**
* @Exclude
*/
#[ORM\ManyToOne(targetEntity: Config::class, inversedBy: 'taggingRules')] #[ORM\ManyToOne(targetEntity: Config::class, inversedBy: 'taggingRules')]
#[Exclude]
private $config; private $config;
/** /**

View file

@ -20,14 +20,13 @@ use Wallabag\Repository\UserRepository;
/** /**
* User. * User.
*
* @XmlRoot("user")
*/ */
#[ORM\Table(name: '`user`')] #[ORM\Table(name: '`user`')]
#[ORM\Entity(repositoryClass: UserRepository::class)] #[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\HasLifecycleCallbacks] #[ORM\HasLifecycleCallbacks]
#[UniqueEntity('email')] #[UniqueEntity('email')]
#[UniqueEntity('username')] #[UniqueEntity('username')]
#[XmlRoot('user')]
class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorInterface, BackupCodeInterface class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorInterface, BackupCodeInterface
{ {
use EntityTimestampsTrait; use EntityTimestampsTrait;
@ -41,12 +40,11 @@ class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorI
* type="int", * type="int",
* example=12, * example=12,
* ) * )
*
* @Groups({"user_api", "user_api_with_client"})
*/ */
#[ORM\Column(name: 'id', type: 'integer')] #[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id] #[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')] #[ORM\GeneratedValue(strategy: 'AUTO')]
#[Groups(['user_api', 'user_api_with_client'])]
protected $id; protected $id;
/** /**
@ -57,9 +55,9 @@ class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorI
* type="string", * type="string",
* example="Walla Baggger", * example="Walla Baggger",
* ) * )
* @Groups({"user_api", "user_api_with_client"})
*/ */
#[ORM\Column(name: 'name', type: 'text', nullable: true)] #[ORM\Column(name: 'name', type: 'text', nullable: true)]
#[Groups(['user_api', 'user_api_with_client'])]
protected $name; protected $name;
/** /**
@ -70,9 +68,8 @@ class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorI
* type="string", * type="string",
* example="wallabag", * example="wallabag",
* ) * )
*
* @Groups({"user_api", "user_api_with_client"})
*/ */
#[Groups(['user_api', 'user_api_with_client'])]
protected $username; protected $username;
/** /**
@ -83,9 +80,8 @@ class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorI
* type="string", * type="string",
* example="wallabag@wallabag.io", * example="wallabag@wallabag.io",
* ) * )
*
* @Groups({"user_api", "user_api_with_client"})
*/ */
#[Groups(['user_api', 'user_api_with_client'])]
protected $email; protected $email;
/** /**
@ -96,9 +92,9 @@ class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorI
* type="string", * type="string",
* example="2023-06-27T19:25:44+0000", * example="2023-06-27T19:25:44+0000",
* ) * )
* @Groups({"user_api", "user_api_with_client"})
*/ */
#[ORM\Column(name: 'created_at', type: 'datetime')] #[ORM\Column(name: 'created_at', type: 'datetime')]
#[Groups(['user_api', 'user_api_with_client'])]
protected $createdAt; protected $createdAt;
/** /**
@ -109,9 +105,9 @@ class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorI
* type="string", * type="string",
* example="2023-06-27T19:37:30+0000", * example="2023-06-27T19:37:30+0000",
* ) * )
* @Groups({"user_api", "user_api_with_client"})
*/ */
#[ORM\Column(name: 'updated_at', type: 'datetime')] #[ORM\Column(name: 'updated_at', type: 'datetime')]
#[Groups(['user_api', 'user_api_with_client'])]
protected $updatedAt; protected $updatedAt;
#[ORM\OneToMany(targetEntity: Entry::class, mappedBy: 'user', cascade: ['remove'])] #[ORM\OneToMany(targetEntity: Entry::class, mappedBy: 'user', cascade: ['remove'])]
@ -139,10 +135,9 @@ class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorI
* description="Default client created during user registration. Used for further authorization", * description="Default client created during user registration. Used for further authorization",
* ref=@Model(type=Client::class, groups={"user_api_with_client"}) * ref=@Model(type=Client::class, groups={"user_api_with_client"})
* ) * )
*
* @Groups({"user_api_with_client"})
* @Accessor(getter="getFirstClient")
*/ */
#[Groups(['user_api_with_client'])]
#[Accessor(getter: 'getFirstClient')]
protected $default_client; protected $default_client;
#[ORM\Column(type: 'integer', nullable: true)] #[ORM\Column(type: 'integer', nullable: true)]