|
|
|
@ -133,9 +133,7 @@ class BlogPostManageService
|
|
|
|
|
|
|
|
|
|
$this->transaction->wrap(function () use ($post, $form) { |
|
|
|
|
$post->revokeTags(); |
|
|
|
|
//$post->doRevision(); |
|
|
|
|
$this->posts->save($post); |
|
|
|
|
//$post->stopRevision(); |
|
|
|
|
|
|
|
|
|
if (is_array($form->tags->new_tags) && !empty($form->tags->new_tags)) { |
|
|
|
|
foreach ( $form->tags->new_tags as $tag_id => $tag_name ) { |
|
|
|
@ -188,6 +186,16 @@ class BlogPostManageService
|
|
|
|
|
$post = $this->posts->get($id); |
|
|
|
|
$from = $this->posts->get($from_id); |
|
|
|
|
|
|
|
|
|
// get from tags |
|
|
|
|
$from_tags = $from->tags; |
|
|
|
|
$new_tags_names = array_map(function ($item){ |
|
|
|
|
return $item->name; |
|
|
|
|
}, $from_tags); |
|
|
|
|
|
|
|
|
|
// clear from tags |
|
|
|
|
$from->revokeTags(); |
|
|
|
|
$this->posts->save($from); |
|
|
|
|
|
|
|
|
|
// remove current revision |
|
|
|
|
$this->posts->remove($post); |
|
|
|
|
|
|
|
|
@ -201,8 +209,14 @@ class BlogPostManageService
|
|
|
|
|
$from->type = BlogPost::TYPE_PUBLIC; |
|
|
|
|
$from->revision_id = null; |
|
|
|
|
|
|
|
|
|
// restore revision to current |
|
|
|
|
$this->posts->save($from); |
|
|
|
|
foreach ($new_tags_names as $tag_name) { |
|
|
|
|
if ( ! $tag = $this->tags->findByName( $tag_name ) ) { |
|
|
|
|
$tag = BlogTag::create( $tag_name, Inflector::slug( $tag_name, '_' ) ); |
|
|
|
|
$this->tags->save( $tag ); |
|
|
|
|
} |
|
|
|
|
$from->assignTag( $tag->id ); |
|
|
|
|
} |
|
|
|
|
$this->posts->save($from); |
|
|
|
|
|
|
|
|
|
// delete never revisions |
|
|
|
|
BlogPost::deleteAll(['AND', ['revision_id' => $from->id], ['>', 'revision_at', $from->revision_at]]); |
|
|
|
|