mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-23 03:59:25 +01:00
Summary: Updates UIExamples Test Plan: Visit application, click on different examples Reviewers: epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T8628 Differential Revision: https://secure.phabricator.com/D13769
60 lines
1.5 KiB
PHP
60 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 PhutilSymbolLoader())
|
|
->setAncestorClass('PhabricatorUIExample')
|
|
->loadObjects();
|
|
$classes = msort($classes, 'getName');
|
|
|
|
$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->buildApplicationPage(
|
|
$nav,
|
|
array(
|
|
'title' => $example->getName(),
|
|
));
|
|
}
|
|
|
|
}
|