getData();
if ($data['xhprofID']) {
return '#ff00ff';
}
return null;
}
public function getDescription() {
return 'Provides detailed PHP profiling information through XHProf.';
}
public function generateData() {
return array(
'xhprofID' => $this->xhprofID,
'profileURI' => (string)$this
->getRequestURI()
->alter('__profile__', 'page'),
);
}
public function getXHProfRunID() {
return $this->xhprofID;
}
public function renderPanel() {
$data = $this->getData();
$run = $data['xhprofID'];
$profile_uri = $data['profileURI'];
if (!DarkConsoleXHProfPluginAPI::isProfilerAvailable()) {
$href = PhabricatorEnv::getDoclink('article/Installation_Guide.html');
$install_guide = phutil_tag(
'a',
array(
'href' => $href,
'class' => 'bright-link',
),
'Installation Guide');
return hsprintf(
'
'.
'The "xhprof" PHP extension is not available. Install xhprof '.
'to enable the XHProf console plugin. You can find instructions in '.
'the %s.'.
'
',
$install_guide);
}
$result = array();
$header = hsprintf(
'',
phutil_tag(
'a',
array(
'href' => $profile_uri,
'class' => $run
? 'disabled button'
: 'green button',
),
'Profile Page'));
$result[] = $header;
if ($run) {
$result[] = hsprintf(
'Profile Permalink'.
'',
$run,
$run);
} else {
$result[] = hsprintf(
''.
'Profiling was not enabled for this page. Use the button above '.
'to enable it.'.
'
');
}
return phutil_implode_html("\n", $result);
}
public function willShutdown() {
if (DarkConsoleXHProfPluginAPI::isProfilerRequested() &&
(DarkConsoleXHProfPluginAPI::isProfilerRequested() !== 'all')) {
$this->xhprofID = DarkConsoleXHProfPluginAPI::stopProfiler();
}
}
}