diff options
author | Kévin Gomez <contact@kevingomez.fr> | 2015-11-13 14:37:58 +0100 |
---|---|---|
committer | Kévin Gomez <contact@kevingomez.fr> | 2015-11-13 14:37:58 +0100 |
commit | a6e27f74663637ecc4a4cf84028e6b5a3556a6ff (patch) | |
tree | 98e0ef2d9d2d11283a08ec0dc0af0f7c6c2e4887 | |
parent | 5c514b0be320d683c22a3044d875a5e4b5fe6ce0 (diff) | |
download | wallabag-a6e27f74663637ecc4a4cf84028e6b5a3556a6ff.tar.gz wallabag-a6e27f74663637ecc4a4cf84028e6b5a3556a6ff.tar.zst wallabag-a6e27f74663637ecc4a4cf84028e6b5a3556a6ff.zip |
Add matches operator
-rw-r--r-- | composer.json | 2 | ||||
-rw-r--r-- | composer.lock | 18 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/TaggingRule.php | 2 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Operator/Doctrine/Matches.php | 15 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Operator/PHP/Matches.php | 11 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Resources/config/services.yml | 10 |
6 files changed, 47 insertions, 11 deletions
diff --git a/composer.json b/composer.json index 949f7e32..8fc5ce5b 100644 --- a/composer.json +++ b/composer.json | |||
@@ -58,7 +58,7 @@ | |||
58 | "scheb/two-factor-bundle": "~1.4", | 58 | "scheb/two-factor-bundle": "~1.4", |
59 | "grandt/phpepub": "~4.0", | 59 | "grandt/phpepub": "~4.0", |
60 | "wallabag/php-mobi": "~1.0.0", | 60 | "wallabag/php-mobi": "~1.0.0", |
61 | "kphoen/rulerz-bundle": "~0.9,>=0.9.1" | 61 | "kphoen/rulerz-bundle": "~0.10" |
62 | }, | 62 | }, |
63 | "require-dev": { | 63 | "require-dev": { |
64 | "doctrine/doctrine-fixtures-bundle": "~2.2.0", | 64 | "doctrine/doctrine-fixtures-bundle": "~2.2.0", |
diff --git a/composer.lock b/composer.lock index 9a4397ba..eea3f8a0 100644 --- a/composer.lock +++ b/composer.lock | |||
@@ -4,8 +4,8 @@ | |||
4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", | 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", |
5 | "This file is @generated automatically" | 5 | "This file is @generated automatically" |
6 | ], | 6 | ], |
7 | "hash": "9372aa161ce94f8b5506d7e9cc73a884", | 7 | "hash": "fed9468f6c830b0f81899daad7670af7", |
8 | "content-hash": "e703c21d623d708ff9528c298d7ab05f", | 8 | "content-hash": "394f8a6ca5162f2d2756dbbee0ff5aae", |
9 | "packages": [ | 9 | "packages": [ |
10 | { | 10 | { |
11 | "name": "doctrine/annotations", | 11 | "name": "doctrine/annotations", |
@@ -2731,22 +2731,22 @@ | |||
2731 | }, | 2731 | }, |
2732 | { | 2732 | { |
2733 | "name": "kphoen/rulerz-bundle", | 2733 | "name": "kphoen/rulerz-bundle", |
2734 | "version": "0.9.1", | 2734 | "version": "0.11.0", |
2735 | "source": { | 2735 | "source": { |
2736 | "type": "git", | 2736 | "type": "git", |
2737 | "url": "https://github.com/K-Phoen/RulerZBundle.git", | 2737 | "url": "https://github.com/K-Phoen/RulerZBundle.git", |
2738 | "reference": "0d8d6ca57ebf2c914c967bc13cdf13c5ebb2de62" | 2738 | "reference": "dcaaed69d8252fa1e3a25802f8cf697947570778" |
2739 | }, | 2739 | }, |
2740 | "dist": { | 2740 | "dist": { |
2741 | "type": "zip", | 2741 | "type": "zip", |
2742 | "url": "https://api.github.com/repos/K-Phoen/RulerZBundle/zipball/0d8d6ca57ebf2c914c967bc13cdf13c5ebb2de62", | 2742 | "url": "https://api.github.com/repos/K-Phoen/RulerZBundle/zipball/dcaaed69d8252fa1e3a25802f8cf697947570778", |
2743 | "reference": "0d8d6ca57ebf2c914c967bc13cdf13c5ebb2de62", | 2743 | "reference": "dcaaed69d8252fa1e3a25802f8cf697947570778", |
2744 | "shasum": "" | 2744 | "shasum": "" |
2745 | }, | 2745 | }, |
2746 | "require": { | 2746 | "require": { |
2747 | "kphoen/rulerz": "~0.1, >=0.13.0", | 2747 | "kphoen/rulerz": "~0.1, >=0.13.0", |
2748 | "symfony/framework-bundle": "~2.3", | 2748 | "symfony/framework-bundle": "~2.3|~3.0", |
2749 | "symfony/validator": "~2.3" | 2749 | "symfony/validator": "~2.3|~3.0" |
2750 | }, | 2750 | }, |
2751 | "require-dev": { | 2751 | "require-dev": { |
2752 | "matthiasnoback/symfony-dependency-injection-test": "~0.7", | 2752 | "matthiasnoback/symfony-dependency-injection-test": "~0.7", |
@@ -2777,7 +2777,7 @@ | |||
2777 | "rulerz", | 2777 | "rulerz", |
2778 | "specification" | 2778 | "specification" |
2779 | ], | 2779 | ], |
2780 | "time": "2015-11-11 15:37:07" | 2780 | "time": "2015-11-13 13:00:14" |
2781 | }, | 2781 | }, |
2782 | { | 2782 | { |
2783 | "name": "kriswallsmith/assetic", | 2783 | "name": "kriswallsmith/assetic", |
diff --git a/src/Wallabag/CoreBundle/Entity/TaggingRule.php b/src/Wallabag/CoreBundle/Entity/TaggingRule.php index 851af932..4eab590f 100644 --- a/src/Wallabag/CoreBundle/Entity/TaggingRule.php +++ b/src/Wallabag/CoreBundle/Entity/TaggingRule.php | |||
@@ -30,7 +30,7 @@ class TaggingRule | |||
30 | * @Assert\NotBlank() | 30 | * @Assert\NotBlank() |
31 | * @RulerZAssert\ValidRule( | 31 | * @RulerZAssert\ValidRule( |
32 | * allowed_variables={"title", "url", "isArchived", "isStared", "content", "language", "mimetype", "readingTime", "domainName"}, | 32 | * allowed_variables={"title", "url", "isArchived", "isStared", "content", "language", "mimetype", "readingTime", "domainName"}, |
33 | * allowed_operators={">", "<", ">=", "<=", "=", "is", "!=", "and", "not", "or"} | 33 | * allowed_operators={">", "<", ">=", "<=", "=", "is", "!=", "and", "not", "or", "matches"} |
34 | * ) | 34 | * ) |
35 | * @ORM\Column(name="rule", type="string", nullable=false) | 35 | * @ORM\Column(name="rule", type="string", nullable=false) |
36 | */ | 36 | */ |
diff --git a/src/Wallabag/CoreBundle/Operator/Doctrine/Matches.php b/src/Wallabag/CoreBundle/Operator/Doctrine/Matches.php new file mode 100644 index 00000000..dc47c982 --- /dev/null +++ b/src/Wallabag/CoreBundle/Operator/Doctrine/Matches.php | |||
@@ -0,0 +1,15 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Operator\Doctrine; | ||
4 | |||
5 | class Matches | ||
6 | { | ||
7 | public function __invoke($subject, $pattern) | ||
8 | { | ||
9 | if ($pattern[0] === "'") { | ||
10 | $pattern = sprintf("'%%%s%%'", substr($pattern, 1, -1)); | ||
11 | } | ||
12 | |||
13 | return sprintf('UPPER(%s) LIKE UPPER(%s)', $subject, $pattern); | ||
14 | } | ||
15 | } | ||
diff --git a/src/Wallabag/CoreBundle/Operator/PHP/Matches.php b/src/Wallabag/CoreBundle/Operator/PHP/Matches.php new file mode 100644 index 00000000..4768900c --- /dev/null +++ b/src/Wallabag/CoreBundle/Operator/PHP/Matches.php | |||
@@ -0,0 +1,11 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Operator\PHP; | ||
4 | |||
5 | class Matches | ||
6 | { | ||
7 | public function __invoke($subject, $pattern) | ||
8 | { | ||
9 | return stripos($subject, $pattern) !== false; | ||
10 | } | ||
11 | } | ||
diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml index 03d33560..c92b4eb3 100644 --- a/src/Wallabag/CoreBundle/Resources/config/services.yml +++ b/src/Wallabag/CoreBundle/Resources/config/services.yml | |||
@@ -91,3 +91,13 @@ services: | |||
91 | arguments: | 91 | arguments: |
92 | - %wallabag_url% | 92 | - %wallabag_url% |
93 | - src/Wallabag/CoreBundle/Resources/views/themes/_global/public/img/appicon/apple-touch-icon-152.png | 93 | - src/Wallabag/CoreBundle/Resources/views/themes/_global/public/img/appicon/apple-touch-icon-152.png |
94 | |||
95 | wallabag.operator.array.matches: | ||
96 | class: Wallabag\CoreBundle\Operator\PHP\Matches | ||
97 | tags: | ||
98 | - { name: rulerz.operator, executor: rulerz.executor.array, operator: matches } | ||
99 | |||
100 | wallabag.operator.doctrine.matches: | ||
101 | class: Wallabag\CoreBundle\Operator\Doctrine\Matches | ||
102 | tags: | ||
103 | - { name: rulerz.operator, executor: rulerz.executor.doctrine, operator: matches, inline: true } | ||