Changeset View
Changeset View
Standalone View
Standalone View
src/applications/owners/query/PhabricatorOwnersPackageQuery.php
Show First 20 Lines • Show All 342 Lines • ▼ Show 20 Lines | /* -( Path Control )------------------------------------------------------- */ | ||||
* | * | ||||
* The first package has the most specific claim on the path; the last | * The first package has the most specific claim on the path; the last | ||||
* package has the most general claim. Multiple packages may have claims of | * package has the most general claim. Multiple packages may have claims of | ||||
* equal strength, so this ordering is primarily one of usability and | * equal strength, so this ordering is primarily one of usability and | ||||
* convenience. | * convenience. | ||||
* | * | ||||
* @return list<PhabricatorOwnersPackage> List of controlling packages. | * @return list<PhabricatorOwnersPackage> List of controlling packages. | ||||
*/ | */ | ||||
public function getControllingPackagesForPath($repository_phid, $path) { | public function getControllingPackagesForPath( | ||||
$repository_phid, | |||||
$path, | |||||
$ignore_dominion = false) { | |||||
$path = (string)$path; | $path = (string)$path; | ||||
if (!isset($this->controlMap[$repository_phid][$path])) { | if (!isset($this->controlMap[$repository_phid][$path])) { | ||||
throw new PhutilInvalidStateException('withControl'); | throw new PhutilInvalidStateException('withControl'); | ||||
} | } | ||||
if ($this->controlResults === null) { | if ($this->controlResults === null) { | ||||
throw new PhutilInvalidStateException('execute'); | throw new PhutilInvalidStateException('execute'); | ||||
Show All 17 Lines | foreach ($packages as $package_id => $package) { | ||||
$fragment_count); | $fragment_count); | ||||
if ($strength > $best_match) { | if ($strength > $best_match) { | ||||
$best_match = $strength; | $best_match = $strength; | ||||
$include = !$package_path->getExcluded(); | $include = !$package_path->getExcluded(); | ||||
} | } | ||||
} | } | ||||
if ($best_match && $include) { | if ($best_match && $include) { | ||||
if ($ignore_dominion) { | |||||
$is_weak = false; | |||||
} else { | |||||
$is_weak = ($package->getDominion() == $weak_dominion); | |||||
} | |||||
$matches[$package_id] = array( | $matches[$package_id] = array( | ||||
'strength' => $best_match, | 'strength' => $best_match, | ||||
'weak' => ($package->getDominion() == $weak_dominion), | 'weak' => $is_weak, | ||||
'package' => $package, | 'package' => $package, | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
$matches = isort($matches, 'strength'); | $matches = isort($matches, 'strength'); | ||||
$matches = array_reverse($matches); | $matches = array_reverse($matches); | ||||
Show All 16 Lines |