REFACTORING: another ugly commit full of refactored code
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Admin\Contents;
|
||||
|
||||
use App\CMS\Contracts\Repositories\Content as IContent;
|
||||
use App\CMS\Contracts\Repositories\Module as IModuleRepository;
|
||||
use App\CMS\Contracts\Repositories\Template as ITemplate;
|
||||
use App\CMS\Enumerations\ContentStatuses;
|
||||
use App\Cms\Handlers\Interactions\Interaction;
|
||||
use App\CMS\Helpers\CurrentTemplate;
|
||||
@@ -12,16 +15,9 @@ use App\Http\Requests\Request;
|
||||
use App\Models\Content\Content;
|
||||
use App\Models\Content\ContentHistory;
|
||||
use App\Models\FileManager\File;
|
||||
use App\Models\Module;
|
||||
use App\Models\Templates\Template;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Modules\Categories\Entities\Category;
|
||||
use Pingpong\Modules\Facades\Module as ModuleInstance;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use App\CMS\Contracts\Repositories\Content as IContent;
|
||||
use App\CMS\Contracts\Repositories\Module as IModuleRepository;
|
||||
use App\CMS\Contracts\Repositories\Template as ITemplate;
|
||||
use Modules\Categories\Contracts\Repositories\Category as ICategory;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class EditContent extends Controller
|
||||
{
|
||||
@@ -85,15 +81,12 @@ class EditContent extends Controller
|
||||
$page = $this->content->getOne($url);
|
||||
|
||||
// get module ID
|
||||
$module = Module::where('handler', $page->module_handler)
|
||||
->firstOrFail();
|
||||
|
||||
$pageHeading = $this->module->getUpdateContentTitle($module);
|
||||
$module = $this->module->getByHandler($page->module_handler);
|
||||
$pageHeading = $this->module->getUpdateContentTitle($module, $page);
|
||||
$templates = $this->template->getForModule($module);
|
||||
$categories = $this->category->getForModule($module);
|
||||
$history = $this->history->getStructuredHistoryOf($page);
|
||||
|
||||
|
||||
// modify data for edit form according to installed template
|
||||
call_user_func_array([CurrentTemplate::handler(), 'beforePopulatingEditForm'], [&$page]);
|
||||
|
||||
@@ -106,8 +99,8 @@ class EditContent extends Controller
|
||||
'categories' => $categories,
|
||||
'rootPages' => $this->content->getOverview(),
|
||||
'templates' => $templates,
|
||||
'formSectionNames' => call_user_func([$page->module_handler, 'getExtendedFormSections']),
|
||||
'formSections' => call_user_func([$page->module_handler, 'getExtendedFormInputsEdit']),
|
||||
'formSectionNames' => $this->module->call($module, 'getExtendedFormSections'),
|
||||
'formSections' => $this->module->call($module, 'getExtendedFormInputsEdit'),
|
||||
'historySize' => count($history['changesets'])
|
||||
]);
|
||||
}
|
||||
@@ -126,7 +119,7 @@ class EditContent extends Controller
|
||||
/**
|
||||
* @var $page Content
|
||||
*/
|
||||
$page = Content::findOrFail($id);
|
||||
$page = $this->content->getOne($id);
|
||||
} catch (NotFoundHttpException $e) {
|
||||
|
||||
// log attempt of invalid edit
|
||||
|
||||
@@ -43,7 +43,6 @@ class History extends Controller
|
||||
|
||||
return view('admin/history.diff', [
|
||||
'change' => $change,
|
||||
'columnName' => 'Page content',
|
||||
'diff' => $diff
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Http\Controllers\Visitor;
|
||||
|
||||
use App\Models\Content\Content as ContentModel;
|
||||
use App\CMS\Contracts\Repositories\Content;
|
||||
use App\CMS\Helpers\PageRenderer;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Content\Content;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ContentPage extends Controller
|
||||
@@ -43,11 +44,10 @@ class ContentPage extends Controller
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function renderPage(Content $page)
|
||||
protected function renderPage(ContentModel $page)
|
||||
{
|
||||
// test if loaded page is visible or not
|
||||
if ($page->status == Content::STATUS_PROTECTED && !Auth::user()) {
|
||||
// throw new \Exception('Cannot access protected resources');
|
||||
if ($page->isProtected() && !Auth::user()) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Http\Controllers\Visitor;
|
||||
|
||||
use App\Http\Requests;
|
||||
|
||||
class Homepage extends ContentPage
|
||||
{
|
||||
public function getIndex()
|
||||
@@ -17,10 +15,6 @@ class Homepage extends ContentPage
|
||||
}
|
||||
|
||||
// render page
|
||||
// try {
|
||||
return $this->renderPage($page);
|
||||
// } catch (\Exception $e) {
|
||||
// return view('errors.homepageNotAvailable', ['exception' => $e, 'reason' => 'exception']);
|
||||
// }
|
||||
return $this->renderPage($page);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user