1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-09-15 18:57:05 +00:00

Add IgnoreOriginRule-related entities, db migration, update config

Add IgnoreOriginUserRule for user-defined rules and
IgnoreOriginInstanceRule for system-wide rules. Add an interface for
these two new entities.

Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
This commit is contained in:
Kevin Decherf 2019-06-23 22:13:06 +02:00
parent 8a8a78a64c
commit c675bd11c6
10 changed files with 302 additions and 1 deletions

View file

@ -119,6 +119,12 @@ class Config
*/
private $taggingRules;
/**
* @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\IgnoreOriginUserRule", mappedBy="config", cascade={"remove"})
* @ORM\OrderBy({"id" = "ASC"})
*/
private $ignoreOriginRules;
/*
* @param User $user
*/
@ -126,6 +132,7 @@ class Config
{
$this->user = $user;
$this->taggingRules = new ArrayCollection();
$this->ignoreOriginRules = new ArrayCollection();
}
/**
@ -387,4 +394,22 @@ class Config
{
return $this->taggingRules;
}
/**
* @return Config
*/
public function addIgnoreOriginRule(IgnoreOriginUserRule $rule)
{
$this->ignoreOriginRules[] = $rule;
return $this;
}
/**
* @return ArrayCollection<IgnoreOriginUserRule>
*/
public function getIgnoreOriginRules()
{
return $this->ignoreOriginRules;
}
}

View file

@ -0,0 +1,71 @@
<?php
namespace Wallabag\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\RulerZ\Validator\Constraints as RulerZAssert;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Ignore Origin rule.
*
* @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\IgnoreOriginInstanceRuleRepository")
* @ORM\Table(name="`ignore_origin_instance_rule`")
* @ORM\Entity
*/
class IgnoreOriginInstanceRule implements IgnoreOriginRuleInterface, RuleInterface
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @Assert\NotBlank()
* @Assert\Length(max=255)
* @RulerZAssert\ValidRule(
* allowed_variables={"host","pattern"},
* allowed_operators={"=","~"}
* )
* @ORM\Column(name="rule", type="string", nullable=false)
*/
private $rule;
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set rule.
*
* @return IgnoreOriginRuleInterface
*/
public function setRule(string $rule)
{
$this->rule = $rule;
return $this;
}
/**
* Get rule.
*
* @return string
*/
public function getRule()
{
return $this->rule;
}
}

View file

@ -0,0 +1,12 @@
<?php
namespace Wallabag\CoreBundle\Entity;
interface IgnoreOriginRuleInterface
{
public function getId();
public function setRule(string $rule);
public function getRule();
}

View file

@ -0,0 +1,98 @@
<?php
namespace Wallabag\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\RulerZ\Validator\Constraints as RulerZAssert;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Ignore Origin rule.
*
* @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\IgnoreOriginUserRuleRepository")
* @ORM\Table(name="`ignore_origin_user_rule`")
* @ORM\Entity
*/
class IgnoreOriginUserRule implements IgnoreOriginRuleInterface, RuleInterface
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @Assert\NotBlank()
* @Assert\Length(max=255)
* @RulerZAssert\ValidRule(
* allowed_variables={"host","pattern"},
* allowed_operators={"=","~"}
* )
* @ORM\Column(name="rule", type="string", nullable=false)
*/
private $rule;
/**
* @ORM\ManyToOne(targetEntity="Wallabag\CoreBundle\Entity\Config", inversedBy="ignoreOriginRules")
*/
private $config;
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set rule.
*
* @return IgnoreOriginRuleInterface
*/
public function setRule(string $rule)
{
$this->rule = $rule;
return $this;
}
/**
* Get rule.
*
* @return string
*/
public function getRule()
{
return $this->rule;
}
/**
* Set config.
*
* @return IgnoreOriginUserRule
*/
public function setConfig(Config $config)
{
$this->config = $config;
return $this;
}
/**
* Get config.
*
* @return Config
*/
public function getConfig()
{
return $this->config;
}
}

View file

@ -0,0 +1,7 @@
<?php
namespace Wallabag\CoreBundle\Entity;
interface RuleInterface
{
}

View file

@ -17,7 +17,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* @ORM\Table(name="`tagging_rule`")
* @ORM\Entity
*/
class TaggingRule
class TaggingRule implements RuleInterface
{
/**
* @var int

View file

@ -0,0 +1,9 @@
<?php
namespace Wallabag\CoreBundle\Repository;
use Doctrine\ORM\EntityRepository;
class IgnoreOriginInstanceRuleRepository extends EntityRepository
{
}

View file

@ -0,0 +1,9 @@
<?php
namespace Wallabag\CoreBundle\Repository;
use Doctrine\ORM\EntityRepository;
class IgnoreOriginUserRuleRepository extends EntityRepository
{
}

View file

@ -131,6 +131,12 @@ services:
calls:
- [ setCrypto, [ "@wallabag_core.helper.crypto_proxy" ] ]
wallabag_core.ignore_origin_instance_rule_repository:
class: Wallabag\CoreBundle\Repository\IgnoreOriginInstanceRuleRepository
factory: [ "@doctrine.orm.default_entity_manager", getRepository ]
arguments:
- WallabagCoreBundle:IgnoreOriginInstanceRule
wallabag_core.helper.entries_export:
class: Wallabag\CoreBundle\Helper\EntriesExport
arguments: