diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index d9e74a5487..921ccd4cf4 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1398,6 +1398,7 @@ phutil_register_library_map(array( 'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php', 'PhabricatorProjectMembersEditController' => 'applications/project/controller/PhabricatorProjectMembersEditController.php', 'PhabricatorProjectNameCollisionException' => 'applications/project/exception/PhabricatorProjectNameCollisionException.php', + 'PhabricatorProjectPHIDTypeProject' => 'applications/project/phid/PhabricatorProjectPHIDTypeProject.php', 'PhabricatorProjectProfile' => 'applications/project/storage/PhabricatorProjectProfile.php', 'PhabricatorProjectProfileController' => 'applications/project/controller/PhabricatorProjectProfileController.php', 'PhabricatorProjectProfileEditController' => 'applications/project/controller/PhabricatorProjectProfileEditController.php', @@ -3402,6 +3403,7 @@ phutil_register_library_map(array( ), 'PhabricatorProjectMembersEditController' => 'PhabricatorProjectController', 'PhabricatorProjectNameCollisionException' => 'Exception', + 'PhabricatorProjectPHIDTypeProject' => 'PhabricatorPHIDType', 'PhabricatorProjectProfile' => 'PhabricatorProjectDAO', 'PhabricatorProjectProfileController' => 'PhabricatorProjectController', 'PhabricatorProjectProfileEditController' => 'PhabricatorProjectController', diff --git a/src/applications/audit/controller/PhabricatorAuditListController.php b/src/applications/audit/controller/PhabricatorAuditListController.php index 681d78fb9b..2049e9779b 100644 --- a/src/applications/audit/controller/PhabricatorAuditListController.php +++ b/src/applications/audit/controller/PhabricatorAuditListController.php @@ -213,27 +213,29 @@ final class PhabricatorAuditListController extends PhabricatorAuditController { } private function validateHandle(PhabricatorObjectHandle $handle) { + $type = $handle->getType(); + switch ($this->filter) { case 'active': case 'user': case 'author': - if ($handle->getType() !== PhabricatorPHIDConstants::PHID_TYPE_USER) { + if ($type !== PhabricatorPHIDConstants::PHID_TYPE_USER) { throw new Exception("PHID must be a user PHID!"); } break; case 'package': case 'packagecommits': - if ($handle->getType() !== PhabricatorPHIDConstants::PHID_TYPE_OPKG) { + if ($type !== PhabricatorPHIDConstants::PHID_TYPE_OPKG) { throw new Exception("PHID must be a package PHID!"); } break; case 'project': - if ($handle->getType() !== PhabricatorPHIDConstants::PHID_TYPE_PROJ) { + if ($type !== PhabricatorProjectPHIDTypeProject::TYPECONST) { throw new Exception("PHID must be a project PHID!"); } break; case 'repository': - if ($handle->getType() !== PhabricatorPHIDConstants::PHID_TYPE_REPO) { + if ($type !== PhabricatorPHIDConstants::PHID_TYPE_REPO) { throw new Exception("PHID must be a repository PHID!"); } break; diff --git a/src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php b/src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php index 140c232ddf..da7cc9cfb3 100644 --- a/src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php +++ b/src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php @@ -121,7 +121,7 @@ abstract class ConduitAPI_maniphest_Method extends ConduitAPIMethod { $project_phids = $request->getValue('projectPHIDs'); if ($project_phids !== null) { $this->validatePHIDList($project_phids, - PhabricatorPHIDConstants::PHID_TYPE_PROJ, + PhabricatorProjectPHIDTypeProject::TYPECONST, 'projectPHIDS'); $changes[ManiphestTransactionType::TYPE_PROJECTS] = $project_phids; } diff --git a/src/applications/maniphest/search/ManiphestSearchIndexer.php b/src/applications/maniphest/search/ManiphestSearchIndexer.php index 5a133d3454..8b4685be18 100644 --- a/src/applications/maniphest/search/ManiphestSearchIndexer.php +++ b/src/applications/maniphest/search/ManiphestSearchIndexer.php @@ -80,7 +80,7 @@ final class ManiphestSearchIndexer $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_PROJECT, $phid, - PhabricatorPHIDConstants::PHID_TYPE_PROJ, + PhabricatorProjectPHIDTypeProject::TYPECONST, $task->getDateModified()); // Bogus. } diff --git a/src/applications/owners/conduit/ConduitAPI_owners_query_Method.php b/src/applications/owners/conduit/ConduitAPI_owners_query_Method.php index 1d92535c3f..5ec7602c7a 100644 --- a/src/applications/owners/conduit/ConduitAPI_owners_query_Method.php +++ b/src/applications/owners/conduit/ConduitAPI_owners_query_Method.php @@ -45,7 +45,7 @@ final class ConduitAPI_owners_query_Method protected static function queryByOwner($owner) { $is_valid_phid = phid_get_type($owner) == PhabricatorPHIDConstants::PHID_TYPE_USER || - phid_get_type($owner) == PhabricatorPHIDConstants::PHID_TYPE_PROJ; + phid_get_type($owner) == PhabricatorProjectPHIDTypeProject::TYPECONST; if (!$is_valid_phid) { throw id(new ConduitException('ERR-INVALID-PARAMETER')) diff --git a/src/applications/owners/storage/PhabricatorOwnersOwner.php b/src/applications/owners/storage/PhabricatorOwnersOwner.php index a60503d310..68859a0127 100644 --- a/src/applications/owners/storage/PhabricatorOwnersOwner.php +++ b/src/applications/owners/storage/PhabricatorOwnersOwner.php @@ -42,7 +42,9 @@ final class PhabricatorOwnersOwner extends PhabricatorOwnersDAO { array()); $users_in_project_phids = array(); - $project_phids = idx($all_phids, PhabricatorPHIDConstants::PHID_TYPE_PROJ); + $project_phids = idx( + $all_phids, + PhabricatorProjectPHIDTypeProject::TYPECONST); if ($project_phids) { $query = id(new PhabricatorEdgeQuery()) ->withSourcePHIDs($project_phids) diff --git a/src/applications/phid/PhabricatorObjectHandle.php b/src/applications/phid/PhabricatorObjectHandle.php index 3bdf678687..0583f5ba0e 100644 --- a/src/applications/phid/PhabricatorObjectHandle.php +++ b/src/applications/phid/PhabricatorObjectHandle.php @@ -117,7 +117,6 @@ final class PhabricatorObjectHandle PhabricatorPHIDConstants::PHID_TYPE_QUES => 'Question', PhabricatorPHIDConstants::PHID_TYPE_PVAR => 'Variable', PhabricatorPHIDConstants::PHID_TYPE_PSTE => 'Paste', - PhabricatorPHIDConstants::PHID_TYPE_PROJ => 'Project', PhabricatorPHIDConstants::PHID_TYPE_LEGD => 'Legalpad Document', ); diff --git a/src/applications/phid/PhabricatorPHIDConstants.php b/src/applications/phid/PhabricatorPHIDConstants.php index 2cbab1af6c..25e00a97da 100644 --- a/src/applications/phid/PhabricatorPHIDConstants.php +++ b/src/applications/phid/PhabricatorPHIDConstants.php @@ -3,7 +3,6 @@ final class PhabricatorPHIDConstants { const PHID_TYPE_USER = 'USER'; - const PHID_TYPE_PROJ = 'PROJ'; const PHID_TYPE_UNKNOWN = '????'; const PHID_TYPE_MAGIC = '!!!!'; const PHID_TYPE_REPO = 'REPO'; diff --git a/src/applications/phid/handle/PhabricatorObjectHandleData.php b/src/applications/phid/handle/PhabricatorObjectHandleData.php index c3571ba735..70ce33b05e 100644 --- a/src/applications/phid/handle/PhabricatorObjectHandleData.php +++ b/src/applications/phid/handle/PhabricatorObjectHandleData.php @@ -56,13 +56,6 @@ final class PhabricatorObjectHandleData { $phids); return mpull($users, null, 'getPHID'); - case PhabricatorPHIDConstants::PHID_TYPE_PROJ: - $projects = id(new PhabricatorProjectQuery()) - ->setViewer($this->viewer) - ->withPHIDs($phids) - ->execute(); - return mpull($projects, null, 'getPHID'); - case PhabricatorPHIDConstants::PHID_TYPE_REPO: // TODO: Update this to PhabricatorRepositoryQuery $object = new PhabricatorRepository(); @@ -289,23 +282,6 @@ final class PhabricatorObjectHandleData { } break; - case PhabricatorPHIDConstants::PHID_TYPE_PROJ: - foreach ($phids as $phid) { - $handle = new PhabricatorObjectHandle(); - $handle->setPHID($phid); - $handle->setType($type); - if (empty($objects[$phid])) { - $handle->setName('Unknown Project'); - } else { - $project = $objects[$phid]; - $handle->setName($project->getName()); - $handle->setURI('/project/view/'.$project->getID().'/'); - $handle->setComplete(true); - } - $handles[$phid] = $handle; - } - break; - case PhabricatorPHIDConstants::PHID_TYPE_REPO: foreach ($phids as $phid) { $handle = new PhabricatorObjectHandle(); diff --git a/src/applications/phid/utils.php b/src/applications/phid/utils.php index a321a96936..d667473190 100644 --- a/src/applications/phid/utils.php +++ b/src/applications/phid/utils.php @@ -16,14 +16,7 @@ function phid_get_type($phid) { } /** - * Group a list of phids by type. Given: - * - * phid_group_by_type([PHID-USER-1, PHID-USER-2, PHID-PROJ-3]) - * - * phid_group_by_type would return: - * - * [PhabricatorPHIDConstants::PHID_TYPE_USER => [PHID-USER-1, PHID-USER-2], - * PhabricatorPHIDConstants::PHID_TYPE_PROJ => [PHID-PROJ-3]] + * Group a list of phids by type. * * @param phids array of phids * @return map of phid type => list of phids diff --git a/src/applications/policy/filter/PhabricatorPolicy.php b/src/applications/policy/filter/PhabricatorPolicy.php index f5f70c7707..2c63c7ee5c 100644 --- a/src/applications/policy/filter/PhabricatorPolicy.php +++ b/src/applications/policy/filter/PhabricatorPolicy.php @@ -37,7 +37,7 @@ final class PhabricatorPolicy { $phid_type = phid_get_type($policy_identifier); switch ($phid_type) { - case PhabricatorPHIDConstants::PHID_TYPE_PROJ: + case PhabricatorProjectPHIDTypeProject::TYPECONST: $policy->setType(PhabricatorPolicyType::TYPE_PROJECT); $policy->setName($handle->getName()); break; diff --git a/src/applications/policy/filter/PhabricatorPolicyFilter.php b/src/applications/policy/filter/PhabricatorPolicyFilter.php index 765583b638..8f525d75de 100644 --- a/src/applications/policy/filter/PhabricatorPolicyFilter.php +++ b/src/applications/policy/filter/PhabricatorPolicyFilter.php @@ -84,7 +84,7 @@ final class PhabricatorPolicyFilter { $policy = $object->getPolicy($capability); $type = phid_get_type($policy); - if ($type == PhabricatorPHIDConstants::PHID_TYPE_PROJ) { + if ($type == PhabricatorProjectPHIDTypeProject::TYPECONST) { $need_projects[] = $policy; } } @@ -203,7 +203,7 @@ final class PhabricatorPolicyFilter { break; default: $type = phid_get_type($policy); - if ($type == PhabricatorPHIDConstants::PHID_TYPE_PROJ) { + if ($type == PhabricatorProjectPHIDTypeProject::TYPECONST) { if (isset($this->userProjects[$viewer->getPHID()][$policy])) { return true; } else { @@ -268,7 +268,7 @@ final class PhabricatorPolicyFilter { $this->viewer); $type = phid_get_type($policy); - if ($type == PhabricatorPHIDConstants::PHID_TYPE_PROJ) { + if ($type == PhabricatorProjectPHIDTypeProject::TYPECONST) { $who = "To {$verb} this object, you must be a member of project ". "'".$handle->getFullName()."'."; } else if ($type == PhabricatorPHIDConstants::PHID_TYPE_USER) { diff --git a/src/applications/project/phid/PhabricatorProjectPHIDTypeProject.php b/src/applications/project/phid/PhabricatorProjectPHIDTypeProject.php new file mode 100644 index 0000000000..82b6936341 --- /dev/null +++ b/src/applications/project/phid/PhabricatorProjectPHIDTypeProject.php @@ -0,0 +1,50 @@ +setViewer($query->getViewer()) + ->withPHIDs($phids) + ->execute(); + } + + public function loadHandles( + PhabricatorHandleQuery $query, + array $handles, + array $objects) { + + foreach ($handles as $phid => $handle) { + $project = $objects[$phid]; + + $name = $project->getName(); + $id = $project->getID(); + + $handle->setName($name); + $handle->setURI("/project/view/{$id}/"); + } + } + + public function canLoadNamedObject($name) { + // TODO: We should be able to load named projects by hashtag, e.g. "#yolo". + return false; + } + +} diff --git a/src/applications/project/storage/PhabricatorProject.php b/src/applications/project/storage/PhabricatorProject.php index 78992f944b..0ed774e83e 100644 --- a/src/applications/project/storage/PhabricatorProject.php +++ b/src/applications/project/storage/PhabricatorProject.php @@ -84,7 +84,7 @@ final class PhabricatorProject extends PhabricatorProjectDAO public function generatePHID() { return PhabricatorPHID::generateNewPHID( - PhabricatorPHIDConstants::PHID_TYPE_PROJ); + PhabricatorProjectPHIDTypeProject::TYPECONST); } public function loadProfile() { diff --git a/src/applications/repository/search/PhabricatorRepositoryCommitSearchIndexer.php b/src/applications/repository/search/PhabricatorRepositoryCommitSearchIndexer.php index 9d214c3219..a5784d0791 100644 --- a/src/applications/repository/search/PhabricatorRepositoryCommitSearchIndexer.php +++ b/src/applications/repository/search/PhabricatorRepositoryCommitSearchIndexer.php @@ -55,7 +55,7 @@ final class PhabricatorRepositoryCommitSearchIndexer $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_PROJECT, $project_phid, - PhabricatorPHIDConstants::PHID_TYPE_PROJ, + PhabricatorProjectPHIDTypeProject::TYPECONST, $date_created); } } diff --git a/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php b/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php index fafe53c624..a932ccb1fc 100644 --- a/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php +++ b/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php @@ -155,7 +155,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { static $class_map = array( PhabricatorPHIDConstants::PHID_TYPE_USER => 'PhabricatorUser', - PhabricatorPHIDConstants::PHID_TYPE_PROJ => 'PhabricatorProject', PhabricatorPHIDConstants::PHID_TYPE_TOBJ => 'HarbormasterObject', PhabricatorPHIDConstants::PHID_TYPE_BLOG => 'PhameBlog', PhabricatorPHIDConstants::PHID_TYPE_POST => 'PhamePost',