]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Entity/TaggingRule.php
Merge pull request #1 from wallabag/master
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / TaggingRule.php
index 20c15258291b1b59a7eb9e6db6103195d3b93ea6..f716608716f1dbde4cc82cf24ff5d4ef03a5bbab 100644 (file)
@@ -3,14 +3,18 @@
 namespace Wallabag\CoreBundle\Entity;
 
 use Doctrine\ORM\Mapping as ORM;
+use JMS\Serializer\Annotation\Exclude;
+use JMS\Serializer\Annotation\Groups;
+use JMS\Serializer\Annotation\XmlRoot;
+use Symfony\Bridge\RulerZ\Validator\Constraints as RulerZAssert;
 use Symfony\Component\Validator\Constraints as Assert;
-use KPhoen\RulerZBundle\Validator\Constraints as RulerZAssert;
 
 /**
- * Config.
+ * Tagging rule.
  *
+ * @XmlRoot("tagging_rule")
  * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\TaggingRuleRepository")
- * @ORM\Table
+ * @ORM\Table(name="`tagging_rule`")
  * @ORM\Entity
  */
 class TaggingRule
@@ -28,8 +32,14 @@ class TaggingRule
      * @var string
      *
      * @Assert\NotBlank()
-     * @RulerZAssert\ValidRule()
+     * @Assert\Length(max=255)
+     * @RulerZAssert\ValidRule(
+     *  allowed_variables={"title", "url", "isArchived", "isStared", "content", "language", "mimetype", "readingTime", "domainName"},
+     *  allowed_operators={">", "<", ">=", "<=", "=", "is", "!=", "and", "not", "or", "matches", "notmatches"}
+     * )
      * @ORM\Column(name="rule", type="string", nullable=false)
+     *
+     * @Groups({"export_tagging_rule"})
      */
     private $rule;
 
@@ -38,10 +48,14 @@ class TaggingRule
      *
      * @Assert\NotBlank()
      * @ORM\Column(name="tags", type="simple_array", nullable=false)
+     *
+     * @Groups({"export_tagging_rule"})
      */
     private $tags = [];
 
     /**
+     * @Exclude
+     *
      * @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\Config", inversedBy="taggingRules")
      */
     private $config;
@@ -83,7 +97,7 @@ class TaggingRule
     /**
      * Set tags.
      *
-     * @param array<string> $tags
+     * @param array <string> $tags
      *
      * @return TaggingRule
      */
@@ -107,8 +121,6 @@ class TaggingRule
     /**
      * Set config.
      *
-     * @param Config $config
-     *
      * @return TaggingRule
      */
     public function setConfig(Config $config)