getAuthorBySlug() public method

Return information about the current category
public getAuthorBySlug ( string $authorSlug ) : array
$authorSlug string
return array
Esempio n. 1
0
 /**
  * List all of the blog posts for a given year
  *
  * @route blog/author/{slug}/{page}
  * @param string $slug
  * @param string $page
  * @throws EmulatePageNotFound
  */
 public function listByAuthor(string $slug, string $page = '')
 {
     if (!$this->can('read')) {
         throw new EmulatePageNotFound();
     }
     list($offset, $limit) = $this->getOffsetAndLimit($page);
     $author = $this->blog->getAuthorBySlug($slug);
     if (empty($author)) {
         throw new EmulatePageNotFound();
     }
     $count = $this->blog->countByAuthor((int) $author['authorid']);
     $blogRoll = $this->blog->listByAuthor((int) $author['authorid'], $limit, $offset);
     $mathJAX = false;
     foreach ($blogRoll as $i => $blog) {
         $blogRoll[$i] = $this->blog->getSnippet($blog);
         if (Binary::safeStrlen($blogRoll[$i]['snippet']) !== Binary::safeStrlen($blog['body'])) {
             $blogRoll[$i]['snippet'] = \rtrim($blogRoll[$i]['snippet'], "\n");
         }
         $mathJAX = $mathJAX || \strpos($blog['body'], '$$') !== false;
     }
     $args = ['author' => $author, 'blogroll' => $blogRoll, 'mathjax' => $mathJAX, 'pagination' => ['base' => \Airship\LensFunctions\cabin_url() . 'blog/author/' . $slug, 'count' => $count, 'page' => (int) \ceil($offset / ($limit ?? 1)) + 1, 'per_page' => $limit]];
     $this->config('blog.cachelists') ? $this->stasis('blog/author', $args) : $this->lens('blog/author', $args);
 }