Skip to content

Instantly share code, notes, and snippets.

@RuZniki
Last active March 28, 2017 09:22
Show Gist options
  • Save RuZniki/6b0d30a4c4a2fdc2b89cb43796ddc5ab to your computer and use it in GitHub Desktop.
Save RuZniki/6b0d30a4c4a2fdc2b89cb43796ddc5ab to your computer and use it in GitHub Desktop.
Drupal 8 Kint how to modify maxLevels
<?php
/**
* Change function kint in devel/kint/kint.module
*
* Show $var up to level 6
* kint($var, ['kint_maxLevels' => 6]),
*/
function kint() {
kint_require();
if (\Drupal::currentUser()->hasPermission('access kint')) {
$maxLevels = 3;
$args = func_get_args();
if (func_num_args() > 1) {
$last_arg = end($args);
if (isset($last_arg['kint_maxLevels']) && count($last_arg) == 1) {
array_pop($args);
\Kint::$maxLevels = 3;
}
}
if (count($args) == 1) {
$args = array_pop($args);
}
if (PHP_SAPI === 'cli') {
s($args);
}
else {
\Kint::$maxLevels = $maxLevels;
\Kint::dump($args);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment