2015-04-07 23:28:20 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorConfigCacheController
|
|
|
|
extends PhabricatorConfigController {
|
|
|
|
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
|
|
|
$nav = $this->buildSideNavView();
|
|
|
|
$nav->selectFilter('cache/');
|
|
|
|
|
|
|
|
$title = pht('Cache Status');
|
|
|
|
|
|
|
|
$crumbs = $this
|
|
|
|
->buildApplicationCrumbs()
|
|
|
|
->addTextCrumb(pht('Cache Status'));
|
|
|
|
|
2015-04-07 23:38:03 +02:00
|
|
|
$code_box = $this->renderCodeBox();
|
|
|
|
$data_box = $this->renderDataBox();
|
2015-04-07 23:28:20 +02:00
|
|
|
|
2015-04-07 23:38:03 +02:00
|
|
|
$nav->appendChild(
|
|
|
|
array(
|
|
|
|
$crumbs,
|
|
|
|
$code_box,
|
|
|
|
$data_box,
|
|
|
|
));
|
2015-04-07 23:28:20 +02:00
|
|
|
|
|
|
|
return $this->buildApplicationPage(
|
|
|
|
$nav,
|
|
|
|
array(
|
|
|
|
'title' => $title,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2015-04-07 23:38:03 +02:00
|
|
|
private function renderCodeBox() {
|
|
|
|
$cache = PhabricatorOpcodeCacheSpec::getActiveCacheSpec();
|
2015-04-07 23:28:20 +02:00
|
|
|
|
2015-04-07 23:38:03 +02:00
|
|
|
$properties = id(new PHUIPropertyListView());
|
2015-04-07 23:28:20 +02:00
|
|
|
|
2015-04-07 23:38:03 +02:00
|
|
|
$this->renderCommonProperties($properties, $cache);
|
2015-04-07 23:28:20 +02:00
|
|
|
|
2015-04-07 23:38:03 +02:00
|
|
|
return id(new PHUIObjectBoxView())
|
|
|
|
->setFormErrors($this->renderIssues($cache->getIssues()))
|
|
|
|
->setHeaderText(pht('Opcode Cache'))
|
|
|
|
->addPropertyList($properties);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderDataBox() {
|
|
|
|
$cache = PhabricatorDataCacheSpec::getActiveCacheSpec();
|
|
|
|
|
|
|
|
$properties = id(new PHUIPropertyListView());
|
|
|
|
|
|
|
|
$this->renderCommonProperties($properties, $cache);
|
|
|
|
|
|
|
|
return id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText(pht('Data Cache'))
|
|
|
|
->addPropertyList($properties);
|
|
|
|
}
|
2015-04-07 23:28:20 +02:00
|
|
|
|
2015-04-07 23:38:03 +02:00
|
|
|
private function renderCommonProperties(
|
|
|
|
PHUIPropertyListView $properties,
|
|
|
|
PhabricatorCacheSpec $cache) {
|
|
|
|
|
|
|
|
if ($cache->getName() !== null) {
|
|
|
|
$name = $this->renderYes($cache->getName());
|
2015-04-07 23:28:20 +02:00
|
|
|
} else {
|
2015-04-07 23:38:03 +02:00
|
|
|
$name = $this->renderNo(pht('None'));
|
2015-04-07 23:28:20 +02:00
|
|
|
}
|
2015-04-07 23:38:03 +02:00
|
|
|
$properties->addProperty(pht('Cache'), $name);
|
2015-04-07 23:28:20 +02:00
|
|
|
|
2015-04-07 23:38:03 +02:00
|
|
|
if ($cache->getIsEnabled()) {
|
|
|
|
$enabled = $this->renderYes(pht('Enabled'));
|
2015-04-07 23:28:20 +02:00
|
|
|
} else {
|
2015-04-07 23:38:03 +02:00
|
|
|
$enabled = $this->renderNo(pht('Not Enabled'));
|
2015-04-07 23:28:20 +02:00
|
|
|
}
|
2015-04-07 23:38:03 +02:00
|
|
|
$properties->addProperty(pht('Enabled'), $enabled);
|
2015-04-07 23:28:20 +02:00
|
|
|
|
2015-04-07 23:38:03 +02:00
|
|
|
$version = $cache->getVersion();
|
|
|
|
if ($version) {
|
|
|
|
$properties->addProperty(pht('Version'), $this->renderInfo($version));
|
2015-04-07 23:28:20 +02:00
|
|
|
}
|
2015-04-07 23:38:03 +02:00
|
|
|
}
|
2015-04-07 23:28:20 +02:00
|
|
|
|
2015-04-07 23:38:03 +02:00
|
|
|
private function renderIssues(array $issues) {
|
|
|
|
$result = array();
|
|
|
|
foreach ($issues as $issue) {
|
|
|
|
$title = $issue['title'];
|
|
|
|
$body = $issue['body'];
|
|
|
|
$result[] = array(
|
|
|
|
phutil_tag('strong', array(), $title.':'),
|
|
|
|
' ',
|
|
|
|
$body,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return $result;
|
2015-04-07 23:28:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private function renderYes($info) {
|
|
|
|
return array(
|
|
|
|
id(new PHUIIconView())->setIconFont('fa-check', 'green'),
|
|
|
|
' ',
|
|
|
|
$info,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderNo($info) {
|
|
|
|
return array(
|
|
|
|
id(new PHUIIconView())->setIconFont('fa-times-circle', 'red'),
|
|
|
|
' ',
|
|
|
|
$info,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderInfo($info) {
|
|
|
|
return array(
|
|
|
|
id(new PHUIIconView())->setIconFont('fa-info-circle', 'grey'),
|
|
|
|
' ',
|
|
|
|
$info,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|