mirror of
https://github.com/wallabag/wallabag.git
synced 2025-07-22 17:18:37 +00:00
Add matches operator
This commit is contained in:
parent
5c514b0be3
commit
a6e27f7466
6 changed files with 47 additions and 11 deletions
|
@ -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)
|
||||
*/
|
||||
|
|
15
src/Wallabag/CoreBundle/Operator/Doctrine/Matches.php
Normal file
15
src/Wallabag/CoreBundle/Operator/Doctrine/Matches.php
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
11
src/Wallabag/CoreBundle/Operator/PHP/Matches.php
Normal file
11
src/Wallabag/CoreBundle/Operator/PHP/Matches.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Operator\PHP;
|
||||
|
||||
class Matches
|
||||
{
|
||||
public function __invoke($subject, $pattern)
|
||||
{
|
||||
return stripos($subject, $pattern) !== false;
|
||||
}
|
||||
}
|
|
@ -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 }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue