1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-14 16:51:08 +01:00
phorge-phorge/src/applications/uiexample/controller/PhabricatorUIExampleRenderController.php
Chad Little fd94e07aad Update UIExamples for newPage
Summary: clever commit summary

Test Plan: clever test plan

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D15583
2016-04-02 13:22:41 -07:00

58 lines
1.5 KiB
PHP

<?php
final class PhabricatorUIExampleRenderController extends PhabricatorController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$id = $request->getURIData('class');
$classes = id(new PhutilClassMapQuery())
->setAncestorClass('PhabricatorUIExample')
->setSortMethod('getName')
->execute();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI('view/')));
foreach ($classes as $class => $obj) {
$name = $obj->getName();
$nav->addFilter($class, $name);
}
$selected = $nav->selectFilter($id, head_key($classes));
$example = $classes[$selected];
$example->setRequest($this->getRequest());
$result = $example->renderExample();
if ($result instanceof AphrontResponse) {
// This allows examples to generate dialogs, etc., for demonstration.
return $result;
}
require_celerity_resource('phabricator-ui-example-css');
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($example->getName());
$note = id(new PHUIInfoView())
->setTitle(pht('%s (%s)', $example->getName(), get_class($example)))
->appendChild($example->getDescription())
->setSeverity(PHUIInfoView::SEVERITY_NODATA);
$nav->appendChild(
array(
$crumbs,
$note,
$result,
));
return $this->newPage()
->setTitle($example->getName())
->appendChild($nav);
}
}