Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / pholio / controller / PholioImageUploadController.php
blob0ff5e061f55b5aa892d0c0be3b2a2148ec570213
1 <?php
3 final class PholioImageUploadController extends PholioController {
5 public function handleRequest(AphrontRequest $request) {
6 $viewer = $request->getViewer();
8 $phid = $request->getStr('filePHID');
9 $replaces_phid = $request->getStr('replacesPHID');
10 $title = $request->getStr('title');
11 $description = $request->getStr('description');
13 $file = id(new PhabricatorFileQuery())
14 ->setViewer($viewer)
15 ->withPHIDs(array($phid))
16 ->executeOne();
17 if (!$file) {
18 return new Aphront404Response();
21 if (!strlen($title)) {
22 $title = $file->getName();
25 $image = PholioImage::initializeNewImage()
26 ->setAuthorPHID($viewer->getPHID())
27 ->attachFile($file)
28 ->setName($title)
29 ->setDescription($description)
30 ->makeEphemeral();
32 $view = id(new PholioUploadedImageView())
33 ->setUser($viewer)
34 ->setImage($image)
35 ->setReplacesPHID($replaces_phid);
37 $content = array(
38 'markup' => $view,
41 return id(new AphrontAjaxResponse())->setContent($content);