Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / console / plugin / DarkConsoleXHProfPlugin.php
blobf76b77c850fe01a2761e95c0e68633c5fce6705e
1 <?php
3 final class DarkConsoleXHProfPlugin extends DarkConsolePlugin {
5 protected $profileFilePHID;
7 public function getName() {
8 return pht('XHProf');
11 public function getColor() {
12 $data = $this->getData();
13 if ($data['profileFilePHID']) {
14 return '#ff00ff';
16 return null;
19 public function getDescription() {
20 return pht('Provides detailed PHP profiling information through XHProf.');
23 public function generateData() {
24 return array(
25 'profileFilePHID' => $this->profileFilePHID,
26 'profileURI' => (string)$this
27 ->getRequestURI()
28 ->alter('__profile__', 'page'),
32 public function getXHProfRunID() {
33 return $this->profileFilePHID;
36 public function renderPanel() {
37 $data = $this->getData();
39 $run = $data['profileFilePHID'];
40 $profile_uri = $data['profileURI'];
42 if (!DarkConsoleXHProfPluginAPI::isProfilerAvailable()) {
43 $href = PhabricatorEnv::getDoclink('Installation Guide');
44 $install_guide = phutil_tag(
45 'a',
46 array(
47 'href' => $href,
48 'class' => 'bright-link',
50 pht('Installation Guide'));
51 return hsprintf(
52 '<div class="dark-console-no-content">%s</div>',
53 pht(
54 'The "xhprof" PHP extension is not available. Install xhprof '.
55 'to enable the XHProf console plugin. You can find instructions in '.
56 'the %s.',
57 $install_guide));
60 $result = array();
62 $header = phutil_tag(
63 'div',
64 array('class' => 'dark-console-panel-header'),
65 array(
66 phutil_tag(
67 'a',
68 array(
69 'href' => $profile_uri,
70 'class' => $run ? 'disabled button' : 'button button-green',
72 pht('Profile Page')),
73 phutil_tag('h1', array(), pht('XHProf Profiler')),
74 ));
75 $result[] = $header;
77 if ($run) {
78 $result[] = phutil_tag(
79 'a',
80 array(
81 'href' => "/xhprof/profile/$run/",
82 'class' => 'bright-link',
83 'style' => 'float: right; margin: 1em 2em 0 0; font-weight: bold;',
84 'target' => '_blank',
86 pht('Profile Permalink'));
87 $result[] = phutil_tag(
88 'iframe',
89 array('src' => "/xhprof/profile/$run/?frame=true"));
90 } else {
91 $result[] = phutil_tag(
92 'div',
93 array('class' => 'dark-console-no-content'),
94 pht(
95 'Profiling was not enabled for this page. Use the button above '.
96 'to enable it.'));
99 return phutil_implode_html("\n", $result);
103 public function willShutdown() {
104 $this->profileFilePHID = DarkConsoleXHProfPluginAPI::getProfileFilePHID();