1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Remove Controller->getHandle() and Controller->loadHandles()

Summary: Ref T7689. Modernize all callsites of these methods.

Test Plan:
- Poked at dashboards.
  - Pretty sure this code is technically unreachable right now.
- Viewed commit; viewed "Audit Status".
- Viewed a fund; viewed "Payable to"; viewed "Owner".
- Viewed herald rules; viewed "Author"; viewed "Applies To".
- Viewed a Legalpad document; viewed "Contributors".
- Viewed Phame post list; viewed blog; viewed post (viewed "Blog", viewed "Blogger").
- Viewed a macro; viewed "Audio".
- Viewed a Phriction page; viewed "Last Author".
- Viewed a Ponder question; viewed "Author".
- Viewed a Ponder answer; viewed header.
  - Behavior changed very slightly here; whatevs.
- Viewed a Countdown; viewed "Author".

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7689

Differential Revision: https://secure.phabricator.com/D12210
This commit is contained in:
epriestley 2015-03-30 07:55:33 -07:00
parent 0f52fc771d
commit 64dddc76c5
19 changed files with 41 additions and 111 deletions

View file

@ -3142,7 +3142,6 @@ phutil_register_library_map(array(
'function' => array(
'celerity_generate_unique_node_id' => 'applications/celerity/api.php',
'celerity_get_resource_uri' => 'applications/celerity/api.php',
'implode_selected_handle_links' => 'applications/phid/handle/view/render.php',
'javelin_tag' => 'infrastructure/javelin/markup.php',
'phabricator_date' => 'view/viewutils.php',
'phabricator_datetime' => 'view/viewutils.php',

View file

@ -426,20 +426,6 @@ abstract class PhabricatorController extends AphrontController {
return $response;
}
protected function getHandle($phid) {
if (empty($this->handles[$phid])) {
throw new Exception(
"Attempting to access handle which wasn't loaded: {$phid}");
}
return $this->handles[$phid];
}
protected function loadHandles(array $phids) {
$phids = array_filter($phids);
$this->handles = $this->loadViewerHandles($phids);
return $this;
}
protected function loadViewerHandles(array $phids) {
return id(new PhabricatorHandleQuery())
->setViewer($this->getRequest()->getUser())

View file

@ -101,7 +101,6 @@ final class PhabricatorCountdownViewController
PhabricatorActionListView $actions) {
$viewer = $this->getViewer();
$handles = $viewer->loadHandles(array($countdown->getAuthorPHID()));
$view = id(new PHUIPropertyListView())
->setUser($viewer)
@ -109,7 +108,7 @@ final class PhabricatorCountdownViewController
$view->addProperty(
pht('Author'),
$handles[$countdown->getAuthorPHID()]->renderLink());
$viewer->renderHandle($countdown->getAuthorPHID()));
return $view;
}

View file

@ -50,11 +50,6 @@ final class PhabricatorDashboardInstallController
'applicationClass',
'PhabricatorHomeApplication');
$handles = $this->loadHandles(array(
$object_phid,
$installer_phid,
));
if ($request->isFormPost()) {
$dashboard_install = id(new PhabricatorDashboardInstall())
->loadOneWhere(
@ -121,7 +116,7 @@ final class PhabricatorDashboardInstallController
phutil_tag(
'strong',
array(),
$this->getHandle($object_phid)->getName())));
$viewer->renderHandle($object_phid))));
}
break;
default:

View file

@ -53,7 +53,6 @@ final class PhabricatorDashboardUninstallController
}
$installer_phid = $viewer->getPHID();
$handles = $this->loadHandles(array($object_phid, $installer_phid));
if ($request->isFormPost()) {
$dashboard_install->delete();
@ -83,6 +82,8 @@ final class PhabricatorDashboardUninstallController
$object_phid,
$installer_phid) {
$viewer = $this->getViewer();
$body = array();
switch ($application_class) {
case 'PhabricatorHomeApplication':
@ -106,7 +107,7 @@ final class PhabricatorDashboardUninstallController
pht(
'Are you sure you want to uninstall this dashboard as the home '.
'page for %s?',
$this->getHandle($object_phid)->getName()));
$viewer->renderHandle($object_phid)));
}
break;
}

View file

@ -1021,9 +1021,7 @@ final class DiffusionCommitController extends DiffusionController {
private function renderAuditStatusView(array $audit_requests) {
assert_instances_of($audit_requests, 'PhabricatorRepositoryAuditRequest');
$phids = mpull($audit_requests, 'getAuditorPHID');
$this->loadHandles($phids);
$viewer = $this->getViewer();
$authority_map = array_fill_keys($this->auditAuthorityPHIDs, true);
@ -1043,7 +1041,7 @@ final class DiffusionCommitController extends DiffusionController {
$item->setNote($note);
$auditor_phid = $request->getAuditorPHID();
$target = $this->getHandle($auditor_phid)->renderLink();
$target = $viewer->renderHandle($auditor_phid);
$item->setTarget($target);
if (isset($authority_map[$auditor_phid])) {

View file

@ -70,9 +70,6 @@ final class DiffusionPushEventViewController
private function buildPropertyList(PhabricatorRepositoryPushEvent $event) {
$viewer = $this->getRequest()->getUser();
$this->loadHandles(array($event->getPusherPHID()));
$view = new PHUIPropertyListView();
$view->addProperty(
@ -81,7 +78,7 @@ final class DiffusionPushEventViewController
$view->addProperty(
pht('Pushed By'),
$this->getHandle($event->getPusherPHID())->renderLink());
$viewer->renderHandle($event->getPusherPHID()));
$view->addProperty(
pht('Pushed Via'),

View file

@ -87,19 +87,14 @@ final class FundInitiativeViewController
$owner_phid = $initiative->getOwnerPHID();
$merchant_phid = $initiative->getMerchantPHID();
$this->loadHandles(
array(
$owner_phid,
$merchant_phid,
));
$view->addProperty(
pht('Owner'),
$this->getHandle($owner_phid)->renderLink());
$viewer->renderHandle($owner_phid));
$view->addProperty(
pht('Payable to Merchant'),
$this->getHandle($merchant_phid)->renderLink());
$viewer->renderHandle($merchant_phid));
$view->addProperty(
pht('Total Funding'),

View file

@ -115,8 +115,6 @@ final class HeraldRuleViewController extends HeraldController {
$viewer = $this->getRequest()->getUser();
$handles = $viewer->loadHandles(HeraldAdapter::getHandlePHIDs($rule));
$view = id(new PHUIPropertyListView())
->setUser($viewer)
->setObject($rule)
@ -129,10 +127,9 @@ final class HeraldRuleViewController extends HeraldController {
if ($rule->isPersonalRule()) {
$view->addProperty(
pht('Author'),
$this->getHandle($rule->getAuthorPHID())->renderLink());
$viewer->renderHandle($rule->getAuthorPHID()));
}
$adapter = HeraldAdapter::getAdapterForContentType($rule->getContentType());
if ($adapter) {
$view->addProperty(
@ -144,7 +141,7 @@ final class HeraldRuleViewController extends HeraldController {
if ($rule->isObjectRule()) {
$view->addProperty(
pht('Trigger Object'),
$this->getHandle($rule->getTriggerObjectPHID())->renderLink());
$viewer->renderHandle($rule->getTriggerObjectPHID()));
}
$view->invokeWillRenderEvent();
@ -153,6 +150,7 @@ final class HeraldRuleViewController extends HeraldController {
pht('Rule Description'),
PHUIPropertyListView::ICON_SUMMARY);
$handles = $viewer->loadHandles(HeraldAdapter::getHandlePHIDs($rule));
$view->addTextContent($adapter->renderRuleAsText($rule, $handles));
}

View file

@ -33,15 +33,6 @@ final class LegalpadDocumentManageController extends LegalpadController {
$document->getPHID());
$document_body = $document->getDocumentBody();
$phids = array();
$phids[] = $document_body->getCreatorPHID();
foreach ($subscribers as $subscriber) {
$phids[] = $subscriber;
}
foreach ($document->getContributors() as $contributor) {
$phids[] = $contributor;
}
$this->loadHandles($phids);
$engine = id(new PhabricatorMarkupEngine())
->setViewer($user);
@ -167,21 +158,19 @@ final class LegalpadDocumentManageController extends LegalpadController {
$properties->addProperty(
pht('Updated By'),
$this->getHandle(
$document->getDocumentBody()->getCreatorPHID())->renderLink());
$user->renderHandle($document->getDocumentBody()->getCreatorPHID()));
$properties->addProperty(
pht('Versions'),
$document->getVersions());
$contributor_view = array();
foreach ($document->getContributors() as $contributor) {
$contributor_view[] = $this->getHandle($contributor)->renderLink();
}
$contributor_view = phutil_implode_html(', ', $contributor_view);
if ($document->getContributors()) {
$properties->addProperty(
pht('Contributors'),
$contributor_view);
$user
->renderHandleList($document->getContributors())
->setAsInline(true));
}
$properties->invokeWillRenderEvent();

View file

@ -150,6 +150,7 @@ final class PhabricatorMacroViewController
private function buildPropertyView(
PhabricatorFileImageMacro $macro,
PhabricatorActionListView $actions) {
$viewer = $this->getViewer();
$view = id(new PHUIPropertyListView())
->setUser($this->getRequest()->getUser())
@ -167,10 +168,9 @@ final class PhabricatorMacroViewController
$audio_phid = $macro->getAudioPHID();
if ($audio_phid) {
$this->loadHandles(array($audio_phid));
$view->addProperty(
pht('Audio'),
$this->getHandle($audio_phid)->renderLink());
$viewer->renderHandle($audio_phid));
}
$view->invokeWillRenderEvent();

View file

@ -58,14 +58,6 @@ final class PhabricatorPasteViewController extends PhabricatorPasteController {
->execute();
$fork_phids = mpull($forks, 'getPHID');
$this->loadHandles(
array_merge(
array(
$paste->getAuthorPHID(),
$paste->getParentPHID(),
),
$fork_phids));
$header = $this->buildHeaderView($paste);
$actions = $this->buildActionView($user, $paste, $file);
$properties = $this->buildPropertyView($paste, $fork_phids, $actions);

View file

@ -33,16 +33,24 @@ abstract class PhameController extends PhabricatorController {
$nodata) {
assert_instances_of($posts, 'PhamePost');
$stories = array();
$handle_phids = array();
foreach ($posts as $post) {
$blogger = $this->getHandle($post->getBloggerPHID())->renderLink();
$blogger_uri = $this->getHandle($post->getBloggerPHID())->getURI();
$blogger_image = $this->getHandle($post->getBloggerPHID())->getImageURI();
$handle_phids[] = $post->getBloggerPHID();
if ($post->getBlog()) {
$handle_phids[] = $post->getBlog()->getPHID();
}
}
$handles = $viewer->loadHandles($handle_phids);
$stories = array();
foreach ($posts as $post) {
$blogger = $handles[$post->getBloggerPHID()]->renderLink();
$blogger_uri = $handles[$post->getBloggerPHID()]->getURI();
$blogger_image = $handles[$post->getBloggerPHID()]->getImageURI();
$blog = null;
if ($post->getBlog()) {
$blog = $this->getHandle($post->getBlog()->getPHID())->renderLink();
$blog = $handles[$post->getBlog()->getPHID()]->renderLink();
}
$phame_post = '';

View file

@ -35,11 +35,6 @@ final class PhameBlogViewController extends PhameController {
->setUser($user)
->setPolicyObject($blog);
$handle_phids = array_merge(
mpull($posts, 'getBloggerPHID'),
mpull($posts, 'getBlogPHID'));
$this->loadHandles($handle_phids);
$actions = $this->renderActions($blog, $user);
$properties = $this->renderProperties($blog, $user, $actions);
$post_list = $this->renderPostList(

View file

@ -62,11 +62,6 @@ final class PhamePostListController extends PhameController {
$posts = $query->executeWithCursorPager($pager);
$handle_phids = array_merge(
mpull($posts, 'getBloggerPHID'),
mpull($posts, 'getBlogPHID'));
$this->loadHandles($handle_phids);
require_celerity_resource('phame-css');
$post_list = $this->renderPostList($posts, $user, $nodata);
$post_list = id(new PHUIBoxView())

View file

@ -23,11 +23,6 @@ final class PhamePostViewController extends PhameController {
$nav = $this->renderSideNavFilterView();
$this->loadHandles(
array(
$post->getBlogPHID(),
$post->getBloggerPHID(),
));
$actions = $this->renderActions($post, $user);
$properties = $this->renderProperties($post, $user, $actions);
@ -168,13 +163,11 @@ final class PhamePostViewController extends PhameController {
$properties->addProperty(
pht('Blog'),
$post->getBlogPHID()
? $this->getHandle($post->getBlogPHID())->renderLink()
: null);
$user->renderHandle($post->getBlogPHID()));
$properties->addProperty(
pht('Blogger'),
$this->getHandle($post->getBloggerPHID())->renderLink());
$user->renderHandle($post->getBloggerPHID()));
$properties->addProperty(
pht('Published'),

View file

@ -35,7 +35,6 @@ final class PhortuneAccountListController extends PhortuneController {
'accounts are used to make purchases.'));
foreach ($accounts as $account) {
$this->loadHandles($account->getMemberPHIDs());
$item = id(new PHUIObjectItemView())
->setObjectName(pht('Account %d', $account->getID()))
->setHeader($account->getName())

View file

@ -250,13 +250,9 @@ final class PhrictionDocumentController
->setUser($viewer)
->setObject($document);
$phids = array($content->getAuthorPHID());
$this->loadHandles($phids);
$view->addProperty(
pht('Last Author'),
$this->getHandle($content->getAuthorPHID())->renderLink());
$viewer->renderHandle($content->getAuthorPHID()));
$age = time() - $content->getDateCreated();
$age = floor($age / (60 * 60 * 24));

View file

@ -141,15 +141,13 @@ final class PonderQuestionViewController extends PonderController {
->setObject($question)
->setActionList($actions);
$this->loadHandles(array($question->getAuthorPHID()));
$view->addProperty(
pht('Status'),
PonderQuestionStatus::getQuestionStatusFullName($question->getStatus()));
$view->addProperty(
pht('Author'),
$this->getHandle($question->getAuthorPHID())->renderLink());
$viewer->renderHandle($question->getAuthorPHID()));
$view->addProperty(
pht('Created'),
@ -221,9 +219,6 @@ final class PonderQuestionViewController extends PonderController {
$out = array();
$phids = mpull($answers, 'getAuthorPHID');
$this->loadHandles($phids);
$xactions = id(new PonderAnswerTransactionQuery())
->setViewer($viewer)
->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT))
@ -253,7 +248,7 @@ final class PonderQuestionViewController extends PonderController {
$out[] = id(new PhabricatorAnchorView())
->setAnchorName("A$id");
$header = id(new PHUIHeaderView())
->setHeader($this->getHandle($author_phid)->getFullName());
->setHeader($viewer->renderHandle($author_phid));
$actions = $this->buildAnswerActions($answer);
$properties = $this->buildAnswerProperties($answer, $actions);