nystudio107 /
craft-twigprofiler
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Twig Profiler plugin for Craft CMS |
||
| 4 | * |
||
| 5 | * Twig Profiler allows you to profile sections of your Twig templates, and see |
||
| 6 | * the resulting timings in the Yii2 Debug Toolbar |
||
| 7 | * |
||
| 8 | * @link https://nystudio107.com/ |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 9 | * @copyright Copyright (c) nystudio107 |
||
|
0 ignored issues
–
show
|
|||
| 10 | */ |
||
|
0 ignored issues
–
show
|
|||
| 11 | |||
| 12 | namespace nystudio107\twigprofiler\services; |
||
| 13 | |||
| 14 | use Craft; |
||
| 15 | use craft\base\Component; |
||
| 16 | use nystudio107\twigprofiler\TwigProfiler; |
||
| 17 | |||
| 18 | /** |
||
|
0 ignored issues
–
show
|
|||
| 19 | * @author nystudio107 |
||
|
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
|
|||
| 20 | * @package TwigProfiler |
||
|
0 ignored issues
–
show
|
|||
| 21 | * @since 1.0.0 |
||
|
0 ignored issues
–
show
|
|||
| 22 | */ |
||
|
0 ignored issues
–
show
|
|||
| 23 | class Profile extends Component |
||
| 24 | { |
||
| 25 | // Constants |
||
| 26 | // ========================================================================= |
||
| 27 | /** |
||
|
0 ignored issues
–
show
|
|||
| 28 | * @var string |
||
| 29 | */ |
||
| 30 | public const CATEGORY_PREFIX = 'Twig Profiler'; |
||
| 31 | |||
| 32 | // Public Methods |
||
| 33 | // ========================================================================= |
||
| 34 | /** |
||
|
0 ignored issues
–
show
|
|||
| 35 | * Start logging profiling data |
||
| 36 | */ |
||
|
0 ignored issues
–
show
|
|||
| 37 | public function begin(string $profile): void |
||
| 38 | { |
||
| 39 | Craft::beginProfile( |
||
| 40 | $profile, |
||
| 41 | Craft::t('twig-profiler', self::CATEGORY_PREFIX) |
||
| 42 | . TwigProfiler::$renderingTemplate |
||
| 43 | ); |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
|
0 ignored issues
–
show
|
|||
| 47 | * End logging profiling data |
||
| 48 | */ |
||
|
0 ignored issues
–
show
|
|||
| 49 | public function end(string $profile): void |
||
| 50 | { |
||
| 51 | Craft::endProfile( |
||
| 52 | $profile, |
||
| 53 | Craft::t('twig-profiler', self::CATEGORY_PREFIX) |
||
| 54 | . TwigProfiler::$renderingTemplate |
||
| 55 | ); |
||
| 56 | } |
||
| 57 | } |
||
| 58 |