]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Add matches operator
authorKévin Gomez <contact@kevingomez.fr>
Fri, 13 Nov 2015 13:37:58 +0000 (14:37 +0100)
committerKévin Gomez <contact@kevingomez.fr>
Fri, 13 Nov 2015 13:37:58 +0000 (14:37 +0100)
composer.json
composer.lock
src/Wallabag/CoreBundle/Entity/TaggingRule.php
src/Wallabag/CoreBundle/Operator/Doctrine/Matches.php [new file with mode: 0644]
src/Wallabag/CoreBundle/Operator/PHP/Matches.php [new file with mode: 0644]
src/Wallabag/CoreBundle/Resources/config/services.yml

index 949f7e32bf39bfa28f4e642caa2521a87094d9df..8fc5ce5bfb1a688986703cddb91ed27f4429cdd6 100644 (file)
@@ -58,7 +58,7 @@
         "scheb/two-factor-bundle": "~1.4",
         "grandt/phpepub": "~4.0",
         "wallabag/php-mobi": "~1.0.0",
-        "kphoen/rulerz-bundle": "~0.9,>=0.9.1"
+        "kphoen/rulerz-bundle": "~0.10"
     },
     "require-dev": {
         "doctrine/doctrine-fixtures-bundle": "~2.2.0",
index 9a4397bade7f85022dba3dd6a5ed5a3d78567f1d..eea3f8a0dc0950ff06e042a57d08bd30c60488ee 100644 (file)
@@ -4,8 +4,8 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "hash": "9372aa161ce94f8b5506d7e9cc73a884",
-    "content-hash": "e703c21d623d708ff9528c298d7ab05f",
+    "hash": "fed9468f6c830b0f81899daad7670af7",
+    "content-hash": "394f8a6ca5162f2d2756dbbee0ff5aae",
     "packages": [
         {
             "name": "doctrine/annotations",
         },
         {
             "name": "kphoen/rulerz-bundle",
-            "version": "0.9.1",
+            "version": "0.11.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/K-Phoen/RulerZBundle.git",
-                "reference": "0d8d6ca57ebf2c914c967bc13cdf13c5ebb2de62"
+                "reference": "dcaaed69d8252fa1e3a25802f8cf697947570778"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/K-Phoen/RulerZBundle/zipball/0d8d6ca57ebf2c914c967bc13cdf13c5ebb2de62",
-                "reference": "0d8d6ca57ebf2c914c967bc13cdf13c5ebb2de62",
+                "url": "https://api.github.com/repos/K-Phoen/RulerZBundle/zipball/dcaaed69d8252fa1e3a25802f8cf697947570778",
+                "reference": "dcaaed69d8252fa1e3a25802f8cf697947570778",
                 "shasum": ""
             },
             "require": {
                 "kphoen/rulerz": "~0.1, >=0.13.0",
-                "symfony/framework-bundle": "~2.3",
-                "symfony/validator": "~2.3"
+                "symfony/framework-bundle": "~2.3|~3.0",
+                "symfony/validator": "~2.3|~3.0"
             },
             "require-dev": {
                 "matthiasnoback/symfony-dependency-injection-test": "~0.7",
                 "rulerz",
                 "specification"
             ],
-            "time": "2015-11-11 15:37:07"
+            "time": "2015-11-13 13:00:14"
         },
         {
             "name": "kriswallsmith/assetic",
index 851af932937f7419510866c8bb6a46baecdfc296..4eab590fd98846632c8e0bdd893d8c0d5d62d07e 100644 (file)
@@ -30,7 +30,7 @@ class TaggingRule
      * @Assert\NotBlank()
      * @RulerZAssert\ValidRule(
      *  allowed_variables={"title", "url", "isArchived", "isStared", "content", "language", "mimetype", "readingTime", "domainName"},
-     *  allowed_operators={">", "<", ">=", "<=", "=", "is", "!=", "and", "not", "or"}
+     *  allowed_operators={">", "<", ">=", "<=", "=", "is", "!=", "and", "not", "or", "matches"}
      * )
      * @ORM\Column(name="rule", type="string", nullable=false)
      */
diff --git a/src/Wallabag/CoreBundle/Operator/Doctrine/Matches.php b/src/Wallabag/CoreBundle/Operator/Doctrine/Matches.php
new file mode 100644 (file)
index 0000000..dc47c98
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+
+namespace Wallabag\CoreBundle\Operator\Doctrine;
+
+class Matches
+{
+    public function __invoke($subject, $pattern)
+    {
+        if ($pattern[0] === "'") {
+            $pattern = sprintf("'%%%s%%'", substr($pattern, 1, -1));
+        }
+
+        return sprintf('UPPER(%s) LIKE UPPER(%s)', $subject, $pattern);
+    }
+}
diff --git a/src/Wallabag/CoreBundle/Operator/PHP/Matches.php b/src/Wallabag/CoreBundle/Operator/PHP/Matches.php
new file mode 100644 (file)
index 0000000..4768900
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+
+namespace Wallabag\CoreBundle\Operator\PHP;
+
+class Matches
+{
+    public function __invoke($subject, $pattern)
+    {
+        return stripos($subject, $pattern) !== false;
+    }
+}
index 03d335609ca740259cd323fcdc3b2204444c5868..c92b4eb37c843d49ca5ec12b1b68d08dffd7cfc4 100644 (file)
@@ -91,3 +91,13 @@ services:
         arguments:
             - %wallabag_url%
             - src/Wallabag/CoreBundle/Resources/views/themes/_global/public/img/appicon/apple-touch-icon-152.png
+
+    wallabag.operator.array.matches:
+        class: Wallabag\CoreBundle\Operator\PHP\Matches
+        tags:
+            - { name: rulerz.operator, executor: rulerz.executor.array, operator: matches }
+
+    wallabag.operator.doctrine.matches:
+        class: Wallabag\CoreBundle\Operator\Doctrine\Matches
+        tags:
+            - { name: rulerz.operator, executor: rulerz.executor.doctrine, operator: matches, inline: true }