]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Entity/Entry.php
Use lang attribute
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / Entry.php
index 4acec2618eb5f3e457d55f7bbc67f3b6eb144cc3..190457983f92eb9d5bc77a25c24b08646ddb918f 100644 (file)
@@ -550,8 +550,6 @@ class Entry
      * Set created_at.
      * Only used when importing data from an other service.
      *
-     * @param \DateTime $createdAt
-     *
      * @return Entry
      */
     public function setCreatedAt(\DateTime $createdAt)
@@ -623,9 +621,6 @@ class Entry
         return $this->annotations;
     }
 
-    /**
-     * @param Annotation $annotation
-     */
     public function setAnnotation(Annotation $annotation)
     {
         $this->annotations[] = $annotation;
@@ -702,9 +697,6 @@ class Entry
         return $data;
     }
 
-    /**
-     * @param Tag $tag
-     */
     public function addTag(Tag $tag)
     {
         if ($this->tags->contains($tag)) {
@@ -725,8 +717,6 @@ class Entry
 
     /**
      * Remove the given tag from the entry (if the tag is associated).
-     *
-     * @param Tag $tag
      */
     public function removeTag(Tag $tag)
     {
@@ -797,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
      */
@@ -874,8 +877,6 @@ class Entry
     }
 
     /**
-     * @param \Datetime $publishedAt
-     *
      * @return Entry
      */
     public function setPublishedAt(\Datetime $publishedAt)