mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 09:12:41 +01:00
Move OwnersPackage to Appliation PHIDs
Summary: Ref T2715. Test Plan: `phid.query` Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2715 Differential Revision: https://secure.phabricator.com/D6572
This commit is contained in:
parent
9827ea9c73
commit
3a80c512c7
6 changed files with 62 additions and 25 deletions
|
@ -1342,6 +1342,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorOwnersEditController' => 'applications/owners/controller/PhabricatorOwnersEditController.php',
|
||||
'PhabricatorOwnersListController' => 'applications/owners/controller/PhabricatorOwnersListController.php',
|
||||
'PhabricatorOwnersOwner' => 'applications/owners/storage/PhabricatorOwnersOwner.php',
|
||||
'PhabricatorOwnersPHIDTypePackage' => 'applications/owners/phid/PhabricatorOwnersPHIDTypePackage.php',
|
||||
'PhabricatorOwnersPackage' => 'applications/owners/storage/PhabricatorOwnersPackage.php',
|
||||
'PhabricatorOwnersPackagePathValidator' => 'applications/repository/worker/commitchangeparser/PhabricatorOwnersPackagePathValidator.php',
|
||||
'PhabricatorOwnersPackageQuery' => 'applications/owners/query/PhabricatorOwnersPackageQuery.php',
|
||||
|
@ -3358,6 +3359,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorOwnersEditController' => 'PhabricatorOwnersController',
|
||||
'PhabricatorOwnersListController' => 'PhabricatorOwnersController',
|
||||
'PhabricatorOwnersOwner' => 'PhabricatorOwnersDAO',
|
||||
'PhabricatorOwnersPHIDTypePackage' => 'PhabricatorPHIDType',
|
||||
'PhabricatorOwnersPackage' =>
|
||||
array(
|
||||
0 => 'PhabricatorOwnersDAO',
|
||||
|
|
|
@ -225,7 +225,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
|
|||
break;
|
||||
case 'package':
|
||||
case 'packagecommits':
|
||||
if ($type !== PhabricatorPHIDConstants::PHID_TYPE_OPKG) {
|
||||
if ($type !== PhabricatorOwnersPHIDTypePackage::TYPECONST) {
|
||||
throw new Exception("PHID must be a package PHID!");
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorOwnersPHIDTypePackage extends PhabricatorPHIDType {
|
||||
|
||||
const TYPECONST = 'OPKG';
|
||||
|
||||
public function getTypeConstant() {
|
||||
return self::TYPECONST;
|
||||
}
|
||||
|
||||
public function getTypeName() {
|
||||
return pht('Owners Package');
|
||||
}
|
||||
|
||||
public function newObject() {
|
||||
return new PhabricatorOwnersPackage();
|
||||
}
|
||||
|
||||
public function loadObjects(
|
||||
PhabricatorObjectQuery $query,
|
||||
array $phids) {
|
||||
|
||||
return id(new PhabricatorOwnersPackageQuery())
|
||||
->setViewer($query->getViewer())
|
||||
->withPHIDs($phids)
|
||||
->execute();
|
||||
}
|
||||
|
||||
public function loadHandles(
|
||||
PhabricatorHandleQuery $query,
|
||||
array $handles,
|
||||
array $objects) {
|
||||
|
||||
foreach ($handles as $phid => $handle) {
|
||||
$package = $objects[$phid];
|
||||
|
||||
$name = $package->getName();
|
||||
$id = $package->getID();
|
||||
|
||||
$handle->setName($name);
|
||||
$handle->setURI("/owners/package/{$id}/");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
final class PhabricatorOwnersPackageQuery
|
||||
extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||
|
||||
private $phids;
|
||||
private $ownerPHIDs;
|
||||
|
||||
/**
|
||||
|
@ -13,6 +14,11 @@ final class PhabricatorOwnersPackageQuery
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function withPHIDs(array $phids) {
|
||||
$this->phids = $phids;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function loadPage() {
|
||||
$table = new PhabricatorOwnersPackage();
|
||||
$conn_r = $table->establishConnection('r');
|
||||
|
@ -39,12 +45,19 @@ final class PhabricatorOwnersPackageQuery
|
|||
id(new PhabricatorOwnersOwner())->getTableName());
|
||||
}
|
||||
|
||||
return implode('', $joins);
|
||||
return implode(' ', $joins);
|
||||
}
|
||||
|
||||
private function buildWhereClause(AphrontDatabaseConnection $conn_r) {
|
||||
$where = array();
|
||||
|
||||
if ($this->phids) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'p.phid IN (%Ls)',
|
||||
$this->phids);
|
||||
}
|
||||
|
||||
if ($this->ownerPHIDs) {
|
||||
$base_phids = $this->ownerPHIDs;
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ final class PhabricatorPHIDConstants {
|
|||
const PHID_TYPE_USER = 'USER';
|
||||
const PHID_TYPE_UNKNOWN = '????';
|
||||
const PHID_TYPE_MAGIC = '!!!!';
|
||||
const PHID_TYPE_OPKG = 'OPKG';
|
||||
const PHID_TYPE_STRY = 'STRY';
|
||||
const PHID_TYPE_APRJ = 'APRJ';
|
||||
const PHID_TYPE_ACMT = 'ACMT';
|
||||
|
|
|
@ -56,11 +56,6 @@ final class PhabricatorObjectHandleData {
|
|||
$phids);
|
||||
return mpull($users, null, 'getPHID');
|
||||
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_OPKG:
|
||||
$object = new PhabricatorOwnersPackage();
|
||||
$packages = $object->loadAllWhere('phid in (%Ls)', $phids);
|
||||
return mpull($packages, null, 'getPHID');
|
||||
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_APRJ:
|
||||
$project_dao = new PhabricatorRepositoryArcanistProject();
|
||||
$projects = $project_dao->loadAllWhere(
|
||||
|
@ -227,23 +222,6 @@ final class PhabricatorObjectHandleData {
|
|||
}
|
||||
break;
|
||||
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_OPKG:
|
||||
foreach ($phids as $phid) {
|
||||
$handle = new PhabricatorObjectHandle();
|
||||
$handle->setPHID($phid);
|
||||
$handle->setType($type);
|
||||
if (empty($objects[$phid])) {
|
||||
$handle->setName('Unknown Package');
|
||||
} else {
|
||||
$package = $objects[$phid];
|
||||
$handle->setName($package->getName());
|
||||
$handle->setURI('/owners/package/'.$package->getID().'/');
|
||||
$handle->setComplete(true);
|
||||
}
|
||||
$handles[$phid] = $handle;
|
||||
}
|
||||
break;
|
||||
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_APRJ:
|
||||
foreach ($phids as $phid) {
|
||||
$handle = new PhabricatorObjectHandle();
|
||||
|
|
Loading…
Reference in a new issue