TraceableContainer.php in Devel 8.2
File
webprofiler/src/DependencyInjection/TraceableContainer.php
View source
<?php
namespace Drupal\webprofiler\DependencyInjection;
use Drupal\Component\Utility\Timer;
use Drupal\Core\DependencyInjection\Container;
class TraceableContainer extends Container {
protected $tracedData;
private $stopwatch = NULL;
private $hasStopwatch = FALSE;
public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE) {
if (!$this->stopwatch && $this
->has('stopwatch')) {
$this->stopwatch = parent::get('stopwatch');
$this->stopwatch
->openSection();
$this->hasStopwatch = TRUE;
}
if ('stopwatch' === $id) {
return $this->stopwatch;
}
Timer::start($id);
if ($this->hasStopwatch) {
$e = $this->stopwatch
->start($id, 'service');
}
$service = parent::get($id, $invalidBehavior);
$this->tracedData[$id] = Timer::stop($id);
if ($this->hasStopwatch && $e
->isStarted()) {
$e
->stop();
}
return $service;
}
public function getTracedData() {
return $this->tracedData;
}
}