Skip to content

Instantly share code, notes, and snippets.

@hissy hissy/app.php
Created Aug 8, 2019

Embed
What would you like to do?
#concrete5 Visualize rendering time of each blocks with DebugBar
<?php
/**
* First, install the debug bar package. @link: https://github.com/concrete5cojp/concrete5_debugbar
* Then, add these code in your application/bootstrap/app.php
*/
Events::addListener('on_block_load', function ($event) {
$bID = $event->getArgument('bID');
$btHandle = $event->getArgument('btHandle');
Core::make('debugbar/time')->startMeasure(sprintf('block_%d', $bID), sprintf('Rendering %s block (bID: %d)', $btHandle, $bID));
});
Events::addListener('on_block_output', function ($event) {
$bID = $event->getBlock()->getBlockID();
Core::make('debugbar/time')->stopMeasure(sprintf('block_%d', $bID));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.