本文整理汇总了PHP中PhabricatorContentSource类的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorContentSource类的具体用法?PHP PhabricatorContentSource怎么用?PHP PhabricatorContentSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PhabricatorContentSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHeraldFieldValueType
public function getHeraldFieldValueType($condition)
{
$map = PhabricatorContentSource::getAllContentSources();
$map = mpull($map, 'getSourceName');
asort($map);
return id(new HeraldSelectFieldValue())->setKey(self::FIELDCONST)->setDefault(PhabricatorWebContentSource::SOURCECONST)->setOptions($map);
}
示例2: execute
protected function execute(ConduitAPIRequest $request)
{
$viewer = $request->getUser();
$raw_diff = $request->getValue('diff');
$repository_phid = $request->getValue('repositoryPHID');
if ($repository_phid) {
$repository = id(new PhabricatorRepositoryQuery())->setViewer($viewer)->withPHIDs(array($repository_phid))->executeOne();
if (!$repository) {
throw new Exception(pht('No such repository "%s"!', $repository_phid));
}
} else {
$repository = null;
}
$parser = new ArcanistDiffParser();
$changes = $parser->parseDiff($raw_diff);
$diff = DifferentialDiff::newFromRawChanges($changes);
$diff->setLintStatus(DifferentialLintStatus::LINT_SKIP);
$diff->setUnitStatus(DifferentialUnitStatus::UNIT_SKIP);
$diff->setAuthorPHID($viewer->getPHID());
$diff->setCreationMethod('web');
if ($repository) {
$diff->setRepositoryPHID($repository->getPHID());
}
id(new DifferentialDiffEditor())->setActor($viewer)->setContentSource(PhabricatorContentSource::newFromConduitRequest($request))->saveDiff($diff);
return $this->buildDiffInfoDictionary($diff);
}
示例3: processReceivedMail
protected function processReceivedMail(PhabricatorMetaMTAReceivedMail $mail, PhabricatorUser $sender)
{
$title = $mail->getSubject();
if (!$title) {
$title = pht('Email Paste');
}
$file = PhabricatorPasteEditor::initializeFileForPaste($sender, $title, $mail->getCleanTextBody());
$xactions = array();
$xactions[] = id(new PhabricatorPasteTransaction())->setTransactionType(PhabricatorPasteTransaction::TYPE_CONTENT)->setNewValue($file->getPHID());
$xactions[] = id(new PhabricatorPasteTransaction())->setTransactionType(PhabricatorPasteTransaction::TYPE_TITLE)->setNewValue($title);
$xactions[] = id(new PhabricatorPasteTransaction())->setTransactionType(PhabricatorPasteTransaction::TYPE_LANGUAGE)->setNewValue('');
// auto-detect
$paste = PhabricatorPaste::initializeNewPaste($sender);
$content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_EMAIL, array('id' => $mail->getID()));
$editor = id(new PhabricatorPasteEditor())->setActor($sender)->setContentSource($content_source)->setContinueOnNoEffect(true);
$xactions = $editor->applyTransactions($paste, $xactions);
$mail->setRelatedPHID($paste->getPHID());
$subject_prefix = PhabricatorEnv::getEnvConfig('metamta.paste.subject-prefix');
$subject = pht('You successfully created a paste.');
$paste_uri = PhabricatorEnv::getProductionURI($paste->getURI());
$body = new PhabricatorMetaMTAMailBody();
$body->addRawSection($subject);
$body->addTextSection(pht('PASTE LINK'), $paste_uri);
id(new PhabricatorMetaMTAMail())->addTos(array($sender->getPHID()))->setSubject($subject)->setSubjectPrefix($subject_prefix)->setFrom($sender->getPHID())->setRelatedPHID($paste->getPHID())->setBody($body->render())->saveAndSend();
}
示例4: processRequest
public function processRequest()
{
$request = $this->getRequest();
if (!$request->isFormPost()) {
return new Aphront400Response();
}
$revision_id = $request->getInt('revision_id');
$revision = id(new DifferentialRevision())->load($revision_id);
if (!$revision) {
return new Aphront400Response();
}
$comment = $request->getStr('comment');
$action = $request->getStr('action');
$reviewers = $request->getArr('reviewers');
$ccs = $request->getArr('ccs');
$editor = new DifferentialCommentEditor($revision, $request->getUser()->getPHID(), $action);
$content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_WEB, array('ip' => $request->getRemoteAddr()));
$editor->setMessage($comment)->setContentSource($content_source)->setAttachInlineComments(true)->setAddCC($action != DifferentialAction::ACTION_RESIGN)->setAddedReviewers($reviewers)->setAddedCCs($ccs)->save();
// TODO: Diff change detection?
$draft = id(new PhabricatorDraft())->loadOneWhere('authorPHID = %s AND draftKey = %s', $request->getUser()->getPHID(), 'differential-comment-' . $revision->getID());
if ($draft) {
$draft->delete();
}
return id(new AphrontRedirectResponse())->setURI('/D' . $revision->getID());
}
示例5: receiveEmail
protected function receiveEmail(PhabricatorMetaMTAReceivedMail $mail)
{
$conpherence = $this->getMailReceiver();
$user = $this->getActor();
if (!$conpherence->getPHID()) {
$conpherence->attachParticipants(array())->attachFilePHIDs(array());
} else {
$edge_type = PhabricatorObjectHasFileEdgeType::EDGECONST;
$file_phids = PhabricatorEdgeQuery::loadDestinationPHIDs($conpherence->getPHID(), $edge_type);
$conpherence->attachFilePHIDs($file_phids);
$participants = id(new ConpherenceParticipant())->loadAllWhere('conpherencePHID = %s', $conpherence->getPHID());
$participants = mpull($participants, null, 'getParticipantPHID');
$conpherence->attachParticipants($participants);
}
$content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_EMAIL, array('id' => $mail->getID()));
$editor = id(new ConpherenceEditor())->setActor($user)->setContentSource($content_source)->setParentMessageID($mail->getMessageID());
$body = $mail->getCleanTextBody();
$body = $this->enhanceBodyWithAttachments($body, $mail->getAttachments());
$xactions = array();
if ($this->getMailAddedParticipantPHIDs()) {
$xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS)->setNewValue(array('+' => $this->getMailAddedParticipantPHIDs()));
}
$xactions = array_merge($xactions, $editor->generateTransactionsFromText($user, $conpherence, $body));
$editor->applyTransactions($conpherence, $xactions);
return $conpherence;
}
示例6: processRequest
public function processRequest()
{
$request = $this->getRequest();
if (!$request->isFormPost()) {
return new Aphront400Response();
}
$user = $request->getUser();
$question_id = $request->getInt('question_id');
$question = PonderQuestionQuery::loadSingle($user, $question_id);
if (!$question) {
return new Aphront404Response();
}
$answer = $request->getStr('answer');
// Only want answers with some non whitespace content
if (!strlen(trim($answer))) {
$dialog = new AphrontDialogView();
$dialog->setUser($request->getUser());
$dialog->setTitle('Empty answer');
$dialog->appendChild('<p>Your answer must not be empty.</p>');
$dialog->addCancelButton('/Q' . $question_id);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
$content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_WEB, array('ip' => $request->getRemoteAddr()));
$res = new PonderAnswer();
$res->setContent($answer)->setAuthorPHID($user->getPHID())->setVoteCount(0)->setQuestionID($question_id)->setContentSource($content_source);
id(new PonderAnswerEditor())->setUser($user)->setQuestion($question)->setAnswer($res)->saveAnswer();
return id(new AphrontRedirectResponse())->setURI(id(new PhutilURI('/Q' . $question->getID())));
}
示例7: processRequest
public function processRequest()
{
$request = $this->getRequest();
$viewer = $request->getUser();
$user = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withIDs(array($this->id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if (!$user) {
return new Aphront404Response();
}
$profile_uri = '/p/' . $user->getUsername() . '/';
$field_list = PhabricatorCustomField::getObjectFields($user, PhabricatorCustomField::ROLE_EDIT);
$field_list->setViewer($viewer)->readFieldsFromStorage($user);
$validation_exception = null;
if ($request->isFormPost()) {
$xactions = $field_list->buildFieldTransactionsFromRequest(new PhabricatorUserTransaction(), $request);
$editor = id(new PhabricatorUserProfileEditor())->setActor($viewer)->setContentSource(PhabricatorContentSource::newFromRequest($request))->setContinueOnNoEffect(true);
try {
$editor->applyTransactions($user, $xactions);
return id(new AphrontRedirectResponse())->setURI($profile_uri);
} catch (PhabricatorApplicationTransactionValidationException $ex) {
$validation_exception = $ex;
}
}
$title = pht('Edit Profile');
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($user->getUsername(), $profile_uri);
$crumbs->addTextCrumb($title);
$form = id(new AphrontFormView())->setUser($viewer);
$field_list->appendFieldsToForm($form);
$form->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($profile_uri)->setValue(pht('Save Profile')));
$form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Edit Profile'))->setValidationException($validation_exception)->setForm($form);
return $this->buildApplicationPage(array($crumbs, $form_box), array('title' => $title));
}
示例8: execute
protected function execute(ConduitAPIRequest $request)
{
$source_phid = $request->getValue('sourcePHID');
$owner_phid = $request->getValue('ownerPHID');
$requestor_phid = $request->getValue('requestorPHID');
$user = $request->getUser();
$item = NuanceItem::initializeNewItem();
$xactions = array();
if ($source_phid) {
$xactions[] = id(new NuanceItemTransaction())->setTransactionType(NuanceItemTransaction::TYPE_SOURCE)->setNewValue($source_phid);
} else {
throw new ConduitException('ERR-NO-SOURCE-PHID');
}
if ($owner_phid) {
$xactions[] = id(new NuanceItemTransaction())->setTransactionType(NuanceItemTransaction::TYPE_OWNER)->setNewValue($owner_phid);
}
if ($requestor_phid) {
$xactions[] = id(new NuanceItemTransaction())->setTransactionType(NuanceItemTransaction::TYPE_REQUESTOR)->setNewValue($requestor_phid);
} else {
throw new ConduitException('ERR-NO-REQUESTOR-PHID');
}
$source = PhabricatorContentSource::newFromConduitRequest($request);
$editor = id(new NuanceItemEditor())->setActor($user)->setContentSource($source)->applyTransactions($item, $xactions);
return $item->toDictionary();
}
示例9: receiveEmail
protected function receiveEmail(PhabricatorMetaMTAReceivedMail $mail)
{
$actor = $this->getActor();
$document = $this->getMailReceiver();
$body_data = $mail->parseBody();
$body = $body_data['body'];
$body = $this->enhanceBodyWithAttachments($body, $mail->getAttachments());
$content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_EMAIL, array('id' => $mail->getID()));
$xactions = array();
$command = $body_data['command'];
switch ($command) {
case 'unsubscribe':
$xaction = id(new LegalpadTransaction())->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)->setNewValue(array('-' => array($actor->getPHID())));
$xactions[] = $xaction;
break;
}
$xactions[] = id(new LegalpadTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new LegalpadTransactionComment())->setDocumentID($document->getID())->setLineNumber(0)->setLineLength(0)->setContent($body));
$editor = id(new LegalpadDocumentEditor())->setActor($actor)->setContentSource($content_source)->setContinueOnNoEffect(true)->setIsPreview(false);
try {
$xactions = $editor->applyTransactions($document, $xactions);
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
// just do nothing, though unclear why you're sending a blank email
return true;
}
$head_xaction = head($xactions);
return $head_xaction->getID();
}
示例10: execute
protected function execute(ConduitAPIRequest $request)
{
$diff = id(new DifferentialDiff())->load($request->getValue('diffid'));
if (!$diff) {
throw new ConduitException('ERR_BAD_DIFF');
}
$revision = id(new DifferentialRevision())->load($request->getValue('id'));
if (!$revision) {
throw new ConduitException('ERR_BAD_REVISION');
}
if ($request->getUser()->getPHID() !== $revision->getAuthorPHID()) {
throw new ConduitException('ERR_WRONG_USER');
}
if ($revision->getStatus() == ArcanistDifferentialRevisionStatus::CLOSED) {
throw new ConduitException('ERR_CLOSED');
}
$content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_CONDUIT, array());
$editor = new DifferentialRevisionEditor($revision, $revision->getAuthorPHID());
$editor->setContentSource($content_source);
$fields = $request->getValue('fields');
$editor->copyFieldsFromConduit($fields);
$editor->addDiff($diff, $request->getValue('message'));
$editor->save();
return array('revisionid' => $revision->getID(), 'uri' => PhabricatorEnv::getURI('/D' . $revision->getID()));
}
示例11: generateObject
public function generateObject()
{
$author_phid = $this->loadPhabrictorUserPHID();
$author = id(new PhabricatorUser())->loadOneWhere('phid = %s', $author_phid);
$task = ManiphestTask::initializeNewTask($author)->setSubPriority($this->generateTaskSubPriority())->setTitle($this->generateTitle());
$content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_UNKNOWN, array());
$template = new ManiphestTransaction();
// Accumulate Transactions
$changes = array();
$changes[ManiphestTransaction::TYPE_TITLE] = $this->generateTitle();
$changes[ManiphestTransaction::TYPE_DESCRIPTION] = $this->generateDescription();
$changes[ManiphestTransaction::TYPE_OWNER] = $this->loadOwnerPHID();
$changes[ManiphestTransaction::TYPE_STATUS] = $this->generateTaskStatus();
$changes[ManiphestTransaction::TYPE_PRIORITY] = $this->generateTaskPriority();
$changes[PhabricatorTransactions::TYPE_SUBSCRIBERS] = array('=' => $this->getCCPHIDs());
$transactions = array();
foreach ($changes as $type => $value) {
$transaction = clone $template;
$transaction->setTransactionType($type);
$transaction->setNewValue($value);
$transactions[] = $transaction;
}
$transactions[] = id(new ManiphestTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', PhabricatorProjectObjectHasProjectEdgeType::EDGECONST)->setNewValue(array('=' => array_fuse($this->getProjectPHIDs())));
// Apply Transactions
$editor = id(new ManiphestTransactionEditor())->setActor($author)->setContentSource($content_source)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($task, $transactions);
return $task;
}
示例12: updateServiceLock
protected function updateServiceLock(AlmanacService $service, $lock)
{
$almanac_phid = id(new PhabricatorAlmanacApplication())->getPHID();
$xaction = id(new AlmanacServiceTransaction())->setTransactionType(AlmanacServiceTransaction::TYPE_LOCK)->setNewValue((int) $lock);
$editor = id(new AlmanacServiceEditor())->setActor($this->getViewer())->setActingAsPHID($almanac_phid)->setContentSource(PhabricatorContentSource::newConsoleSource())->setContinueOnMissingFields(true);
$editor->applyTransactions($service, array($xaction));
}
示例13: processRequest
public function processRequest()
{
$request = $this->getRequest();
$viewer = $request->getUser();
$xaction = id(new PhabricatorObjectQuery())->withPHIDs(array($this->phid))->setViewer($viewer)->executeOne();
if (!$xaction) {
return new Aphront404Response();
}
if (!$xaction->getComment()) {
return new Aphront404Response();
}
if ($xaction->getComment()->getIsRemoved()) {
// You can't remove an already-removed comment.
return new Aphront400Response();
}
$obj_phid = $xaction->getObjectPHID();
$obj_handle = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs(array($obj_phid))->executeOne();
if ($request->isDialogFormPost()) {
$comment = $xaction->getApplicationTransactionCommentObject()->setContent('')->setIsRemoved(true);
$editor = id(new PhabricatorApplicationTransactionCommentEditor())->setActor($viewer)->setContentSource(PhabricatorContentSource::newFromRequest($request))->applyEdit($xaction, $comment);
if ($request->isAjax()) {
return id(new AphrontAjaxResponse())->setContent(array());
} else {
return id(new AphrontReloadResponse())->setURI($obj_handle->getURI());
}
}
$form = id(new AphrontFormView())->setUser($viewer);
$dialog = $this->newDialog()->setTitle(pht('Remove Comment'));
$dialog->addHiddenInput('anchor', $request->getStr('anchor'))->appendParagraph(pht("Removing a comment prevents anyone (including you) from reading " . "it. Removing a comment also hides the comment's edit history " . "and prevents it from being edited."))->appendParagraph(pht('Really remove this comment?'));
$dialog->addSubmitButton(pht('Remove Comment'))->addCancelButton($obj_handle->getURI());
return $dialog;
}
开发者ID:fengshao0907,项目名称:phabricator,代码行数:32,代码来源:PhabricatorApplicationTransactionCommentRemoveController.php
示例14: processRequest
public function processRequest()
{
$request = $this->getRequest();
$viewer = $request->getUser();
if (!$request->isFormPost()) {
return new Aphront400Response();
}
$question_id = $request->getInt('question_id');
$question = id(new PonderQuestionQuery())->setViewer($viewer)->withIDs(array($question_id))->needAnswers(true)->executeOne();
if (!$question) {
return new Aphront404Response();
}
$answer = $request->getStr('answer');
if (!strlen(trim($answer))) {
$dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht('Empty Answer'))->appendChild(phutil_tag('p', array(), pht('Your answer must not be empty.')))->addCancelButton('/Q' . $question_id);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
$content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_WEB, array('ip' => $request->getRemoteAddr()));
$res = id(new PonderAnswer())->setAuthorPHID($viewer->getPHID())->setQuestionID($question->getID())->setContent($answer)->setVoteCount(0)->setContentSource($content_source);
$xactions = array();
$xactions[] = id(new PonderQuestionTransaction())->setTransactionType(PonderQuestionTransaction::TYPE_ANSWERS)->setNewValue(array('+' => array(array('answer' => $res))));
$editor = id(new PonderQuestionEditor())->setActor($viewer)->setContentSourceFromRequest($request);
$editor->applyTransactions($question, $xactions);
return id(new AphrontRedirectResponse())->setURI(id(new PhutilURI('/Q' . $question->getID())));
}
示例15: parseCommit
protected function parseCommit(PhabricatorRepository $repository, PhabricatorRepositoryCommit $commit)
{
// Reload the commit to pull commit data and audit requests.
$commit = id(new DiffusionCommitQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withIDs(array($commit->getID()))->needCommitData(true)->needAuditRequests(true)->executeOne();
$data = $commit->getCommitData();
if (!$data) {
throw new PhabricatorWorkerPermanentFailureException(pht('Unable to load commit data. The data for this task is invalid ' . 'or no longer exists.'));
}
$commit->attachRepository($repository);
$content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_DAEMON, array());
$committer_phid = $data->getCommitDetail('committerPHID');
$author_phid = $data->getCommitDetail('authorPHID');
$acting_as_phid = nonempty($committer_phid, $author_phid, id(new PhabricatorDiffusionApplication())->getPHID());
$editor = id(new PhabricatorAuditEditor())->setActor(PhabricatorUser::getOmnipotentUser())->setActingAsPHID($acting_as_phid)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true)->setContentSource($content_source);
$xactions = array();
$xactions[] = id(new PhabricatorAuditTransaction())->setTransactionType(PhabricatorAuditTransaction::TYPE_COMMIT)->setDateCreated($commit->getEpoch())->setNewValue(array('description' => $data->getCommitMessage(), 'summary' => $data->getSummary(), 'authorName' => $data->getAuthorName(), 'authorPHID' => $commit->getAuthorPHID(), 'committerName' => $data->getCommitDetail('committer'), 'committerPHID' => $data->getCommitDetail('committerPHID')));
$reverts_refs = id(new DifferentialCustomFieldRevertsParser())->parseCorpus($data->getCommitMessage());
$reverts = array_mergev(ipull($reverts_refs, 'monograms'));
if ($reverts) {
$reverted_commits = id(new DiffusionCommitQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withRepository($repository)->withIdentifiers($reverts)->execute();
$reverted_commit_phids = mpull($reverted_commits, 'getPHID', 'getPHID');
// NOTE: Skip any write attempts if a user cleverly implies a commit
// reverts itself.
unset($reverted_commit_phids[$commit->getPHID()]);
$reverts_edge = DiffusionCommitRevertsCommitEdgeType::EDGECONST;
$xactions[] = id(new PhabricatorAuditTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $reverts_edge)->setNewValue(array('+' => array_fuse($reverted_commit_phids)));
}
try {
$raw_patch = $this->loadRawPatchText($repository, $commit);
} catch (Exception $ex) {
$raw_patch = pht('Unable to generate patch: %s', $ex->getMessage());
}
$editor->setRawPatch($raw_patch);
return $editor->applyTransactions($commit, $xactions);
}