REFACTORING #1880 @4h30m: another ugly refactoring commit
This commit is contained in:
@@ -36,18 +36,17 @@ class ContentActions extends Controller
|
||||
->with('error', trans('admin/contents.invalidStatus'));
|
||||
}
|
||||
|
||||
try {
|
||||
// try to find this page
|
||||
$page = Content::findOrFail($id);
|
||||
} catch (NotFoundHttpException $e) {
|
||||
// page not found
|
||||
return redirect()
|
||||
->route('content.overview')
|
||||
->with('error', trans('admin/contents.invalidPage'));
|
||||
}
|
||||
|
||||
// try to change the page
|
||||
list ($revision, $changedColumns) = $page->updateWithHistory(['status' => 'status'], ['status' => $status]);
|
||||
// fire events
|
||||
if ($status != Content::STATUS_DRAFT) {
|
||||
Event::fire(new PublishContent($page, $revision));
|
||||
} else {
|
||||
Event::fire(new MakeDraftFromContent($page, $revision));
|
||||
}
|
||||
|
||||
// was something changed?
|
||||
if ($changedColumns == 0) {
|
||||
@@ -56,12 +55,7 @@ class ContentActions extends Controller
|
||||
->with('error', trans('admin/contents.nothingToEdit'));
|
||||
}
|
||||
|
||||
// fire events
|
||||
if ($status != Content::STATUS_DRAFT) {
|
||||
Event::fire(new PublishContent($page, $revision));
|
||||
} else {
|
||||
Event::fire(new MakeDraftFromContent($page, $revision));
|
||||
}
|
||||
|
||||
|
||||
// redirect back to overview with info for user
|
||||
return redirect()
|
||||
@@ -97,7 +91,7 @@ class ContentActions extends Controller
|
||||
$page->delete();
|
||||
|
||||
// let module to delete some extra content created during page's life
|
||||
call_user_func([$page->module_handler, 'delete'], $page);
|
||||
call_user_func([$page->moduleHandler, 'delete'], $page);
|
||||
|
||||
// trigger delete event
|
||||
Event::fire(new DeleteContent($page));
|
||||
@@ -134,12 +128,12 @@ class ContentActions extends Controller
|
||||
}
|
||||
|
||||
// disable any other existing homepage
|
||||
Content::where('is_homepage', 1)
|
||||
Content::where('isHomepage', 1)
|
||||
->where('language', LaravelLocalization::getCurrentLocale())
|
||||
->update(['is_homepage' => 0]);
|
||||
->update(['isHomepage' => 0]);
|
||||
|
||||
// set new homepage
|
||||
list ($revision, $changedColumns) = $page->updateWithHistory(['is_homepage' => 'is_homepage'], ['is_homepage' => 1]);
|
||||
list ($revision, $changedColumns) = $page->updateWithHistory(['isHomepage' => 'isHomepage'], ['isHomepage' => 1]);
|
||||
|
||||
// was something changed?
|
||||
if ($changedColumns == 0) {
|
||||
|
||||
Reference in New Issue
Block a user