|
|
@ -133,9 +133,7 @@ class BlogPostManageService |
|
|
|
|
|
|
|
|
|
|
|
$this->transaction->wrap(function () use ($post, $form) { |
|
|
|
$this->transaction->wrap(function () use ($post, $form) { |
|
|
|
$post->revokeTags(); |
|
|
|
$post->revokeTags(); |
|
|
|
//$post->doRevision(); |
|
|
|
|
|
|
|
$this->posts->save($post); |
|
|
|
$this->posts->save($post); |
|
|
|
//$post->stopRevision(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (is_array($form->tags->new_tags) && !empty($form->tags->new_tags)) { |
|
|
|
if (is_array($form->tags->new_tags) && !empty($form->tags->new_tags)) { |
|
|
|
foreach ( $form->tags->new_tags as $tag_id => $tag_name ) { |
|
|
|
foreach ( $form->tags->new_tags as $tag_id => $tag_name ) { |
|
|
@ -188,6 +186,16 @@ class BlogPostManageService |
|
|
|
$post = $this->posts->get($id); |
|
|
|
$post = $this->posts->get($id); |
|
|
|
$from = $this->posts->get($from_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 |
|
|
|
// remove current revision |
|
|
|
$this->posts->remove($post); |
|
|
|
$this->posts->remove($post); |
|
|
|
|
|
|
|
|
|
|
@ -201,7 +209,13 @@ class BlogPostManageService |
|
|
|
$from->type = BlogPost::TYPE_PUBLIC; |
|
|
|
$from->type = BlogPost::TYPE_PUBLIC; |
|
|
|
$from->revision_id = null; |
|
|
|
$from->revision_id = null; |
|
|
|
|
|
|
|
|
|
|
|
// restore revision to current |
|
|
|
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); |
|
|
|
$this->posts->save($from); |
|
|
|
|
|
|
|
|
|
|
|
// delete never revisions |
|
|
|
// delete never revisions |
|
|
|