Airship\Cabin\Bridge\Blueprint\Author::getSlug PHP Method

getSlug() public method

Get the slug for a given Author (given its ID)
public getSlug ( integer $authorId ) : string
$authorId integer
return string
    public function getSlug(int $authorId) : string
    {
        $slug = $this->db->cell('SELECT slug FROM hull_blog_authors WHERE authorid = ?', $authorId);
        if (!empty($slug)) {
            return $slug;
        }
        return '';
    }

Usage Example

Example #1
0
 /**
  * Loads all the necessary information for this author
  *
  * @param int $authorId
  */
 protected function loadAuthorInfo(int $authorId)
 {
     $this->authorId = $authorId;
     $this->authorName = $this->author->getName($authorId);
     $this->authorSlug = $this->author->getSlug($authorId);
     $this->storeLensVar('header', \__('Files for Author "%s"', 'default', Util::noHTML($this->authorName)));
     $this->storeLensVar('title', \__('Files for Author "%s"', 'default', Util::noHTML($this->authorName)));
     $this->root_dir = 'author/' . $this->authorSlug;
     $this->path_middle = 'author/files/' . $authorId;
     $this->storeLensVar('path_middle', $this->path_middle);
     $userId = $this->getActiveUserId();
     $this->attribution = ['author' => $authorId, 'uploaded_by' => $userId];
 }