REFACTORING #1880 @4h30m: another ugly refactoring commit

This commit is contained in:
Michal Kváček
2016-10-25 16:50:04 +02:00
parent 28f67ffe3c
commit cc999dd24e
71 changed files with 827 additions and 608 deletions
+10 -18
View File
@@ -5,7 +5,6 @@ use App\CMS\Contracts\Content\AdvancedContentModifier;
use App\CMS\Contracts\Content\ContentTitles;
use App\CMS\Contracts\Modules\InstallableModule;
use App\CMS\Handlers\Handler;
use App\Http\Controllers\Admin\Contents\EditContent;
use App\Http\Controllers\Controller;
use App\Http\Requests\Request;
use App\Models\ActionLog\ActionLogType;
@@ -27,7 +26,7 @@ class Article extends Handler implements ContentTitles, AdvancedContentModifier,
public function render(Content $content, $parameters)
{
$content->comments = [];
if (isset($content->module_settings->allowComments) && $content->module_settings->allowComments) {
if (isset($content->moduleSettings->allowComments) && $content->moduleSettings->allowComments) {
$content->comments = Comment::where('content_id', $content->id)
->with('author')
->where('approved', 1)
@@ -62,7 +61,7 @@ class Article extends Handler implements ContentTitles, AdvancedContentModifier,
*/
public static function createNew(Content &$content, Request $request)
{
$content->module_settings = json_encode(['allowComments' => (int)$request->has('allowComments')]);
$content->moduleSettings = ['allowComments' => (int)$request->has('allowComments')];
}
/**
@@ -73,23 +72,18 @@ class Article extends Handler implements ContentTitles, AdvancedContentModifier,
* @param Content $content
* @param Request $request
*
* @param $revisionID string ID of revision used
*
* @return int number of edited fields
* @return void
*/
public static function edit(Content &$content, Request $request, $revisionID)
public static function edit(Content $content, $request)
{
$fields = ['allowComments' => 'allowComments'];
$settings = $content->moduleSettings;
if (!is_object($settings))
$settings = new \stdClass();
// get data and try to save them
$data = EditContent::getFields($request, $fields);
$settings->allowComments = isset($request['allowComments']) ? (int)$request['allowComments'] : 0;
$data['allowComments'] = (int)$data['allowComments'];
list($revision, $changedColumns) = $content->updateWithHistory($fields, $data, $revisionID);
// return amount of changed columns
return $changedColumns;
$content->moduleSettings = $settings;
$content->save();
}
/**
@@ -99,8 +93,6 @@ class Article extends Handler implements ContentTitles, AdvancedContentModifier,
*/
public static function registerAdminMenu(User $user)
{
parent::registerAdminMenu($user);
$menu = \Menu::instance('mainMenu');
$blogSubmenu = $menu->whereTitle(trans('article::module.blog'));