aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Helper
diff options
context:
space:
mode:
authorKévin Gomez <contact@kevingomez.fr>2015-10-11 17:14:50 +0200
committerKévin Gomez <contact@kevingomez.fr>2015-11-11 16:23:49 +0100
commitac9fec610a6485b39c856d9cb7d263ce8c5f1223 (patch)
treeef822c68bd263c6a1b99da8bc5edcfe1668c1ea3 /src/Wallabag/CoreBundle/Helper
parentc3510620ad0718d2ab1f856e3a838360a5ade314 (diff)
downloadwallabag-ac9fec610a6485b39c856d9cb7d263ce8c5f1223.tar.gz
wallabag-ac9fec610a6485b39c856d9cb7d263ce8c5f1223.tar.zst
wallabag-ac9fec610a6485b39c856d9cb7d263ce8c5f1223.zip
Add TaggingRule entity
Diffstat (limited to 'src/Wallabag/CoreBundle/Helper')
-rw-r--r--src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
index 012450b6..bb933779 100644
--- a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
+++ b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
@@ -30,11 +30,11 @@ class RuleBasedTagger
30 $rules = $this->getRulesForUser($entry->getUser()); 30 $rules = $this->getRulesForUser($entry->getUser());
31 31
32 foreach ($rules as $rule) { 32 foreach ($rules as $rule) {
33 if (!$this->rulerz->satisfies($entry, $rule['rule'])) { 33 if (!$this->rulerz->satisfies($entry, $rule->getRule())) {
34 continue; 34 continue;
35 } 35 }
36 36
37 foreach ($rule['tags'] as $label) { 37 foreach ($rule->getTags() as $label) {
38 $tag = $this->getTag($entry->getUser(), $label); 38 $tag = $this->getTag($entry->getUser(), $label);
39 39
40 $entry->addTag($tag); 40 $entry->addTag($tag);
@@ -62,21 +62,15 @@ class RuleBasedTagger
62 return $tag; 62 return $tag;
63 } 63 }
64 64
65 /**
66 * Retrieves the tagging rules for a given user.
67 *
68 * @param User $user
69 *
70 * @return array<TaggingRule>
71 */
65 private function getRulesForUser(User $user) 72 private function getRulesForUser(User $user)
66 { 73 {
67 return [ 74 return $user->getConfig()->getTaggingRules();
68 [
69 'rule' => 'domainName = "github.com"',
70 'tags' => ['github'],
71 ],
72 [
73 'rule' => 'readingTime >= 15',
74 'tags' => ['long reading'],
75 ],
76 [
77 'rule' => 'readingTime <= 3 ',
78 'tags' => ['short reading'],
79 ],
80 ];
81 } 75 }
82} 76}