FEATURE #2354 @2h30m: add pipeline for edit and create new content
This commit is contained in:
@@ -37,32 +37,18 @@ class EditContent implements Interaction
|
||||
* @param array $data
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return mixed|void
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($data, $parameters)
|
||||
{
|
||||
/**
|
||||
* @var $page Content
|
||||
*/
|
||||
list($page, $titlePhoto, $relatedFiles) = $parameters;
|
||||
list($page) = $parameters;
|
||||
|
||||
// let template to modify request and content page
|
||||
CurrentTemplate::beforeSave($page, $data);
|
||||
app('saveContentPipeline')->run($page, $data);
|
||||
|
||||
// upload file - if provided
|
||||
$data['titlePhoto'] = isset($data['existingTitlePhoto']) ? $data['existingTitlePhoto'] : null;
|
||||
|
||||
if (!is_null($titlePhoto)) {
|
||||
$file = $this->file->upload($titlePhoto);
|
||||
$data['titlePhoto'] = $file ? $file['filename'] : null;
|
||||
}
|
||||
|
||||
$page->update($data);
|
||||
$this->module->callOnString($page->moduleHandler, 'edit', [$page, $data]);
|
||||
|
||||
// move to interaction
|
||||
$keepAssigned = isset($data['keepAssigned']) ? $data['keepAssigned'] : [];
|
||||
$page->uploadRelatedFiles($relatedFiles, $keepAssigned);
|
||||
return $page;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user