]> BookStack Code Mirror - bookstack/blobdiff - app/Entity.php
Added custom meta titles to many pages. Closes #30.
[bookstack] / app / Entity.php
index 977b02e77c8aa06b5710877cde41a96b6b3fb37c..db244e01453b9fd7f6f85cfc6e73d952c3671d20 100644 (file)
@@ -97,18 +97,29 @@ abstract class Entity extends Model
      */
     public static function isA($type)
     {
-        return static::getName() === strtolower($type);
+        return static::getClassName() === strtolower($type);
     }
 
     /**
      * Gets the class name.
      * @return string
      */
-    public static function getName()
+    public static function getClassName()
     {
         return strtolower(array_slice(explode('\\', static::class), -1, 1)[0]);
     }
 
+    /**
+     *Gets a limited-length version of the entities name.
+     * @param int $length
+     * @return string
+     */
+    public function getShortName($length = 25)
+    {
+        if(strlen($this->name) <= $length) return $this->name;
+        return substr($this->name, 0, $length-3) . '...';
+    }
+
     /**
      * Perform a full-text search on this entity.
      * @param string[] $fieldsToSearch