class TraceableContainer
Extends the Drupal container class to trace service instantiations.
Hierarchy
- class \Drupal\webprofiler\DependencyInjection\TraceableContainer extends \Drupal\Core\DependencyInjection\Container
Expanded class hierarchy of TraceableContainer
1 file declares its use of TraceableContainer
- ServicesDataCollector.php in webprofiler/
src/ DataCollector/ ServicesDataCollector.php
File
-
webprofiler/
src/ DependencyInjection/ TraceableContainer.php, line 11
Namespace
Drupal\webprofiler\DependencyInjectionView source
class TraceableContainer extends Container {
/**
* @var array
*/
protected $tracedData;
/**
* @var \Symfony\Component\Stopwatch\Stopwatch
*/
private $stopwatch = NULL;
/**
* @var bool
*/
private $hasStopwatch = FALSE;
/**
* @param string $id
* @param int $invalidBehavior
*
* @return object
*/
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;
}
/**
* @return array
*/
public function getTracedData() {
return $this->tracedData;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
TraceableContainer::$hasStopwatch | private | property | |
TraceableContainer::$stopwatch | private | property | |
TraceableContainer::$tracedData | protected | property | |
TraceableContainer::get | public | function | |
TraceableContainer::getTracedData | public | function |