Airship\Cabin\Hull\Landing\BlogPosts::listByAuthor PHP Метод

listByAuthor() публичный Метод

List all of the blog posts for a given year
public listByAuthor ( string $slug, string $page = '' )
$slug string
$page string
    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);
    }