]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Helper/ContentProxy.php
Move readingTime & domainName in ContentProxy
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Helper / ContentProxy.php
index 2dd70e51db50464732c1dbda235dc93b7c442282..7fb41393127c8bcdaab1a11511a988e93bb6cb16 100644 (file)
@@ -4,10 +4,11 @@ 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
- * and update the entry with what it found
+ * and update the entry with what it found.
  */
 class ContentProxy
 {
@@ -20,10 +21,10 @@ class ContentProxy
 
     /**
      * Fetch content using graby and hydrate given entry with results information.
-     * In case we couldn't find content, we'll try to use Open Graph data
+     * In case we couldn't find content, we'll try to use Open Graph data.
      *
-     * @param  Entry  $entry Entry to update
-     * @param  string $url   Url to grab content for
+     * @param Entry  $entry Entry to update
+     * @param string $url   Url to grab content for
      *
      * @return Entry
      */
@@ -49,7 +50,10 @@ class ContentProxy
         $entry->setUrl($content['url'] ?: $url);
         $entry->setTitle($title);
         $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']);