Airship\Cabin\Bridge\Landing\Blog::newPost PHP Method

newPost() public method

Create a new blog post
public newPost ( )
    public function newPost()
    {
        if (!$this->can('create')) {
            \Airship\redirect($this->airship_cabin_prefix . '/blog/post');
        }
        // Load Data
        if ($this->isSuperUser()) {
            $authors = $this->author->getAll();
        } else {
            $authors = $this->author->getForUser($this->getActiveUserId());
        }
        $categories = $this->blog->getCategoryTree();
        $tags = $this->blog->getTags();
        $post = $this->post(new NewPostFilter());
        if (!empty($post)) {
            $authorsAllowed = [];
            foreach ($authors as $a) {
                $authorsAllowed[] = (int) $a['authorid'];
            }
            if ($this->processNewPost($post, $authorsAllowed)) {
                \Airship\redirect($this->airship_cabin_prefix . '/blog/post');
            }
        }
        $this->lens('blog/posts_new', ['current_time' => (new \DateTime())->format(\AIRSHIP_DATE_FORMAT), 'active_link' => 'bridge-link-blog-posts', 'authors' => $authors, 'categories' => $categories, 'tags' => $tags]);
    }