本文整理汇总了PHP中PhabricatorOwnersPackage::loadAffectedPackages方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorOwnersPackage::loadAffectedPackages方法的具体用法?PHP PhabricatorOwnersPackage::loadAffectedPackages怎么用?PHP PhabricatorOwnersPackage::loadAffectedPackages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhabricatorOwnersPackage
的用法示例。
在下文中一共展示了PhabricatorOwnersPackage::loadAffectedPackages方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseCommit
protected function parseCommit(PhabricatorRepository $repository, PhabricatorRepositoryCommit $commit)
{
$affected_paths = PhabricatorOwnerPathQuery::loadAffectedPaths($repository, $commit);
$affected_packages = PhabricatorOwnersPackage::loadAffectedPackages($repository, $affected_paths);
if (!$affected_packages) {
return;
}
foreach ($affected_packages as $package) {
$relationship = id(new PhabricatorOwnersPackageCommitRelationship())->loadOneWhere('packagePHID=%s AND commitPHID=%s', $package->getPHID(), $commit->getPHID());
// Don't update relationship if it exists already
if (!$relationship) {
if ($package->getAuditingEnabled()) {
$reasons = $this->checkAuditReasons($commit, $package);
if ($reasons) {
$audit_status = PhabricatorAuditStatusConstants::AUDIT_REQUIRED;
} else {
$audit_status = PhabricatorAuditStatusConstants::AUDIT_NOT_REQUIRED;
}
} else {
$reasons = array();
$audit_status = PhabricatorAuditStatusConstants::NONE;
}
$relationship = new PhabricatorOwnersPackageCommitRelationship();
$relationship->setPackagePHID($package->getPHID());
$relationship->setCommitPHID($commit->getPHID());
$relationship->setAuditReasons($reasons);
$relationship->setAuditStatus($audit_status);
$relationship->save();
}
}
}
示例2: loadAffectedPackages
public function loadAffectedPackages()
{
if ($this->affectedPackages === null) {
$packages = PhabricatorOwnersPackage::loadAffectedPackages($this->repository, $this->loadAffectedPaths());
$this->affectedPackages = $packages;
}
return $this->affectedPackages;
}
示例3: updateAffectedPackages
private static function updateAffectedPackages($repository, array $move_map)
{
$paths = array_keys($move_map);
if ($paths) {
$packages = PhabricatorOwnersPackage::loadAffectedPackages($repository, $paths);
foreach ($packages as $package) {
self::updatePackagePaths($package, $move_map);
}
}
}
示例4: triggerOwnerAudits
private function triggerOwnerAudits(PhabricatorRepository $repository, PhabricatorRepositoryCommit $commit)
{
if (!$repository->shouldPublish()) {
return;
}
$affected_paths = PhabricatorOwnerPathQuery::loadAffectedPaths($repository, $commit, PhabricatorUser::getOmnipotentUser());
$affected_packages = PhabricatorOwnersPackage::loadAffectedPackages($repository, $affected_paths);
if (!$affected_packages) {
return;
}
$data = id(new PhabricatorRepositoryCommitData())->loadOneWhere('commitID = %d', $commit->getID());
$commit->attachCommitData($data);
$author_phid = $data->getCommitDetail('authorPHID');
$revision_id = $data->getCommitDetail('differential.revisionID');
if ($revision_id) {
$revision = id(new DifferentialRevisionQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withIDs(array($revision_id))->needReviewerStatus(true)->executeOne();
} else {
$revision = null;
}
$requests = id(new PhabricatorRepositoryAuditRequest())->loadAllWhere('commitPHID = %s', $commit->getPHID());
$requests = mpull($requests, null, 'getAuditorPHID');
foreach ($affected_packages as $package) {
$request = idx($requests, $package->getPHID());
if ($request) {
// Don't update request if it exists already.
continue;
}
if ($package->isArchived()) {
// Don't trigger audits if the package is archived.
continue;
}
if ($package->getAuditingEnabled()) {
$reasons = $this->checkAuditReasons($commit, $package, $author_phid, $revision);
if ($reasons) {
$audit_status = PhabricatorAuditStatusConstants::AUDIT_REQUIRED;
} else {
$audit_status = PhabricatorAuditStatusConstants::AUDIT_NOT_REQUIRED;
}
} else {
$reasons = array();
$audit_status = PhabricatorAuditStatusConstants::NONE;
}
$relationship = new PhabricatorRepositoryAuditRequest();
$relationship->setAuditorPHID($package->getPHID());
$relationship->setCommitPHID($commit->getPHID());
$relationship->setAuditReasons($reasons);
$relationship->setAuditStatus($audit_status);
$relationship->save();
$requests[$package->getPHID()] = $relationship;
}
$commit->updateAuditStatus($requests);
$commit->save();
}
示例5: parseCommit
protected function parseCommit(PhabricatorRepository $repository, PhabricatorRepositoryCommit $commit)
{
$affected_paths = PhabricatorOwnerPathQuery::loadAffectedPaths($repository, $commit);
$affected_packages = PhabricatorOwnersPackage::loadAffectedPackages($repository, $affected_paths);
if ($affected_packages) {
$requests = id(new PhabricatorRepositoryAuditRequest())->loadAllWhere('commitPHID = %s', $commit->getPHID());
$requests = mpull($requests, null, 'getAuditorPHID');
foreach ($affected_packages as $package) {
$request = idx($requests, $package->getPHID());
if ($request) {
// Don't update request if it exists already.
continue;
}
if ($package->getAuditingEnabled()) {
$reasons = $this->checkAuditReasons($commit, $package);
if ($reasons) {
$audit_status = PhabricatorAuditStatusConstants::AUDIT_REQUIRED;
} else {
$audit_status = PhabricatorAuditStatusConstants::AUDIT_NOT_REQUIRED;
}
} else {
$reasons = array();
$audit_status = PhabricatorAuditStatusConstants::NONE;
}
$relationship = new PhabricatorRepositoryAuditRequest();
$relationship->setAuditorPHID($package->getPHID());
$relationship->setCommitPHID($commit->getPHID());
$relationship->setAuditReasons($reasons);
$relationship->setAuditStatus($audit_status);
$relationship->save();
$requests[$package->getPHID()] = $relationship;
}
$commit->updateAuditStatus($requests);
$commit->save();
}
if ($this->shouldQueueFollowupTasks()) {
$herald_task = new PhabricatorWorkerTask();
$herald_task->setTaskClass('PhabricatorRepositoryCommitHeraldWorker');
$herald_task->setData(array('commitID' => $commit->getID()));
$herald_task->save();
}
}
示例6: triggerOwnerAudits
private function triggerOwnerAudits(PhabricatorRepository $repository, PhabricatorRepositoryCommit $commit)
{
if (!$repository->shouldPublish()) {
return;
}
$affected_paths = PhabricatorOwnerPathQuery::loadAffectedPaths($repository, $commit, PhabricatorUser::getOmnipotentUser());
$affected_packages = PhabricatorOwnersPackage::loadAffectedPackages($repository, $affected_paths);
if ($affected_packages) {
$requests = id(new PhabricatorRepositoryAuditRequest())->loadAllWhere('commitPHID = %s', $commit->getPHID());
$requests = mpull($requests, null, 'getAuditorPHID');
foreach ($affected_packages as $package) {
$request = idx($requests, $package->getPHID());
if ($request) {
// Don't update request if it exists already.
continue;
}
if ($package->getAuditingEnabled()) {
$reasons = $this->checkAuditReasons($commit, $package);
if ($reasons) {
$audit_status = PhabricatorAuditStatusConstants::AUDIT_REQUIRED;
} else {
$audit_status = PhabricatorAuditStatusConstants::AUDIT_NOT_REQUIRED;
}
} else {
$reasons = array();
$audit_status = PhabricatorAuditStatusConstants::NONE;
}
$relationship = new PhabricatorRepositoryAuditRequest();
$relationship->setAuditorPHID($package->getPHID());
$relationship->setCommitPHID($commit->getPHID());
$relationship->setAuditReasons($reasons);
$relationship->setAuditStatus($audit_status);
$relationship->save();
$requests[$package->getPHID()] = $relationship;
}
$commit->updateAuditStatus($requests);
$commit->save();
}
}
示例7: didApplyHeraldRules
protected function didApplyHeraldRules(PhabricatorLiskDAO $object, HeraldAdapter $adapter, HeraldTranscript $transcript)
{
$repository = $object->getRepository();
if (!$repository) {
return array();
}
if (!$this->affectedPaths) {
return array();
}
$packages = PhabricatorOwnersPackage::loadAffectedPackages($repository, $this->affectedPaths);
if (!$packages) {
return array();
}
// Remove packages that the revision author is an owner of. If you own
// code, you don't need another owner to review it.
$authority = id(new PhabricatorOwnersPackageQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withPHIDs(mpull($packages, 'getPHID'))->withAuthorityPHIDs(array($object->getAuthorPHID()))->execute();
$authority = mpull($authority, null, 'getPHID');
foreach ($packages as $key => $package) {
$package_phid = $package->getPHID();
if (isset($authority[$package_phid])) {
unset($packages[$key]);
continue;
}
}
if (!$packages) {
return array();
}
$auto_subscribe = array();
$auto_review = array();
$auto_block = array();
foreach ($packages as $package) {
switch ($package->getAutoReview()) {
case PhabricatorOwnersPackage::AUTOREVIEW_SUBSCRIBE:
$auto_subscribe[] = $package;
break;
case PhabricatorOwnersPackage::AUTOREVIEW_REVIEW:
$auto_review[] = $package;
break;
case PhabricatorOwnersPackage::AUTOREVIEW_BLOCK:
$auto_block[] = $package;
break;
case PhabricatorOwnersPackage::AUTOREVIEW_NONE:
default:
break;
}
}
$owners_phid = id(new PhabricatorOwnersApplication())->getPHID();
$xactions = array();
if ($auto_subscribe) {
$xactions[] = $object->getApplicationTransactionTemplate()->setAuthorPHID($owners_phid)->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)->setNewValue(array('+' => mpull($auto_subscribe, 'getPHID')));
}
$specs = array(array($auto_review, false), array($auto_block, true));
foreach ($specs as $spec) {
list($reviewers, $blocking) = $spec;
if (!$reviewers) {
continue;
}
$phids = mpull($reviewers, 'getPHID');
$xaction = $this->newAutoReviewTransaction($object, $phids, $blocking);
if ($xaction) {
$xactions[] = $xaction;
}
}
return $xactions;
}