Migrate to Symfony attributes

This commit is contained in:
Yassine Guedidi
2025-04-05 15:06:57 +02:00
parent 6a3780ce81
commit 2a60d8473d
46 changed files with 143 additions and 256 deletions

View File

@ -55,14 +55,10 @@ class Annotation
/**
* @var string
*
* @Assert\Length(
* max = 10000,
* maxMessage = "validator.quote_length_too_high"
* )
*
* @Groups({"entries_for_user", "export_all"})
*/
#[ORM\Column(name: 'quote', type: 'text')]
#[Assert\Length(max: 10000, maxMessage: 'validator.quote_length_too_high')]
private $quote;
/**

View File

@ -32,26 +32,20 @@ class Config
/**
* @var int
*
* @Assert\NotBlank()
* @Assert\Range(
* min = 1,
* max = 100000,
* maxMessage = "validator.item_per_page_too_high"
* )
*
* @Groups({"config_api"})
*/
#[ORM\Column(name: 'items_per_page', type: 'integer', nullable: false)]
#[Assert\NotBlank]
#[Assert\Range(min: 1, max: 100000, maxMessage: 'validator.item_per_page_too_high')]
private $itemsPerPage;
/**
* @var string
*
* @Assert\NotBlank()
*
* @Groups({"config_api"})
*/
#[ORM\Column(name: 'language', type: 'string', nullable: false)]
#[Assert\NotBlank]
private $language;
/**
@ -65,14 +59,10 @@ class Config
/**
* @var int|null
*
* @Assert\Range(
* min = 1,
* max = 100000,
* maxMessage = "validator.feed_limit_too_high"
* )
* @Groups({"config_api"})
*/
#[ORM\Column(name: 'feed_limit', type: 'integer', nullable: true)]
#[Assert\Range(min: 1, max: 100000, maxMessage: 'validator.feed_limit_too_high')]
private $feedLimit;
/**

View File

@ -68,14 +68,11 @@ class Entry
*
* @var string|null
*
* @Assert\NotBlank()
* @Assert\Url(
* message = "The url '{{ value }}' is not a valid url",
* )
*
* @Groups({"entries_for_user", "export_all"})
*/
#[ORM\Column(name: 'url', type: 'text', nullable: true)]
#[Assert\NotBlank]
#[Assert\Url(message: "The url '{{ value }}' is not a valid url")]
private $url;
/**

View File

@ -25,14 +25,14 @@ class IgnoreOriginInstanceRule implements IgnoreOriginRuleInterface, RuleInterfa
/**
* @var string
*
* @Assert\NotBlank()
* @Assert\Length(max=255)
* @RulerZAssert\ValidRule(
* allowed_variables={"host","_all"},
* allowed_operators={"=","~"}
* )
*/
#[ORM\Column(name: 'rule', type: 'string', nullable: false)]
#[Assert\NotBlank]
#[Assert\Length(max: 255)]
private $rule;
/**

View File

@ -25,14 +25,14 @@ class IgnoreOriginUserRule implements IgnoreOriginRuleInterface, RuleInterface
/**
* @var string
*
* @Assert\NotBlank()
* @Assert\Length(max=255)
* @RulerZAssert\ValidRule(
* allowed_variables={"host","_all"},
* allowed_operators={"=","~"}
* )
*/
#[ORM\Column(name: 'rule', type: 'string', nullable: false)]
#[Assert\NotBlank]
#[Assert\Length(max: 255)]
private $rule;
#[ORM\JoinColumn(nullable: false)]

View File

@ -27,27 +27,24 @@ class SiteCredential
/**
* @var string
*
* @Assert\NotBlank()
* @Assert\Length(max=255)
*/
#[ORM\Column(name: 'host', type: 'string', length: 255)]
#[Assert\NotBlank]
#[Assert\Length(max: 255)]
private $host;
/**
* @var string
*
* @Assert\NotBlank()
*/
#[ORM\Column(name: 'username', type: 'text')]
#[Assert\NotBlank]
private $username;
/**
* @var string
*
* @Assert\NotBlank()
*/
#[ORM\Column(name: 'password', type: 'text')]
#[Assert\NotBlank]
private $password;
/**

View File

@ -30,8 +30,6 @@ class TaggingRule implements RuleInterface
/**
* @var string
*
* @Assert\NotBlank()
* @Assert\Length(max=255)
* @RulerZAssert\ValidRule(
* allowed_variables={"title", "url", "isArchived", "isStarred", "content", "language", "mimetype", "readingTime", "domainName"},
* allowed_operators={">", "<", ">=", "<=", "=", "is", "!=", "and", "not", "or", "matches", "notmatches"}
@ -40,16 +38,17 @@ class TaggingRule implements RuleInterface
* @Groups({"export_tagging_rule"})
*/
#[ORM\Column(name: 'rule', type: 'string', nullable: false)]
#[Assert\NotBlank]
#[Assert\Length(max: 255)]
private $rule;
/**
* @var array<string>
*
* @Assert\NotBlank()
*
* @Groups({"export_tagging_rule"})
*/
#[ORM\Column(name: 'tags', type: 'simple_array', nullable: false)]
#[Assert\NotBlank]
private $tags = [];
/**

View File

@ -22,13 +22,12 @@ use Wallabag\Repository\UserRepository;
* User.
*
* @XmlRoot("user")
*
* @UniqueEntity("email")
* @UniqueEntity("username")
*/
#[ORM\Table(name: '`user`')]
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\HasLifecycleCallbacks]
#[UniqueEntity('email')]
#[UniqueEntity('username')]
class User extends BaseUser implements EmailTwoFactorInterface, GoogleTwoFactorInterface, BackupCodeInterface
{
use EntityTimestampsTrait;