Changeset View
Changeset View
Standalone View
Standalone View
src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | return array_merge( | ||||
array( | array( | ||||
self::FIELD_TITLE, | self::FIELD_TITLE, | ||||
self::FIELD_BODY, | self::FIELD_BODY, | ||||
self::FIELD_AUTHOR, | self::FIELD_AUTHOR, | ||||
self::FIELD_AUTHOR_PROJECTS, | self::FIELD_AUTHOR_PROJECTS, | ||||
self::FIELD_REVIEWERS, | self::FIELD_REVIEWERS, | ||||
self::FIELD_CC, | self::FIELD_CC, | ||||
self::FIELD_REPOSITORY, | self::FIELD_REPOSITORY, | ||||
self::FIELD_REPOSITORY_PROJECTS, | |||||
self::FIELD_DIFF_FILE, | self::FIELD_DIFF_FILE, | ||||
self::FIELD_DIFF_CONTENT, | self::FIELD_DIFF_CONTENT, | ||||
self::FIELD_DIFF_ADDED_CONTENT, | self::FIELD_DIFF_ADDED_CONTENT, | ||||
self::FIELD_DIFF_REMOVED_CONTENT, | self::FIELD_DIFF_REMOVED_CONTENT, | ||||
self::FIELD_RULE, | self::FIELD_RULE, | ||||
self::FIELD_AFFECTED_PACKAGE, | self::FIELD_AFFECTED_PACKAGE, | ||||
self::FIELD_AFFECTED_PACKAGE_OWNER, | self::FIELD_AFFECTED_PACKAGE_OWNER, | ||||
), | ), | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | final class HeraldDifferentialRevisionAdapter extends HeraldAdapter { | ||||
public function getHeraldName() { | public function getHeraldName() { | ||||
return $this->revision->getTitle(); | return $this->revision->getTitle(); | ||||
} | } | ||||
public function loadRepository() { | public function loadRepository() { | ||||
if ($this->repository === null) { | if ($this->repository === null) { | ||||
$this->repository = false; | $this->repository = false; | ||||
// TODO: (T603) Implement policy stuff in Herald. | |||||
$viewer = PhabricatorUser::getOmnipotentUser(); | $viewer = PhabricatorUser::getOmnipotentUser(); | ||||
$repository_phid = null; | |||||
$revision = $this->revision; | $revision = $this->revision; | ||||
if ($revision->getRepositoryPHID()) { | if ($revision->getRepositoryPHID()) { | ||||
$repositories = id(new PhabricatorRepositoryQuery()) | $repository_phid = $revision->getRepositoryPHID(); | ||||
} else { | |||||
$repository = id(new DifferentialRepositoryLookup()) | |||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withPHIDs(array($revision->getRepositoryPHID())) | ->setDiff($this->diff) | ||||
->execute(); | ->lookupRepository(); | ||||
if ($repositories) { | if ($repository) { | ||||
$this->repository = head($repositories); | // We want to get the projects for this repository too, so run a | ||||
return $this->repository; | // full query for it below. | ||||
$repository_phid = $repository->getPHID(); | |||||
} | } | ||||
} | } | ||||
$repository = id(new DifferentialRepositoryLookup()) | if ($repository_phid) { | ||||
$repository = id(new PhabricatorRepositoryQuery()) | |||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->setDiff($this->diff) | ->withPHIDs(array($repository_phid)) | ||||
->lookupRepository(); | ->needProjectPHIDs(true) | ||||
->executeOne(); | |||||
if ($repository) { | if ($repository) { | ||||
$this->repository = $repository; | $this->repository = $repository; | ||||
return $this->repository; | |||||
} | } | ||||
$repository = false; | |||||
} | } | ||||
} | |||||
return $this->repository; | return $this->repository; | ||||
} | } | ||||
protected function loadChangesets() { | protected function loadChangesets() { | ||||
if ($this->changesets === null) { | if ($this->changesets === null) { | ||||
$this->changesets = $this->diff->loadChangesets(); | $this->changesets = $this->diff->loadChangesets(); | ||||
} | } | ||||
return $this->changesets; | return $this->changesets; | ||||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | switch ($field) { | ||||
return $this->revision->getReviewers(); | return $this->revision->getReviewers(); | ||||
} | } | ||||
case self::FIELD_REPOSITORY: | case self::FIELD_REPOSITORY: | ||||
$repository = $this->loadRepository(); | $repository = $this->loadRepository(); | ||||
if (!$repository) { | if (!$repository) { | ||||
return null; | return null; | ||||
} | } | ||||
return $repository->getPHID(); | return $repository->getPHID(); | ||||
case self::FIELD_REPOSITORY_PROJECTS: | |||||
$repository = $this->loadRepository(); | |||||
if (!$repository) { | |||||
return null; | |||||
} | |||||
return $repository->getProjectPHIDs(); | |||||
case self::FIELD_DIFF_CONTENT: | case self::FIELD_DIFF_CONTENT: | ||||
return $this->loadContentDictionary(); | return $this->loadContentDictionary(); | ||||
case self::FIELD_DIFF_ADDED_CONTENT: | case self::FIELD_DIFF_ADDED_CONTENT: | ||||
return $this->loadAddedContentDictionary(); | return $this->loadAddedContentDictionary(); | ||||
case self::FIELD_DIFF_REMOVED_CONTENT: | case self::FIELD_DIFF_REMOVED_CONTENT: | ||||
return $this->loadRemovedContentDictionary(); | return $this->loadRemovedContentDictionary(); | ||||
case self::FIELD_AFFECTED_PACKAGE: | case self::FIELD_AFFECTED_PACKAGE: | ||||
$packages = $this->loadAffectedPackages(); | $packages = $this->loadAffectedPackages(); | ||||
▲ Show 20 Lines • Show All 155 Lines • Show Last 20 Lines |