本文整理汇总了PHP中PhabricatorDraft::buildFromRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorDraft::buildFromRequest方法的具体用法?PHP PhabricatorDraft::buildFromRequest怎么用?PHP PhabricatorDraft::buildFromRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhabricatorDraft
的用法示例。
在下文中一共展示了PhabricatorDraft::buildFromRequest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
if (!$request->isFormPost()) {
return new Aphront400Response();
}
$paste = id(new PhabricatorPasteQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
if (!$paste) {
return new Aphront404Response();
}
$is_preview = $request->isPreviewRequest();
$draft = PhabricatorDraft::buildFromRequest($request);
$view_uri = $paste->getURI();
$xactions = array();
$xactions[] = id(new PhabricatorPasteTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new PhabricatorPasteTransactionComment())->setContent($request->getStr('comment')));
$editor = id(new PhabricatorPasteEditor())->setActor($viewer)->setContinueOnNoEffect($request->isContinueRequest())->setContentSourceFromRequest($request)->setIsPreview($is_preview);
try {
$xactions = $editor->applyTransactions($paste, $xactions);
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
return id(new PhabricatorApplicationTransactionNoEffectResponse())->setCancelURI($view_uri)->setException($ex);
}
if ($draft) {
$draft->replaceOrDelete();
}
if ($request->isAjax() && $is_preview) {
return id(new PhabricatorApplicationTransactionResponse())->setViewer($viewer)->setTransactions($xactions)->setIsPreview($is_preview);
} else {
return id(new AphrontRedirectResponse())->setURI($view_uri);
}
}
示例2: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
if (!$request->isFormPost()) {
return new Aphront400Response();
}
$document = id(new LegalpadDocumentQuery())->setViewer($viewer)->withIDs(array($id))->needDocumentBodies(true)->executeOne();
if (!$document) {
return new Aphront404Response();
}
$is_preview = $request->isPreviewRequest();
$draft = PhabricatorDraft::buildFromRequest($request);
$document_uri = $this->getApplicationURI('view/' . $document->getID());
$comment = $request->getStr('comment');
$xactions = array();
if (strlen($comment)) {
$xactions[] = id(new LegalpadTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new LegalpadTransactionComment())->setDocumentID($document->getID())->setLineNumber(0)->setLineLength(0)->setContent($comment));
}
$editor = id(new LegalpadDocumentEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect($request->isContinueRequest())->setIsPreview($is_preview);
try {
$xactions = $editor->applyTransactions($document, $xactions);
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
return id(new PhabricatorApplicationTransactionNoEffectResponse())->setCancelURI($document_uri)->setException($ex);
}
if ($draft) {
$draft->replaceOrDelete();
}
if ($request->isAjax() && $is_preview) {
return id(new PhabricatorApplicationTransactionResponse())->setViewer($viewer)->setTransactions($xactions)->setIsPreview($is_preview);
} else {
return id(new AphrontRedirectResponse())->setURI($document_uri);
}
}
示例3: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
if (!$request->isFormPost()) {
return new Aphront400Response();
}
$poll = id(new PhabricatorSlowvoteQuery())->setViewer($user)->withIDs(array($this->id))->executeOne();
if (!$poll) {
return new Aphront404Response();
}
$is_preview = $request->isPreviewRequest();
$draft = PhabricatorDraft::buildFromRequest($request);
$view_uri = '/V' . $poll->getID();
$xactions = array();
$xactions[] = id(new PhabricatorSlowvoteTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new PhabricatorSlowvoteTransactionComment())->setContent($request->getStr('comment')));
$editor = id(new PhabricatorSlowvoteEditor())->setActor($user)->setContinueOnNoEffect($request->isContinueRequest())->setContentSourceFromRequest($request)->setIsPreview($is_preview);
try {
$xactions = $editor->applyTransactions($poll, $xactions);
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
return id(new PhabricatorApplicationTransactionNoEffectResponse())->setCancelURI($view_uri)->setException($ex);
}
if ($draft) {
$draft->replaceOrDelete();
}
if ($request->isAjax() && $is_preview) {
return id(new PhabricatorApplicationTransactionResponse())->setViewer($user)->setTransactions($xactions)->setIsPreview($is_preview)->setAnchorOffset($request->getStr('anchor'));
} else {
return id(new AphrontRedirectResponse())->setURI($view_uri);
}
}
示例4: handleRequest
public function handleRequest(AphrontRequest $request)
{
if (!$request->isFormPost()) {
return new Aphront400Response();
}
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$is_preview = $request->isPreviewRequest();
$draft = PhabricatorDraft::buildFromRequest($request);
$event = id(new PhabricatorCalendarEventQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
if (!$event) {
return new Aphront404Response();
}
$index = $request->getURIData('sequence');
if ($index && !$is_preview) {
$result = $this->getEventAtIndexForGhostPHID($viewer, $event->getPHID(), $index);
if ($result) {
$event = $result;
} else {
$event = $this->createEventFromGhost($viewer, $event, $index);
$event->applyViewerTimezone($viewer);
}
}
$view_uri = '/' . $event->getMonogram();
$xactions = array();
$xactions[] = id(new PhabricatorCalendarEventTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new PhabricatorCalendarEventTransactionComment())->setContent($request->getStr('comment')));
$editor = id(new PhabricatorCalendarEventEditor())->setActor($viewer)->setContinueOnNoEffect($request->isContinueRequest())->setContentSourceFromRequest($request)->setIsPreview($is_preview);
try {
$xactions = $editor->applyTransactions($event, $xactions);
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
return id(new PhabricatorApplicationTransactionNoEffectResponse())->setCancelURI($view_uri)->setException($ex);
}
if ($draft) {
$draft->replaceOrDelete();
}
if ($request->isAjax() && $is_preview) {
return id(new PhabricatorApplicationTransactionResponse())->setViewer($viewer)->setTransactions($xactions)->setIsPreview($is_preview);
} else {
return id(new AphrontRedirectResponse())->setURI($view_uri);
}
}
示例5: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
if (!$request->isFormPost()) {
return new Aphront400Response();
}
$mock = id(new PholioMockQuery())->setViewer($viewer)->withIDs(array($id))->needImages(true)->executeOne();
if (!$mock) {
return new Aphront404Response();
}
$is_preview = $request->isPreviewRequest();
$draft = PhabricatorDraft::buildFromRequest($request);
$mock_uri = '/M' . $mock->getID();
$comment = $request->getStr('comment');
$xactions = array();
$inline_comments = id(new PholioTransactionComment())->loadAllWhere('authorphid = %s AND transactionphid IS NULL AND imageid IN (%Ld)', $viewer->getPHID(), mpull($mock->getImages(), 'getID'));
if (!$inline_comments || strlen($comment)) {
$xactions[] = id(new PholioTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new PholioTransactionComment())->setContent($comment));
}
foreach ($inline_comments as $inline_comment) {
$xactions[] = id(new PholioTransaction())->setTransactionType(PholioTransaction::TYPE_INLINE)->attachComment($inline_comment);
}
$editor = id(new PholioMockEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect($request->isContinueRequest())->setIsPreview($is_preview);
try {
$xactions = $editor->applyTransactions($mock, $xactions);
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
return id(new PhabricatorApplicationTransactionNoEffectResponse())->setCancelURI($mock_uri)->setException($ex);
}
if ($draft) {
$draft->replaceOrDelete();
}
if ($request->isAjax() && $is_preview) {
$xaction_view = id(new PholioTransactionView())->setMock($mock);
return id(new PhabricatorApplicationTransactionResponse())->setViewer($viewer)->setTransactions($xactions)->setTransactionView($xaction_view)->setIsPreview($is_preview);
} else {
return id(new AphrontRedirectResponse())->setURI($mock_uri);
}
}