public function TraceableContainer::get in Devel 8
Same name and namespace in other branches
- 8.3 webprofiler/src/DependencyInjection/TraceableContainer.php \Drupal\webprofiler\DependencyInjection\TraceableContainer::get()
- 8.2 webprofiler/src/DependencyInjection/TraceableContainer.php \Drupal\webprofiler\DependencyInjection\TraceableContainer::get()
- 4.x webprofiler/src/DependencyInjection/TraceableContainer.php \Drupal\webprofiler\DependencyInjection\TraceableContainer::get()
Parameters
string $id:
int $invalidBehavior:
Return value
object
Overrides Container::get
File
- webprofiler/src/ DependencyInjection/ TraceableContainer.php, line 34 
Class
- TraceableContainer
- Extends the Drupal container class to trace service instantiations.
Namespace
Drupal\webprofiler\DependencyInjectionCode
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;
}