Differential D18819 Diff 45159 src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
| Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | abstract class PhabricatorApplicationTransactionEditor | ||||
| private $heraldForcedEmailPHIDs = array(); | private $heraldForcedEmailPHIDs = array(); | ||||
| private $heraldHeader; | private $heraldHeader; | ||||
| private $mailToPHIDs = array(); | private $mailToPHIDs = array(); | ||||
| private $mailCCPHIDs = array(); | private $mailCCPHIDs = array(); | ||||
| private $feedNotifyPHIDs = array(); | private $feedNotifyPHIDs = array(); | ||||
| private $feedRelatedPHIDs = array(); | private $feedRelatedPHIDs = array(); | ||||
| private $modularTypes; | private $modularTypes; | ||||
| private $transactionQueue = array(); | |||||
| const STORAGE_ENCODING_BINARY = 'binary'; | const STORAGE_ENCODING_BINARY = 'binary'; | ||||
| /** | /** | ||||
| * Get the class name for the application this editor is a part of. | * Get the class name for the application this editor is a part of. | ||||
| * | * | ||||
| * Uninstalling the application will disable the editor. | * Uninstalling the application will disable the editor. | ||||
| * | * | ||||
| * @return string Editor's application class name. | * @return string Editor's application class name. | ||||
| ▲ Show 20 Lines • Show All 1,088 Lines • ▼ Show 20 Lines | PhabricatorWorker::scheduleTask( | ||||
| 'xactionPHIDs' => mpull($xactions, 'getPHID'), | 'xactionPHIDs' => mpull($xactions, 'getPHID'), | ||||
| 'state' => $this->getWorkerState(), | 'state' => $this->getWorkerState(), | ||||
| ), | ), | ||||
| array( | array( | ||||
| 'objectPHID' => $object->getPHID(), | 'objectPHID' => $object->getPHID(), | ||||
| 'priority' => PhabricatorWorker::PRIORITY_ALERTS, | 'priority' => PhabricatorWorker::PRIORITY_ALERTS, | ||||
| )); | )); | ||||
| $this->flushTransactionQueue($object); | |||||
| return $xactions; | return $xactions; | ||||
| } | } | ||||
| protected function didCatchDuplicateKeyException( | protected function didCatchDuplicateKeyException( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| array $xactions, | array $xactions, | ||||
| Exception $ex) { | Exception $ex) { | ||||
| return; | return; | ||||
| ▲ Show 20 Lines • Show All 2,674 Lines • ▼ Show 20 Lines | /* -( Workers )------------------------------------------------------------ */ | ||||
| public function getCreateObjectTitle($author, $object) { | public function getCreateObjectTitle($author, $object) { | ||||
| return pht('%s created this object.', $author); | return pht('%s created this object.', $author); | ||||
| } | } | ||||
| public function getCreateObjectTitleForFeed($author, $object) { | public function getCreateObjectTitleForFeed($author, $object) { | ||||
| return pht('%s created an object: %s.', $author, $object); | return pht('%s created an object: %s.', $author, $object); | ||||
| } | } | ||||
| /* -( Queue )-------------------------------------------------------------- */ | |||||
| protected function queueTransaction( | |||||
| PhabricatorApplicationTransaction $xaction) { | |||||
| $this->transactionQueue[] = $xaction; | |||||
| return $this; | |||||
| } | |||||
| private function flushTransactionQueue($object) { | |||||
| if (!$this->transactionQueue) { | |||||
| return; | |||||
| } | |||||
| $xactions = $this->transactionQueue; | |||||
| $this->transactionQueue = array(); | |||||
| $editor = $this->newQueueEditor(); | |||||
| return $editor->applyTransactions($object, $xactions); | |||||
| } | |||||
| private function newQueueEditor() { | |||||
| $editor = id(newv(get_class($this), array())) | |||||
| ->setActor($this->getActor()) | |||||
| ->setContentSource($this->getContentSource()) | |||||
| ->setContinueOnNoEffect($this->getContinueOnNoEffect()) | |||||
| ->setContinueOnMissingFields($this->getContinueOnMissingFields()); | |||||
| if ($this->actingAsPHID !== null) { | |||||
| $editor->setActingAsPHID($this->actingAsPHID); | |||||
| } | |||||
| return $editor; | |||||
| } | |||||
| } | } | ||||