Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/controller/PhrictionMoveController.php
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | if ($request->isFormPost()) { | ||||
$editor = id(new PhrictionTransactionEditor()) | $editor = id(new PhrictionTransactionEditor()) | ||||
->setActor($viewer) | ->setActor($viewer) | ||||
->setContentSourceFromRequest($request) | ->setContentSourceFromRequest($request) | ||||
->setContinueOnNoEffect(true) | ->setContinueOnNoEffect(true) | ||||
->setDescription($v_note); | ->setDescription($v_note); | ||||
$xactions = array(); | $xactions = array(); | ||||
$xactions[] = id(new PhrictionTransaction()) | $xactions[] = id(new PhrictionTransaction()) | ||||
->setTransactionType(PhrictionTransaction::TYPE_MOVE_TO) | ->setTransactionType( | ||||
PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE) | |||||
->setNewValue($document); | ->setNewValue($document); | ||||
$target_document = id(new PhrictionDocumentQuery()) | $target_document = id(new PhrictionDocumentQuery()) | ||||
->setViewer(PhabricatorUser::getOmnipotentUser()) | ->setViewer(PhabricatorUser::getOmnipotentUser()) | ||||
->withSlugs(array($normal_slug)) | ->withSlugs(array($normal_slug)) | ||||
->needContent(true) | ->needContent(true) | ||||
->requireCapabilities( | ->requireCapabilities( | ||||
array( | array( | ||||
PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
PhabricatorPolicyCapability::CAN_EDIT, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
)) | )) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$target_document) { | if (!$target_document) { | ||||
$target_document = PhrictionDocument::initializeNewDocument( | $target_document = PhrictionDocument::initializeNewDocument( | ||||
$viewer, | $viewer, | ||||
$v_slug); | $v_slug); | ||||
} | } | ||||
try { | try { | ||||
$editor->applyTransactions($target_document, $xactions); | $editor->applyTransactions($target_document, $xactions); | ||||
$redir_uri = PhrictionDocument::getSlugURI( | $redir_uri = PhrictionDocument::getSlugURI( | ||||
$target_document->getSlug()); | $target_document->getSlug()); | ||||
return id(new AphrontRedirectResponse())->setURI($redir_uri); | return id(new AphrontRedirectResponse())->setURI($redir_uri); | ||||
} catch (PhabricatorApplicationTransactionValidationException $ex) { | } catch (PhabricatorApplicationTransactionValidationException $ex) { | ||||
$validation_exception = $ex; | $validation_exception = $ex; | ||||
$e_slug = $ex->getShortMessage(PhrictionTransaction::TYPE_MOVE_TO); | $e_slug = $ex->getShortMessage( | ||||
PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE); | |||||
} | } | ||||
} | } | ||||
$form = id(new AphrontFormView()) | $form = id(new AphrontFormView()) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormStaticControl()) | id(new AphrontFormStaticControl()) | ||||
Show All 28 Lines |