updatePost() public méthode

Update a blog post
public updatePost ( array $post, array $old, boolean $publish = false ) : boolean
$post array
$old array
$publish boolean
Résultat boolean
Exemple #1
0
 /**
  * Update a blog post
  *
  * @param array $post
  * @param array $authorsAllowed
  * @param array $oldPost
  * @return bool
  */
 protected function processEditPost(array $post, array $authorsAllowed = [], array $oldPost = []) : bool
 {
     $required = ['author', 'blog_post_body', 'format', 'save_btn', 'title'];
     if (!\Airship\all_keys_exist($required, $post)) {
         return false;
     }
     if (!$this->isSuperUser()) {
         if (!empty($post['author'])) {
             // Only administrators can transfer ownership; block this request
             return false;
         }
         if (!\in_array((int) $oldPost['author'], $authorsAllowed)) {
             // This author is invalid.
             return false;
         }
     }
     $publish = $this->can('publish') ? $post['save_btn'] === 'publish' : false;
     return $this->blog->updatePost($post, $oldPost, $publish);
 }