Last active
January 23, 2017 22:58
-
-
Save Mulkave/ba30e6894cac7b5a5b01e6e167c17cbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CreateArticleFeature extends Feature | |
{ | |
public function handle(Request $request) | |
{ | |
$this->run(new ValidateArticleInputForCreationJob($request->input())); | |
// process cover photo | |
$photo = $this->run(MakePhotoFromDataJob::class, ['data' => $request->input('photo')]); | |
$this->run(new ValidateCoverPhotoDimensionsJob($photo)); | |
$variations = $this->run(new GeneratePhotoVariationsJob($photo)); | |
$uploads = $this->run(new UploadFilesToCdnJob($variations)); | |
$cover = $this->run(new MakeCoverFromVariationUploadsJob($uploads)); | |
$this->run(CleanFilesInDirectoryJob::class, [ | |
'files' => $variations, | |
'directory' => $this->run(GetImagesStorageLocationJob::class), | |
]); | |
// save article | |
$article = $this->run(CreateArticleJob::class, [ | |
'cover' => $cover, | |
'title' => $request->input('title'), | |
'body' => $request->input('body'), | |
]); | |
return $this->run(new RespondWithJsonJob($article)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment