]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Entity/Entry.php
Fix createdAt date range filter
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / Entry.php
index beda581af2ee214abb96c11a6fd48eb6af30908b..0e19a0c20afb25e7ed86e0fdd480a934d6ba4761 100644 (file)
@@ -552,7 +552,7 @@ class Entry
      *
      * @return Entry
      */
-    public function setCreatedAt(\DateTime $createdAt)
+    public function setCreatedAt(\DateTimeInterface $createdAt)
     {
         $this->createdAt = $createdAt;
 
@@ -787,6 +787,19 @@ class Entry
         return $this->language;
     }
 
+    /**
+     * Format the entry language to a valid html lang attribute.
+     */
+    public function getHTMLLanguage()
+    {
+        $parsedLocale = \Locale::parseLocale($this->getLanguage());
+        $lang = '';
+        $lang .= $parsedLocale['language'] ?? '';
+        $lang .= isset($parsedLocale['region']) ? '-' . $parsedLocale['region'] : '';
+
+        return $lang;
+    }
+
     /**
      * @return string|null
      */