Changeset View
Changeset View
Standalone View
Standalone View
src/applications/audit/editor/PhabricatorAuditEditor.php
| <?php | <?php | ||||
| final class PhabricatorAuditEditor | final class PhabricatorAuditEditor | ||||
| extends PhabricatorApplicationTransactionEditor { | extends PhabricatorApplicationTransactionEditor { | ||||
| const MAX_FILES_SHOWN_IN_EMAIL = 1000; | const MAX_FILES_SHOWN_IN_EMAIL = 1000; | ||||
| private $auditReasonMap = array(); | private $auditReasonMap = array(); | ||||
| private $affectedFiles; | private $affectedFiles; | ||||
| private $rawPatch; | private $rawPatch; | ||||
| private $auditorPHIDs = array(); | |||||
| private $didExpandInlineState; | private $didExpandInlineState; | ||||
| public function addAuditReason($phid, $reason) { | public function addAuditReason($phid, $reason) { | ||||
| if (!isset($this->auditReasonMap[$phid])) { | if (!isset($this->auditReasonMap[$phid])) { | ||||
| $this->auditReasonMap[$phid] = array(); | $this->auditReasonMap[$phid] = array(); | ||||
| } | } | ||||
| $this->auditReasonMap[$phid][] = $reason; | $this->auditReasonMap[$phid][] = $reason; | ||||
| ▲ Show 20 Lines • Show All 318 Lines • ▼ Show 20 Lines | protected function applyFinalEffects( | ||||
| $requests = $object->getAudits(); | $requests = $object->getAudits(); | ||||
| $object->updateAuditStatus($requests); | $object->updateAuditStatus($requests); | ||||
| $object->save(); | $object->save(); | ||||
| if ($import_status_flag) { | if ($import_status_flag) { | ||||
| $object->writeImportStatusFlag($import_status_flag); | $object->writeImportStatusFlag($import_status_flag); | ||||
| } | } | ||||
| // Collect auditor PHIDs for building mail. | |||||
| $this->auditorPHIDs = mpull($object->getAudits(), 'getAuditorPHID'); | |||||
| return $xactions; | return $xactions; | ||||
| } | } | ||||
| protected function expandTransaction( | protected function expandTransaction( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
| $xactions = parent::expandTransaction($object, $xaction); | $xactions = parent::expandTransaction($object, $xaction); | ||||
| ▲ Show 20 Lines • Show All 331 Lines • ▼ Show 20 Lines | if ($author_phid) { | ||||
| $user_phids[$author_phid][] = pht('Author'); | $user_phids[$author_phid][] = pht('Author'); | ||||
| } | } | ||||
| $committer_phid = $data->getCommitDetail('committerPHID'); | $committer_phid = $data->getCommitDetail('committerPHID'); | ||||
| if ($committer_phid && ($committer_phid != $author_phid)) { | if ($committer_phid && ($committer_phid != $author_phid)) { | ||||
| $user_phids[$committer_phid][] = pht('Committer'); | $user_phids[$committer_phid][] = pht('Committer'); | ||||
| } | } | ||||
| // we loaded this in applyFinalEffects | foreach ($this->auditorPHIDs as $auditor_phid) { | ||||
| $audit_requests = $object->getAudits(); | |||||
| $auditor_phids = mpull($audit_requests, 'getAuditorPHID'); | |||||
| foreach ($auditor_phids as $auditor_phid) { | |||||
| $user_phids[$auditor_phid][] = pht('Auditor'); | $user_phids[$auditor_phid][] = pht('Auditor'); | ||||
| } | } | ||||
| // TODO: It would be nice to show pusher here too, but that information | // TODO: It would be nice to show pusher here too, but that information | ||||
| // is a little tricky to get at right now. | // is a little tricky to get at right now. | ||||
| if ($user_phids) { | if ($user_phids) { | ||||
| $handle_phids = array_keys($user_phids); | $handle_phids = array_keys($user_phids); | ||||
| ▲ Show 20 Lines • Show All 274 Lines • ▼ Show 20 Lines | final class PhabricatorAuditEditor | ||||
| } | } | ||||
| protected function shouldPublishFeedStory( | protected function shouldPublishFeedStory( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| array $xactions) { | array $xactions) { | ||||
| return $this->shouldPublishRepositoryActivity($object, $xactions); | return $this->shouldPublishRepositoryActivity($object, $xactions); | ||||
| } | } | ||||
| protected function getCustomWorkerState() { | |||||
| return array( | |||||
| 'rawPatch' => $this->rawPatch, | |||||
| 'affectedFiles' => $this->affectedFiles, | |||||
| 'auditorPHIDs' => $this->auditorPHIDs, | |||||
| ); | |||||
| } | |||||
| protected function loadCustomWorkerState(array $state) { | |||||
| $this->rawPatch = idx($state, 'rawPatch'); | |||||
| $this->affectedFiles = idx($state, 'affectedFiles'); | |||||
| $this->auditorPHIDs = idx($state, 'auditorPHIDs'); | |||||
| return $this; | |||||
| } | |||||
| } | } | ||||