本文整理汇总了PHP中PhabricatorOwnersPackage类的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorOwnersPackage类的具体用法?PHP PhabricatorOwnersPackage怎么用?PHP PhabricatorOwnersPackage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PhabricatorOwnersPackage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildPackagePropertyView
private function buildPackagePropertyView(PhabricatorOwnersPackage $package, PhabricatorCustomFieldList $field_list)
{
$viewer = $this->getViewer();
$view = id(new PHUIPropertyListView())->setUser($viewer);
$owners = $package->getOwners();
if ($owners) {
$owner_list = $viewer->renderHandleList(mpull($owners, 'getUserPHID'));
} else {
$owner_list = phutil_tag('em', array(), pht('None'));
}
$view->addProperty(pht('Owners'), $owner_list);
if ($package->getAuditingEnabled()) {
$auditing = pht('Enabled');
} else {
$auditing = pht('Disabled');
}
$view->addProperty(pht('Auditing'), $auditing);
$description = $package->getDescription();
if (strlen($description)) {
$description = new PHUIRemarkupView($viewer, $description);
$view->addSectionHeader(pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
$view->addTextContent($description);
}
$view->invokeWillRenderEvent();
$field_list->appendFieldsToPropertyList($package, $viewer, $view);
return $view;
}
示例2: checkAuditReasons
private function checkAuditReasons(PhabricatorRepositoryCommit $commit, PhabricatorOwnersPackage $package)
{
$data = id(new PhabricatorRepositoryCommitData())->loadOneWhere('commitID = %d', $commit->getID());
$reasons = array();
if ($data->getCommitDetail('vsDiff')) {
$reasons[] = pht('Changed After Revision Was Accepted');
}
$commit_author_phid = $data->getCommitDetail('authorPHID');
if (!$commit_author_phid) {
$reasons[] = pht('Commit Author Not Recognized');
}
$revision_id = $data->getCommitDetail('differential.revisionID');
$revision_author_phid = null;
$commit_reviewedby_phid = null;
if ($revision_id) {
$revision = id(new DifferentialRevisionQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withIDs(array($revision_id))->executeOne();
if ($revision) {
$revision_author_phid = $revision->getAuthorPHID();
$commit_reviewedby_phid = $data->getCommitDetail('reviewerPHID');
if ($revision_author_phid !== $commit_author_phid) {
$reasons[] = pht('Author Not Matching with Revision');
}
} else {
$reasons[] = pht('Revision Not Found');
}
} else {
$reasons[] = pht('No Revision Specified');
}
$owners_phids = PhabricatorOwnersOwner::loadAffiliatedUserPHIDs(array($package->getID()));
if (!($commit_author_phid && in_array($commit_author_phid, $owners_phids) || $commit_reviewedby_phid && in_array($commit_reviewedby_phid, $owners_phids))) {
$reasons[] = pht('Owners Not Involved');
}
return $reasons;
}
示例3: loadPackagesForPaths
private static function loadPackagesForPaths(PhabricatorRepository $repository, array $paths, $limit = 0)
{
$package = new PhabricatorOwnersPackage();
$path = new PhabricatorOwnersPath();
$conn = $package->establishConnection('r');
$repository_clause = qsprintf($conn, 'AND p.repositoryPHID = %s', $repository->getPHID());
$limit_clause = '';
if (!empty($limit)) {
$limit_clause = qsprintf($conn, 'LIMIT %d', $limit);
}
$data = queryfx_all($conn, 'SELECT pkg.id FROM %T pkg JOIN %T p ON p.packageID = pkg.id
WHERE p.path IN (%Ls) %Q ORDER BY LENGTH(p.path) DESC %Q', $package->getTableName(), $path->getTableName(), $paths, $repository_clause, $limit_clause);
$ids = ipull($data, 'id');
if (empty($ids)) {
return array();
}
$order = array();
foreach ($ids as $id) {
if (empty($order[$id])) {
$order[$id] = true;
}
}
$packages = $package->loadAllWhere('id in (%Ld)', array_keys($order));
$packages = array_select_keys($packages, array_keys($order));
return $packages;
}
示例4: loadPage
protected function loadPage()
{
$table = new PhabricatorOwnersPackage();
$conn_r = $table->establishConnection('r');
$data = queryfx_all($conn_r, 'SELECT p.* FROM %T p %Q %Q %Q %Q', $table->getTableName(), $this->buildJoinClause($conn_r), $this->buildWhereClause($conn_r), $this->buildOrderClause($conn_r), $this->buildLimitClause($conn_r));
return $table->loadAllFromArray($data);
}
示例5: buildCustomEditFields
protected function buildCustomEditFields($object)
{
$paths_help = pht(<<<EOTEXT
When updating the paths for a package, pass a list of dictionaries like
this as the `value` for the transaction:
```lang=json, name="Example Paths Value"
[
{
"repositoryPHID": "PHID-REPO-1234",
"path": "/path/to/directory/",
"excluded": false
},
{
"repositoryPHID": "PHID-REPO-1234",
"path": "/another/example/path/",
"excluded": false
}
]
```
This transaction will set the paths to the list you provide, overwriting any
previous paths.
Generally, you will call `owners.search` first to get a list of current paths
(which are provided in the same format), make changes, then update them by
applying a transaction of this type.
EOTEXT
);
$autoreview_map = PhabricatorOwnersPackage::getAutoreviewOptionsMap();
$autoreview_map = ipull($autoreview_map, 'name');
$dominion_map = PhabricatorOwnersPackage::getDominionOptionsMap();
$dominion_map = ipull($dominion_map, 'name');
return array(id(new PhabricatorTextEditField())->setKey('name')->setLabel(pht('Name'))->setDescription(pht('Name of the package.'))->setTransactionType(PhabricatorOwnersPackageTransaction::TYPE_NAME)->setIsRequired(true)->setValue($object->getName()), id(new PhabricatorDatasourceEditField())->setKey('owners')->setLabel(pht('Owners'))->setDescription(pht('Users and projects which own the package.'))->setTransactionType(PhabricatorOwnersPackageTransaction::TYPE_OWNERS)->setDatasource(new PhabricatorProjectOrUserDatasource())->setIsCopyable(true)->setValue($object->getOwnerPHIDs()), id(new PhabricatorSelectEditField())->setKey('dominion')->setLabel(pht('Dominion'))->setDescription(pht('Change package dominion rules.'))->setTransactionType(PhabricatorOwnersPackageTransaction::TYPE_DOMINION)->setIsCopyable(true)->setValue($object->getDominion())->setOptions($dominion_map), id(new PhabricatorSelectEditField())->setKey('autoReview')->setLabel(pht('Auto Review'))->setDescription(pht('Automatically trigger reviews for commits affecting files in ' . 'this package.'))->setTransactionType(PhabricatorOwnersPackageTransaction::TYPE_AUTOREVIEW)->setIsCopyable(true)->setValue($object->getAutoReview())->setOptions($autoreview_map), id(new PhabricatorSelectEditField())->setKey('auditing')->setLabel(pht('Auditing'))->setDescription(pht('Automatically trigger audits for commits affecting files in ' . 'this package.'))->setTransactionType(PhabricatorOwnersPackageTransaction::TYPE_AUDITING)->setIsCopyable(true)->setValue($object->getAuditingEnabled())->setOptions(array('' => pht('Disabled'), '1' => pht('Enabled'))), id(new PhabricatorRemarkupEditField())->setKey('description')->setLabel(pht('Description'))->setDescription(pht('Human-readable description of the package.'))->setTransactionType(PhabricatorOwnersPackageTransaction::TYPE_DESCRIPTION)->setValue($object->getDescription()), id(new PhabricatorSelectEditField())->setKey('status')->setLabel(pht('Status'))->setDescription(pht('Archive or enable the package.'))->setTransactionType(PhabricatorOwnersPackageTransaction::TYPE_STATUS)->setIsConduitOnly(true)->setValue($object->getStatus())->setOptions($object->getStatusNameMap()), id(new PhabricatorConduitEditField())->setKey('paths.set')->setLabel(pht('Paths'))->setIsConduitOnly(true)->setTransactionType(PhabricatorOwnersPackageTransaction::TYPE_PATHS)->setConduitDescription(pht('Overwrite existing package paths with new paths.'))->setConduitTypeDescription(pht('List of dictionaries, each describing a path.'))->setConduitDocumentation($paths_help));
}
示例6: queryByPath
private static function queryByPath($repo_callsign, $path)
{
$repository = id(new PhabricatorRepository())->loadOneWhere('callsign = %s', $repo_callsign);
if (empty($repository)) {
throw id(new ConduitException('ERR_REP_NOT_FOUND'))->setErrorDescription('Repository callsign ' . $repo_callsign . ' not recognized');
}
return PhabricatorOwnersPackage::loadOwningPackages($repository, $path);
}
示例7: loadAffectedPackages
public function loadAffectedPackages()
{
if ($this->affectedPackages === null) {
$packages = PhabricatorOwnersPackage::loadAffectedPackages($this->repository, $this->loadAffectedPaths());
$this->affectedPackages = $packages;
}
return $this->affectedPackages;
}
示例8: testFindLongestPathsPerPackage
function testFindLongestPathsPerPackage()
{
$rows = array(array('id' => 1, 'excluded' => 0, 'path' => 'src/'), array('id' => 1, 'excluded' => 1, 'path' => 'src/releeph/'), array('id' => 2, 'excluded' => 0, 'path' => 'src/releeph/'));
$paths = array('src/' => array('src/a.php' => true, 'src/releeph/b.php' => true), 'src/releeph/' => array('src/releeph/b.php' => true));
$this->assertEqual(array(1 => strlen('src/'), 2 => strlen('src/releeph/')), PhabricatorOwnersPackage::findLongestPathsPerPackage($rows, $paths));
$paths = array('src/' => array('src/releeph/b.php' => true), 'src/releeph/' => array('src/releeph/b.php' => true));
$this->assertEqual(array(2 => strlen('src/releeph/')), PhabricatorOwnersPackage::findLongestPathsPerPackage($rows, $paths));
}
示例9: 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);
}
}
}
示例10: getTitle
public function getTitle()
{
$map = PhabricatorOwnersPackage::getDominionOptionsMap();
$map = ipull($map, 'short');
$old = $this->getOldValue();
$new = $this->getNewValue();
$old = idx($map, $old, $old);
$new = idx($map, $new, $new);
return pht('%s adjusted package dominion rules from %s to %s.', $this->renderAuthor(), $this->renderValue($old), $this->renderValue($new));
}
示例11: getTitle
public function getTitle()
{
$map = PhabricatorOwnersPackage::getAutoreviewOptionsMap();
$map = ipull($map, 'name');
$old = $this->getOldValue();
$new = $this->getNewValue();
$old = idx($map, $old, $old);
$new = idx($map, $new, $new);
return pht('%s adjusted autoreview from %s to %s.', $this->renderAuthor(), $this->renderValue($old), $this->renderValue($new));
}
示例12: testObjectListQuery
public function testObjectListQuery()
{
$user = $this->generateNewTestUser();
$name = $user->getUsername();
$phid = $user->getPHID();
$result = $this->parseObjectList("@{$name}");
$this->assertEqual(array($phid), $result);
$result = $this->parseObjectList("{$name}");
$this->assertEqual(array($phid), $result);
$result = $this->parseObjectList("{$name}, {$name}");
$this->assertEqual(array($phid), $result);
$result = $this->parseObjectList("@{$name}, {$name}");
$this->assertEqual(array($phid), $result);
$result = $this->parseObjectList('');
$this->assertEqual(array(), $result);
$result = $this->parseObjectList("{$name}!", array(), false, array('!'));
$this->assertEqual(array(array('phid' => $phid, 'suffixes' => array('!' => '!'))), $result);
$package = PhabricatorOwnersPackage::initializeNewPackage($user)->setName(pht('Query Test Package'))->save();
$package_phid = $package->getPHID();
$package_mono = $package->getMonogram();
$result = $this->parseObjectList("{$package_mono} Any Ignored Text");
$this->assertEqual(array($package_phid), $result);
$result = $this->parseObjectList("{$package_mono} Any Text, {$name}");
$this->assertEqual(array($package_phid, $phid), $result);
$result = $this->parseObjectList("{$package_mono} Any Text!, {$name}", array(), false, array('!'));
$this->assertEqual(array(array('phid' => $package_phid, 'suffixes' => array('!' => '!')), array('phid' => $phid, 'suffixes' => array())), $result);
// Expect failure when loading a user if objects must be of type "DUCK".
$caught = null;
try {
$result = $this->parseObjectList("{$name}", array('DUCK'));
} catch (Exception $ex) {
$caught = $ex;
}
$this->assertTrue($caught instanceof Exception);
// Expect failure when loading an invalid object.
$caught = null;
try {
$result = $this->parseObjectList('invalid');
} catch (Exception $ex) {
$caught = $ex;
}
$this->assertTrue($caught instanceof Exception);
// Expect failure when loading ANY invalid object, by default.
$caught = null;
try {
$result = $this->parseObjectList("{$name}, invalid");
} catch (Exception $ex) {
$caught = $ex;
}
$this->assertTrue($caught instanceof Exception);
// With partial results, this should load the valid user.
$result = $this->parseObjectList("{$name}, invalid", array(), true);
$this->assertEqual(array($phid), $result);
}
示例13: queryByPath
private static function queryByPath(PhabricatorUser $viewer, $repo_callsign, $path)
{
$repository = id(new PhabricatorRepositoryQuery())->setViewer($viewer)->withCallsigns(array($repo_callsign))->executeOne();
if (!$repository) {
throw id(new ConduitException('ERR_REP_NOT_FOUND'))->setErrorDescription(pht('Repository callsign %s not recognized', $repo_callsign));
}
if ($path == null) {
return PhabricatorOwnersPackage::loadPackagesForRepository($repository);
} else {
return PhabricatorOwnersPackage::loadOwningPackages($repository, $path);
}
}
示例14: checkAuditReasons
private function checkAuditReasons(PhabricatorRepositoryCommit $commit, PhabricatorOwnersPackage $package, $author_phid, $revision)
{
$owner_phids = PhabricatorOwnersOwner::loadAffiliatedUserPHIDs(array($package->getID()));
$owner_phids = array_fuse($owner_phids);
$reasons = array();
if (!$author_phid) {
$reasons[] = pht('Commit Author Not Recognized');
} else {
if (isset($owner_phids[$author_phid])) {
return $reasons;
}
}
if (!$revision) {
$reasons[] = pht('No Revision Specified');
return $reasons;
}
$accepted_statuses = array(DifferentialReviewerStatus::STATUS_ACCEPTED, DifferentialReviewerStatus::STATUS_ACCEPTED_OLDER);
$accepted_statuses = array_fuse($accepted_statuses);
$found_accept = false;
foreach ($revision->getReviewerStatus() as $reviewer) {
$reviewer_phid = $reviewer->getReviewerPHID();
// If this reviewer isn't a package owner, just ignore them.
if (empty($owner_phids[$reviewer_phid])) {
continue;
}
// If this reviewer accepted the revision and owns the package, we're
// all clear and do not need to trigger an audit.
if (isset($accepted_statuses[$reviewer->getStatus()])) {
$found_accept = true;
break;
}
}
if (!$found_accept) {
$reasons[] = pht('Owners Not Involved');
}
return $reasons;
}
示例15: buildPackageDetailView
private function buildPackageDetailView(PhabricatorOwnersPackage $package, PhabricatorCustomFieldList $field_list)
{
$viewer = $this->getViewer();
$view = id(new PHUIPropertyListView())->setUser($viewer);
$owners = $package->getOwners();
if ($owners) {
$owner_list = $viewer->renderHandleList(mpull($owners, 'getUserPHID'));
} else {
$owner_list = phutil_tag('em', array(), pht('None'));
}
$view->addProperty(pht('Owners'), $owner_list);
$dominion = $package->getDominion();
$dominion_map = PhabricatorOwnersPackage::getDominionOptionsMap();
$spec = idx($dominion_map, $dominion, array());
$name = idx($spec, 'short', $dominion);
$view->addProperty(pht('Dominion'), $name);
$auto = $package->getAutoReview();
$autoreview_map = PhabricatorOwnersPackage::getAutoreviewOptionsMap();
$spec = idx($autoreview_map, $auto, array());
$name = idx($spec, 'name', $auto);
$view->addProperty(pht('Auto Review'), $name);
if ($package->getAuditingEnabled()) {
$auditing = pht('Enabled');
} else {
$auditing = pht('Disabled');
}
$view->addProperty(pht('Auditing'), $auditing);
$description = $package->getDescription();
if (strlen($description)) {
$description = new PHUIRemarkupView($viewer, $description);
$view->addSectionHeader(pht('Description'));
$view->addTextContent($description);
}
$field_list->appendFieldsToPropertyList($package, $viewer, $view);
return $view;
}