FEATURE #2354 @2h30m: add pipeline for edit and create new content

This commit is contained in:
Michal Kváček
2017-03-10 09:52:12 +01:00
parent 55f9c0a679
commit 9bec808d38
32 changed files with 381 additions and 319 deletions
@@ -43,29 +43,14 @@ class NewContent implements Interaction
*/
public function handle($data, $parameters)
{
list($moduleHandler, $titlePhoto, $relatedFiles) = $parameters;
// upload file - if provided
$file = !is_null($titlePhoto) ? $this->file->upload($titlePhoto) : null;
list($moduleHandler) = $parameters;
$data['userId'] = \Auth::user()->id;
$data['language'] = LaravelLocalization::getCurrentLocale();
$data['titlePhoto'] = $file ? $file['filename'] : null;
$data['moduleHandler'] = $moduleHandler;
$page = Content::create($data);
// save module-specific stuff
$this->module->callOnString($moduleHandler, 'createNew', [&$page, $data]);
// let template to modify data and content page
CurrentTemplate::beforeSave($page, $data);
// save content of page before (possible) uploading related files
$page->save();
// upload files assigned to content page
$page->uploadRelatedFiles($relatedFiles);
$page = new Content();
app('saveContentPipeline')->run($page, $data);
return $page;
}