class ProfilerExtension in Devel 8.2
Same name and namespace in other branches
- 8.3 webprofiler/src/Twig/Extension/ProfilerExtension.php \Drupal\webprofiler\Twig\Extension\ProfilerExtension
- 8 webprofiler/src/Twig/Extension/ProfilerExtension.php \Drupal\webprofiler\Twig\Extension\ProfilerExtension
- 4.x webprofiler/src/Twig/Extension/ProfilerExtension.php \Drupal\webprofiler\Twig\Extension\ProfilerExtension
Class ProfilerExtension
Hierarchy
- class \Drupal\webprofiler\Twig\Extension\ProfilerExtension extends \Drupal\webprofiler\Twig\Extension\Twig_Extension_Profiler
Expanded class hierarchy of ProfilerExtension
1 string reference to 'ProfilerExtension'
- webprofiler.services.yml in webprofiler/
webprofiler.services.yml - webprofiler/webprofiler.services.yml
1 service uses ProfilerExtension
File
- webprofiler/
src/ Twig/ Extension/ ProfilerExtension.php, line 12
Namespace
Drupal\webprofiler\Twig\ExtensionView source
class ProfilerExtension extends \Twig_Extension_Profiler {
/**
* @var \Symfony\Component\Stopwatch\Stopwatch
*/
private $stopwatch;
private $events;
private $ideLink;
private $classShortener;
/**
* {@inheritdoc}
*/
public function __construct(\Twig_Profiler_Profile $profile, Stopwatch $stopwatch = NULL, IdeLinkGeneratorInterface $ideLink, ClassShortenerInterface $classShortener) {
parent::__construct($profile);
$this->ideLink = $ideLink;
$this->classShortener = $classShortener;
$this->stopwatch = $stopwatch;
$this->events = new \SplObjectStorage();
}
/**
* {@inheritdoc}
*/
public function enter(\Twig_Profiler_Profile $profile) {
if ($this->stopwatch && $profile
->isTemplate()) {
$this->events[$profile] = $this->stopwatch
->start($profile
->getName(), 'template');
}
parent::enter($profile);
}
/**
* {@inheritdoc}
*/
public function leave(\Twig_Profiler_Profile $profile) {
parent::leave($profile);
if ($this->stopwatch && $profile
->isTemplate()) {
$this->events[$profile]
->stop();
unset($this->events[$profile]);
}
}
/**
* {@inheritdoc}
*/
public function getFunctions() {
return [
new \Twig_SimpleFunction('abbr', [
$this,
'getAbbr',
]),
new \Twig_SimpleFunction('idelink', [
$this,
'getIdeLink',
]),
];
}
/**
* {@inheritdoc}
*/
public function getName() {
return 'native_profiler';
}
/**
* @param $class
*
* @return string
*/
public function getAbbr($class) {
return $this->classShortener
->shortenClass($class);
}
/**
* @param $file
* @param $line
*
* @return string
*/
public function getIdeLink($file, $line) {
return $this->ideLink
->generateLink($file, $line);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ProfilerExtension:: |
private | property | ||
ProfilerExtension:: |
private | property | ||
ProfilerExtension:: |
private | property | ||
ProfilerExtension:: |
private | property | ||
ProfilerExtension:: |
public | function | ||
ProfilerExtension:: |
public | function | ||
ProfilerExtension:: |
public | function | ||
ProfilerExtension:: |
public | function | ||
ProfilerExtension:: |
public | function | ||
ProfilerExtension:: |
public | function | ||
ProfilerExtension:: |
public | function |