Begin moving Phabricator configuration into PHP
Summary: Ref T2255. Ref T2221. Lay the groundwork to move configuration into PHP, so we can show descriptions in the web UI, do typechecking, disable application options when an application is uninstalled, etc.
Test Plan:
{F28421}
{F28420}
{F28422}
Reviewers: codeblock, btrahan, vrana
Reviewed By: codeblock
CC: aran
Maniphest Tasks: T2221, T2255
Differential Revision: https://secure.phabricator.com/D4306
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
final class PhabricatorConfigGroupController
|
||||
extends PhabricatorConfigController {
|
||||
|
||||
private $groupKey;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->groupKey = $data['key'];
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$groups = PhabricatorApplicationConfigOptions::loadAll();
|
||||
$options = idx($groups, $this->groupKey);
|
||||
if (!$options) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$title = pht('%s Configuration', $options->getName());
|
||||
|
||||
$header = id(new PhabricatorHeaderView())
|
||||
->setHeader($title);
|
||||
|
||||
$list = $this->buildOptionList($options->getOptions());
|
||||
|
||||
$crumbs = $this
|
||||
->buildApplicationCrumbs()
|
||||
->addCrumb(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setName(pht('Config'))
|
||||
->setHref($this->getApplicationURI()))
|
||||
->addCrumb(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setName($options->getName())
|
||||
->setHref($this->getApplicationURI()));
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
$crumbs,
|
||||
$header,
|
||||
$list,
|
||||
),
|
||||
array(
|
||||
'title' => $title,
|
||||
'device' => true,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function buildOptionList(array $options) {
|
||||
assert_instances_of($options, 'PhabricatorConfigOption');
|
||||
|
||||
$list = new PhabricatorObjectItemListView();
|
||||
foreach ($options as $option) {
|
||||
$item = id(new PhabricatorObjectItemView())
|
||||
->setHeader($option->getKey())
|
||||
->setHref('/config/edit/'.$option->getKey().'/')
|
||||
->addAttribute(phutil_escape_html($option->getSummary()));
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user