Something went wrong. Try again.
@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
Something went wrong. Try again.
1.5 kB · 54 lines
PHP
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455<?php
final class PhabricatorProjectCoverController extends PhabricatorProjectController {
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer();
$request->validateCSRF();
$board_phid = $request->getStr('boardPHID'); $object_phid = $request->getStr('objectPHID'); $file_phid = $request->getStr('filePHID');
$object = id(new ManiphestTaskQuery()) ->setViewer($viewer) ->withPHIDs(array($object_phid)) ->requireCapabilities( array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, )) ->executeOne(); if (!$object) { return new Aphront404Response(); }
$file = id(new PhabricatorFileQuery()) ->setViewer($viewer) ->withPHIDs(array($file_phid)) ->executeOne(); if (!$file) { return new Aphront404Response(); }
$xactions = array();
// Set the new Cover Image. $xactions[] = id(new ManiphestTransaction()) ->setTransactionType(ManiphestTaskCoverImageTransaction::TRANSACTIONTYPE) ->setNewValue($file->getPHID());
$editor = id(new ManiphestTransactionEditor()) ->setActor($viewer) ->setContinueOnMissingFields(true) ->setContinueOnNoEffect(true) ->setContentSourceFromRequest($request);
$editor->applyTransactions($object, $xactions);
return $this->newCardResponse($board_phid, $object_phid); }
}