diff --git a/src/Controller/XHProfController.php b/src/Controller/XHProfController.php
index a4d93e4..f72252c 100644
--- a/src/Controller/XHProfController.php
+++ b/src/Controller/XHProfController.php
@@ -109,6 +109,10 @@ class XHProfController extends ControllerBase {
'#type' => 'inline_template',
'#template' => '
Summary
',
),
+ 'path' => array(
+ '#type' => 'inline_template',
+ '#template' => $this->t('Path: :path', array(':path' => $run->getPath())),
+ ),
'table' => array(
'#theme' => 'table',
'#header' => array(),
diff --git a/src/XHProfLib/Run.php b/src/XHProfLib/Run.php
index 35bc08a..684642a 100755
--- a/src/XHProfLib/Run.php
+++ b/src/XHProfLib/Run.php
@@ -19,6 +19,13 @@ class Run {
*/
private $namespace;
+ /**
+ * URL path of the run.
+ *
+ * @var string
+ */
+ private $path;
+
/**
* @var array
*/
@@ -33,11 +40,13 @@ class Run {
* @param string $run_id
* @param string $namespace
* @param array $data
+ * @param string $path
*/
- public function __construct($run_id, $namespace, $data) {
+ public function __construct($run_id, $namespace, $data, $path) {
$this->run_id = $run_id;
$this->namespace = $namespace;
$this->symbols = $this->parseSymbols($data);
+ $this->path = $path;
}
/**
@@ -47,6 +56,13 @@ class Run {
return $this->run_id;
}
+ /**
+ * @return string
+ */
+ public function getPath() {
+ return $this->path;
+ }
+
/**+
* @return array
*/
diff --git a/src/XHProfLib/Storage/FileStorage.php b/src/XHProfLib/Storage/FileStorage.php
index e526830..0aa1779 100755
--- a/src/XHProfLib/Storage/FileStorage.php
+++ b/src/XHProfLib/Storage/FileStorage.php
@@ -2,7 +2,6 @@
namespace Drupal\xhprof\XHProfLib\Storage;
-use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\xhprof\XHProfLib\Run;
class FileStorage implements StorageInterface {
@@ -61,7 +60,7 @@ class FileStorage implements StorageInterface {
throw new \UnexpectedValueException("Unable to unserialize $file_name!");
}
- $run = new Run($run_id, $namespace, $contents);
+ $run = new Run($run_id, $namespace, $contents['data'], $contents['path']);
return $run;
}
@@ -83,13 +82,17 @@ class FileStorage implements StorageInterface {
public function saveRun($data, $namespace, $run_id) {
// Use PHP serialize function to store the XHProf's
// raw profiler data.
- $data = serialize($data);
+ $file_data = array(
+ 'data' => $data,
+ 'path' => \Drupal::requestStack()->getMasterRequest()->getRequestUri(),
+ );
+ $file_data = serialize($file_data);
$file_name = $this->fileName($run_id, $namespace);
$file = fopen($file_name, 'w');
if ($file) {
- fwrite($file, $data);
+ fwrite($file, $file_data);
fclose($file);
}
else {
@@ -110,11 +113,13 @@ class FileStorage implements StorageInterface {
if (is_dir($dir)) {
foreach (glob("{$this->dir}/*.{$this->suffix}") as $file) {
preg_match("/(?:(?\w+)\.)(?:(?[^.]+)\.)(?[\w.]+)/", basename($file), $matches);
+ $run = $this->getRun($matches['run'], $matches['namespace']);
$runs[] = array(
'run_id' => $matches['run'],
'namespace' => $matches['namespace'],
'basename' => htmlentities(basename($file)),
'date' => date("Y-m-d H:i:s", filemtime($file)),
+ 'path' => $run->getPath(),
);
}
}