class TraceableContainer in Devel 8.2
Same name and namespace in other branches
- 8.3 webprofiler/src/DependencyInjection/TraceableContainer.php \Drupal\webprofiler\DependencyInjection\TraceableContainer
- 8 webprofiler/src/DependencyInjection/TraceableContainer.php \Drupal\webprofiler\DependencyInjection\TraceableContainer
- 4.x webprofiler/src/DependencyInjection/TraceableContainer.php \Drupal\webprofiler\DependencyInjection\TraceableContainer
Extends the Drupal container class to trace service instantiations.
Hierarchy
- class \Drupal\Component\DependencyInjection\Container implements \Symfony\Component\DependencyInjection\ContainerInterface
- class \Drupal\Core\DependencyInjection\Container
- class \Drupal\webprofiler\DependencyInjection\TraceableContainer
- class \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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Container:: |
protected | property | The aliases of the container. | |
Container:: |
protected | property | Whether the container parameters can still be changed. | |
Container:: |
protected | property | The currently loading services. | |
Container:: |
protected | property | The parameters of the container. | |
Container:: |
protected | property | The instantiated private services. | |
Container:: |
protected | property | The service definitions of the container. | |
Container:: |
protected | property | The instantiated services. | |
Container:: |
protected | function | Creates a service from a service definition. | 1 |
Container:: |
protected | function | Provides alternatives for a given array and key. | |
Container:: |
public | function | Gets a parameter. | |
Container:: |
protected | function | Provides alternatives in case a parameter was not found. | |
Container:: |
protected | function | Provides alternatives in case a service was not found. | |
Container:: |
public | function | Gets all defined service IDs. | |
Container:: |
public | function | Returns true if the given service is defined. | |
Container:: |
public | function | Checks if a parameter exists. | |
Container:: |
public | function | ||
Container:: |
public | function | Resets shared services from the container. | |
Container:: |
protected | function | Resolves arguments that represent services or variables to the real values. | 1 |
Container:: |
public | function |
Sets a service. Overrides Container:: |
|
Container:: |
public | function | Sets a parameter. | |
Container:: |
private | function | Ensure that cloning doesn't work. | |
Container:: |
public | function | Constructs a new Container instance. | 1 |
Container:: |
public | function | ||
TraceableContainer:: |
private | property | ||
TraceableContainer:: |
private | property | ||
TraceableContainer:: |
protected | property | ||
TraceableContainer:: |
public | function |
Overrides Container:: |
|
TraceableContainer:: |
public | function |