aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Entity/TaggingRule.php2
-rw-r--r--src/Wallabag/CoreBundle/Operator/Doctrine/Matches.php15
-rw-r--r--src/Wallabag/CoreBundle/Operator/PHP/Matches.php11
-rw-r--r--src/Wallabag/CoreBundle/Resources/config/services.yml10
4 files changed, 37 insertions, 1 deletions
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
3namespace Wallabag\CoreBundle\Operator\Doctrine;
4
5class 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
3namespace Wallabag\CoreBundle\Operator\PHP;
4
5class 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 }