Differential D16189 Diff 38944 src/applications/search/controller/PhabricatorSearchRelationshipController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/controller/PhabricatorSearchRelationshipController.php
<?php | <?php | ||||
final class PhabricatorSearchRelationshipController | final class PhabricatorSearchRelationshipController | ||||
extends PhabricatorSearchBaseController { | extends PhabricatorSearchBaseController { | ||||
public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$phid = $request->getURIData('sourcePHID'); | $object = $this->loadRelationshipObject(); | ||||
$object = id(new PhabricatorObjectQuery()) | |||||
->setViewer($viewer) | |||||
->withPHIDs(array($phid)) | |||||
->requireCapabilities( | |||||
array( | |||||
PhabricatorPolicyCapability::CAN_VIEW, | |||||
PhabricatorPolicyCapability::CAN_EDIT, | |||||
)) | |||||
->executeOne(); | |||||
if (!$object) { | if (!$object) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
$list = PhabricatorObjectRelationshipList::newForObject( | $relationship = $this->loadRelationship($object); | ||||
$viewer, | |||||
$object); | |||||
$relationship_key = $request->getURIData('relationshipKey'); | |||||
$relationship = $list->getRelationship($relationship_key); | |||||
if (!$relationship) { | if (!$relationship) { | ||||
return new Aphront404Response(); | return new Aphront404Response(); | ||||
} | } | ||||
$src_phid = $object->getPHID(); | $src_phid = $object->getPHID(); | ||||
$edge_type = $relationship->getEdgeConstant(); | $edge_type = $relationship->getEdgeConstant(); | ||||
$dst_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( | $dst_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( | ||||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | $filters = array( | ||||
'all' => pht('All Objects'), | 'all' => pht('All Objects'), | ||||
); | ); | ||||
$dialog_title = $relationship->getDialogTitleText(); | $dialog_title = $relationship->getDialogTitleText(); | ||||
$dialog_header = $relationship->getDialogHeaderText(); | $dialog_header = $relationship->getDialogHeaderText(); | ||||
$dialog_button = $relationship->getDialogButtonText(); | $dialog_button = $relationship->getDialogButtonText(); | ||||
$dialog_instructions = $relationship->getDialogInstructionsText(); | $dialog_instructions = $relationship->getDialogInstructionsText(); | ||||
// TODO: Remove this, this is just legacy support. | $source_uri = $relationship->getSourceURI($object); | ||||
$legacy_kinds = array( | |||||
ManiphestTaskHasCommitEdgeType::EDGECONST => 'CMIT', | |||||
ManiphestTaskHasMockEdgeType::EDGECONST => 'MOCK', | |||||
ManiphestTaskHasRevisionEdgeType::EDGECONST => 'DREV', | |||||
ManiphestTaskDependsOnTaskEdgeType::EDGECONST => 'TASK', | |||||
ManiphestTaskDependedOnByTaskEdgeType::EDGECONST => 'TASK', | |||||
); | |||||
$edge_type = $relationship->getEdgeConstant(); | |||||
$legacy_kind = idx($legacy_kinds, $edge_type); | |||||
if (!$legacy_kind) { | |||||
throw new Exception( | |||||
pht('Only specific legacy relationships are supported!')); | |||||
} | |||||
return id(new PhabricatorObjectSelectorDialog()) | return id(new PhabricatorObjectSelectorDialog()) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->setInitialPHIDs($initial_phids) | ->setInitialPHIDs($initial_phids) | ||||
->setHandles($handles) | ->setHandles($handles) | ||||
->setFilters($filters) | ->setFilters($filters) | ||||
->setSelectedFilter('created') | ->setSelectedFilter('created') | ||||
->setExcluded($phid) | ->setExcluded($src_phid) | ||||
->setCancelURI($done_uri) | ->setCancelURI($done_uri) | ||||
->setSearchURI("/search/select/{$legacy_kind}/edge/") | ->setSearchURI($source_uri) | ||||
->setTitle($dialog_title) | ->setTitle($dialog_title) | ||||
->setHeader($dialog_header) | ->setHeader($dialog_header) | ||||
->setButtonText($dialog_button) | ->setButtonText($dialog_button) | ||||
->setInstructions($dialog_instructions) | ->setInstructions($dialog_instructions) | ||||
->buildDialog(); | ->buildDialog(); | ||||
} | } | ||||
private function newGraphCycleResponse( | private function newGraphCycleResponse( | ||||
Show All 35 Lines |