当前位置: 首页>>代码示例>>PHP>>正文


PHP PhabricatorContentSource::newForSource方法代码示例

本文整理汇总了PHP中PhabricatorContentSource::newForSource方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorContentSource::newForSource方法的具体用法?PHP PhabricatorContentSource::newForSource怎么用?PHP PhabricatorContentSource::newForSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhabricatorContentSource的用法示例。


在下文中一共展示了PhabricatorContentSource::newForSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute(PhutilArgumentParser $args)
 {
     $viewer = $this->getViewer();
     $argv = $args->getArg('argv');
     if (count($argv) !== 2) {
         throw new PhutilArgumentUsageException(pht('Specify a commit and a revision to attach it to.'));
     }
     $commit_name = head($argv);
     $revision_name = last($argv);
     $commit = id(new DiffusionCommitQuery())->setViewer($viewer)->withIdentifiers(array($commit_name))->executeOne();
     if (!$commit) {
         throw new PhutilArgumentUsageException(pht('Commit "%s" does not exist.', $commit_name));
     }
     $revision = id(new PhabricatorObjectQuery())->setViewer($viewer)->withNames(array($revision_name))->executeOne();
     if (!$revision) {
         throw new PhutilArgumentUsageException(pht('Revision "%s" does not exist.', $revision_name));
     }
     if (!$revision instanceof DifferentialRevision) {
         throw new PhutilArgumentUsageException(pht('Object "%s" must be a Differential revision.', $revision_name));
     }
     // Reload the revision to get the active diff.
     $revision = id(new DifferentialRevisionQuery())->setViewer($viewer)->withIDs(array($revision->getID()))->needActiveDiffs(true)->executeOne();
     $differential_phid = id(new PhabricatorDifferentialApplication())->getPHID();
     $extraction_engine = id(new DifferentialDiffExtractionEngine())->setViewer($viewer)->setAuthorPHID($differential_phid);
     $content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_CONSOLE, array());
     $extraction_engine->updateRevisionWithCommit($revision, $commit, array(), $content_source);
     echo tsprintf("%s\n", pht('Attached "%s" to "%s".', $commit->getMonogram(), $revision->getMonogram()));
 }
开发者ID:truSense,项目名称:phabricator,代码行数:28,代码来源:PhabricatorDifferentialAttachCommitWorkflow.php

示例2: 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());
 }
开发者ID:hwang36,项目名称:phabricator,代码行数:25,代码来源:DifferentialCommentSaveController.php

示例3: 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;
 }
开发者ID:truSense,项目名称:phabricator,代码行数:27,代码来源:PhabricatorManiphestTaskTestDataGenerator.php

示例4: 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();
 }
开发者ID:denghp,项目名称:phabricator,代码行数:25,代码来源:PasteCreateMailReceiver.php

示例5: 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);
 }
开发者ID:pugong,项目名称:phabricator,代码行数:35,代码来源:PhabricatorRepositoryCommitHeraldWorker.php

示例6: 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()));
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:25,代码来源:ConduitAPI_differential_updaterevision_Method.php

示例7: 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();
 }
开发者ID:denghp,项目名称:phabricator,代码行数:27,代码来源:LegalpadReplyHandler.php

示例8: 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())));
 }
开发者ID:denghp,项目名称:phabricator,代码行数:25,代码来源:PonderAnswerSaveController.php

示例9: 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;
 }
开发者ID:barcelonascience,项目名称:phabricator,代码行数:26,代码来源:ConpherenceReplyHandler.php

示例10: 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())));
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:28,代码来源:PonderAnswerSaveController.php

示例11: buildEditor

 /**
  * Build and configure an Editor to publish these transactions.
  */
 private function buildEditor(PhabricatorApplicationTransactionInterface $object)
 {
     $data = $this->getTaskData();
     $daemon_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_DAEMON, array());
     $viewer = PhabricatorUser::getOmnipotentUser();
     $editor = $object->getApplicationTransactionEditor()->setActor($viewer)->setContentSource($daemon_source)->setActingAsPHID(idx($data, 'actorPHID'))->loadWorkerState(idx($data, 'state', array()));
     return $editor;
 }
开发者ID:patelhardik,项目名称:phabricator,代码行数:11,代码来源:PhabricatorApplicationTransactionPublishWorker.php

示例12: newEditor

 private function newEditor(PhabricatorMetaMTAReceivedMail $mail)
 {
     $content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_EMAIL, array('id' => $mail->getID()));
     $editor = $this->getMailReceiver()->getApplicationTransactionEditor()->setActor($this->getActor())->setContentSource($content_source)->setContinueOnMissingFields(true)->setParentMessageID($mail->getMessageID())->setExcludeMailRecipientPHIDs($this->getExcludeMailRecipientPHIDs());
     if ($this->getApplicationEmail()) {
         $editor->setApplicationEmail($this->getApplicationEmail());
     }
     return $editor;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:9,代码来源:PhabricatorApplicationTransactionReplyHandler.php

示例13: execute

 protected function execute(ConduitAPIRequest $request)
 {
     $action = $request->getValue('action');
     $new_commit_id = $request->getValue('commitIdentifier');
     $releeph_request = id(new ReleephRequest())->loadOneWhere('phid = %s', $request->getValue('requestPHID'));
     $xactions = array();
     $xactions[] = id(new ReleephRequestTransaction())->setTransactionType(ReleephRequestTransaction::TYPE_COMMIT)->setMetadataValue('action', $action)->setNewValue($new_commit_id);
     $editor = id(new ReleephRequestTransactionalEditor())->setActor($request->getUser())->setContinueOnNoEffect(true)->setContentSource(PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_CONDUIT, array()));
     $editor->applyTransactions($releeph_request, $xactions);
 }
开发者ID:denghp,项目名称:phabricator,代码行数:10,代码来源:ReleephWorkRecordConduitAPIMethod.php

示例14: receiveEmail

 protected function receiveEmail(PhabricatorMetaMTAReceivedMail $mail)
 {
     $commit = $this->getMailReceiver();
     $actor = $this->getActor();
     $message = $mail->getCleanTextBody();
     $content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_EMAIL, array('id' => $mail->getID()));
     // TODO: Support !raise, !accept, etc.
     $xactions = array();
     $xactions[] = id(new PhabricatorAuditTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new PhabricatorAuditTransactionComment())->setCommitPHID($commit->getPHID())->setContent($message));
     $editor = id(new PhabricatorAuditEditor())->setActor($actor)->setContentSource($content_source)->setExcludeMailRecipientPHIDs($this->getExcludeMailRecipientPHIDs())->setContinueOnMissingFields(true)->applyTransactions($commit, $xactions);
 }
开发者ID:denghp,项目名称:phabricator,代码行数:11,代码来源:PhabricatorAuditReplyHandler.php

示例15: doWork

 protected function doWork()
 {
     $subscription = $this->loadSubscription();
     $range = $this->getBillingPeriodRange($subscription);
     list($last_epoch, $next_epoch) = $range;
     $should_invoice = $subscription->shouldInvoiceForBillingPeriod($last_epoch, $next_epoch);
     if (!$should_invoice) {
         return;
     }
     $currency = $subscription->getCostForBillingPeriodAsCurrency($last_epoch, $next_epoch);
     if (!$currency->isPositive()) {
         return;
     }
     $account = $subscription->getAccount();
     $merchant = $subscription->getMerchant();
     $viewer = PhabricatorUser::getOmnipotentUser();
     $product = id(new PhortuneProductQuery())->setViewer($viewer)->withClassAndRef('PhortuneSubscriptionProduct', $subscription->getPHID())->executeOne();
     $cart_implementation = id(new PhortuneSubscriptionCart())->setSubscription($subscription);
     // TODO: This isn't really ideal. It would be better to use an application
     // actor than the original author of the subscription. In particular, if
     // someone initiates a subscription, adds some other account managers, and
     // later leaves the company, they'll continue "acting" here indefinitely.
     // However, for now, some of the stuff later in the pipeline requires a
     // valid actor with a real PHID. The subscription should eventually be
     // able to create these invoices "as" the application it is acting on
     // behalf of.
     $actor = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withPHIDs(array($subscription->getAuthorPHID()))->executeOne();
     if (!$actor) {
         throw new Exception(pht('Failed to load actor to bill subscription!'));
     }
     $cart = $account->newCart($actor, $cart_implementation, $merchant);
     $purchase = $cart->newPurchase($actor, $product);
     $purchase->setBasePriceAsCurrency($currency)->setMetadataValue('subscriptionPHID', $subscription->getPHID())->setMetadataValue('epoch.start', $last_epoch)->setMetadataValue('epoch.end', $next_epoch)->save();
     $cart->setSubscriptionPHID($subscription->getPHID())->setIsInvoice(1)->save();
     $cart->activateCart();
     try {
         $issues = $this->chargeSubscription($actor, $subscription, $cart);
     } catch (Exception $ex) {
         $issues = array(pht('There was a technical error while trying to automatically bill ' . 'this subscription: %s', $ex));
     }
     if (!$issues) {
         // We're all done; charging the cart sends a billing email as a side
         // effect.
         return;
     }
     // We're shoving this through the CartEditor because it has all the logic
     // for sending mail about carts. This doesn't really affect the state of
     // the cart, but reduces the amount of code duplication.
     $xactions = array();
     $xactions[] = id(new PhortuneCartTransaction())->setTransactionType(PhortuneCartTransaction::TYPE_INVOICED)->setNewValue(true);
     $content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_PHORTUNE, array());
     $acting_phid = id(new PhabricatorPhortuneApplication())->getPHID();
     $editor = id(new PhortuneCartEditor())->setActor($viewer)->setActingAsPHID($acting_phid)->setContentSource($content_source)->setContinueOnMissingFields(true)->setInvoiceIssues($issues)->applyTransactions($cart, $xactions);
 }
开发者ID:pugong,项目名称:phabricator,代码行数:54,代码来源:PhortuneSubscriptionWorker.php


注:本文中的PhabricatorContentSource::newForSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。