createPost() public method

Create (and, optionally, publish) a new blog post.
public createPost ( array $post, boolean $publish = false ) : boolean
$post array
$publish boolean
return boolean
Ejemplo n.º 1
0
 /**
  * Create a new blog post
  *
  * @param array $post
  * @param array $authorsAllowed
  * @return bool
  */
 protected function processNewPost(array $post, array $authorsAllowed = []) : bool
 {
     $required = ['author', 'blog_post_body', 'format', 'save_btn', 'title'];
     if (!\Airship\all_keys_exist($required, $post)) {
         return false;
     }
     if (!\in_array($post['author'], $authorsAllowed)) {
         return false;
     }
     $publish = $this->can('publish') ? $post['save_btn'] === 'publish' : false;
     return $this->blog->createPost($post, $publish);
 }