29 lines
774 B
PHP
Executable File
29 lines
774 B
PHP
Executable File
<?php
|
|
namespace Modules\Blog\Article\Pipeline\SaveContent;
|
|
|
|
use App\CMS\Contracts\Content\SavePipeline\Process;
|
|
use App\Models\Content\Content;
|
|
use Modules\Blog\Article\Handlers\Article;
|
|
|
|
class TurnCommentsOnOrOff implements Process
|
|
{
|
|
/**
|
|
* Process and modify given page
|
|
*
|
|
* @param Content $content
|
|
* @param array $input
|
|
*
|
|
* @return void
|
|
*/
|
|
function handle(Content & $content, array & $input)
|
|
{
|
|
if (trim($content->moduleHandler, '\\') !== Article::class) {
|
|
return;
|
|
}
|
|
|
|
$settings = $content->moduleSettings;
|
|
$settings['allowComments'] = isset($input['allowComments']) ? (int)$input['allowComments'] : 0;
|
|
$content->moduleSettings = $settings;
|
|
$content->save();
|
|
}
|
|
} |