1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-30 04:23:11 +03:00

Added custom meta titles to many pages. Closes #30.

This commit is contained in:
Dan Brown
2015-12-05 14:41:51 +00:00
parent f1c2866fbc
commit c32d70abc4
13 changed files with 56 additions and 11 deletions

View 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