]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Helper/ContentProxy.php
Also validate used variables when creating tagging rules
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Helper / ContentProxy.php
index 3de8828f98e1e5740a155d60532d45c875010836..dc6e1184cd34e08fc10797f20668879ed94e63f8 100644 (file)
@@ -4,6 +4,7 @@ namespace Wallabag\CoreBundle\Helper;
 
 use Graby\Graby;
 use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\CoreBundle\Tools\Utils;
 
 /**
  * This kind of proxy class take care of getting the content from an url
@@ -12,10 +13,12 @@ use Wallabag\CoreBundle\Entity\Entry;
 class ContentProxy
 {
     protected $graby;
+    protected $tagger;
 
-    public function __construct(Graby $graby)
+    public function __construct(Graby $graby, RuleBasedTagger $tagger)
     {
-        $this->graby = $graby;
+        $this->graby  = $graby;
+        $this->tagger = $tagger;
     }
 
     /**
@@ -51,11 +54,15 @@ class ContentProxy
         $entry->setContent($html);
         $entry->setLanguage($content['language']);
         $entry->setMimetype($content['content_type']);
+        $entry->setReadingTime(Utils::getReadingTime($html));
+        $entry->setDomainName(parse_url($entry->getUrl(), PHP_URL_HOST));
 
         if (isset($content['open_graph']['og_image'])) {
             $entry->setPreviewPicture($content['open_graph']['og_image']);
         }
 
+        $this->tagger->tag($entry);
+
         return $entry;
     }
 }