Commit 815aa548 authored by Luca Lusso's avatar Luca Lusso Committed by willzyx
Browse files

Issue #2703343 by willzyx, lussoluca: Remove usage of kprint_r() and kdevel_print_object()

parent 6385f7cd
......@@ -241,7 +241,7 @@ function backtrace_error_handler($error_level, $message, $filename, $line, $cont
drupal_set_message($msg, ($severity_level <= RfcLogLevel::NOTICE ? 'error' : 'warning'), TRUE);
}
if (!empty($error_handlers[DEVEL_ERROR_HANDLER_BACKTRACE_KINT])) {
print kprint_r(ddebug_backtrace(TRUE, 1), $return = TRUE, $msg);
print kpr(ddebug_backtrace(TRUE, 1), TRUE, $msg);
}
if (!empty($error_handlers[DEVEL_ERROR_HANDLER_BACKTRACE_DPM])) {
dpm(ddebug_backtrace(TRUE, 1), $msg, 'warning');
......@@ -382,18 +382,6 @@ function kpr($input, $export = FALSE, $name = NULL) {
return \Drupal::service('devel.dumper')->dumpOrExport($input, $name, $export);
}
/**
* Kint print.
*
* @deprecated in Devel 8.x-dev, will be removed before Devel 8.0.
* Use kpr() or devel.dumper service instead.
*
* @TODO remove in https://www.drupal.org/node/2703343
*/
function kprint_r($input, $export = FALSE, $name = NULL, $function = 'print_r') {
return kpr($input, $export, $name);
}
/**
* Wrapper for DevelDumperManager::dumpOrExport().
*
......@@ -462,7 +450,7 @@ function dpq($query, $return = FALSE, $name = NULL) {
function devel_render() {
$args = func_get_args();
// #pre_render and #post_render pass the rendered $element as last argument.
kprint_r(end($args));
kpr(end($args));
// #pre_render and #post_render expect the first argument to be returned.
return reset($args);
}
......@@ -535,7 +523,7 @@ function ddebug_backtrace($return = FALSE, $pop = 0, $options = DEBUG_BACKTRACE_
if ($return) {
return $nicetrace;
}
kprint_r($nicetrace);
kpr($nicetrace);
}
}
}
......
......@@ -4,14 +4,40 @@ namespace Drupal\devel\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Url;
use Drupal\devel\DevelDumperManagerInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Returns responses for devel module routes.
*/
class DevelController extends ControllerBase {
/**
* The dumper service.
*
* @var \Drupal\devel\DevelDumperManagerInterface
*/
protected $dumper;
/**
* EntityDebugController constructor.
*
* @param \Drupal\devel\DevelDumperManagerInterface $dumper
* The dumper service.
*/
public function __construct(DevelDumperManagerInterface $dumper) {
$this->dumper = $dumper;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container->get('devel.dumper'));
}
/**
* Clears all caches, then redirects to the previous page.
*/
......@@ -24,7 +50,7 @@ class DevelController extends ControllerBase {
public function themeRegistry() {
$hooks = theme_get_registry();
ksort($hooks);
return array('#markup' => kprint_r($hooks, TRUE));
return $this->dumper->exportAsRenderable($hooks);
}
/**
......@@ -43,7 +69,7 @@ class DevelController extends ControllerBase {
ksort($elements_info);
return array('#markup' => kpr($elements_info, TRUE));
return $this->dumper->exportAsRenderable($elements_info);
}
/**
......@@ -55,27 +81,27 @@ class DevelController extends ControllerBase {
public function fieldInfoPage() {
$fields = FieldStorageConfig::loadMultiple();
ksort($fields);
$output['fields'] = array('#markup' => kprint_r($fields, TRUE, $this->t('Fields')));
$output['fields'] = $this->dumper->exportAsRenderable($fields, $this->t('Fields'));
$field_instances = FieldConfig::loadMultiple();
ksort($field_instances);
$output['instances'] = array('#markup' => kprint_r($field_instances, TRUE, $this->t('Instances')));
$output['instances'] = $this->dumper->exportAsRenderable($field_instances, $this->t('Instances'));
$bundles = \Drupal::service('entity_type.bundle.info')->getAllBundleInfo();
ksort($bundles);
$output['bundles'] = array('#markup' => kprint_r($bundles, TRUE, $this->t('Bundles')));
$output['bundles'] = $this->dumper->exportAsRenderable($bundles, $this->t('Bundles'));
$field_types = \Drupal::service('plugin.manager.field.field_type')->getUiDefinitions();
ksort($field_types);
$output['field_types'] = array('#markup' => kprint_r($field_types, TRUE, $this->t('Field types')));
$output['field_types'] = $this->dumper->exportAsRenderable($field_types, $this->t('Field types'));
$formatter_types = \Drupal::service('plugin.manager.field.formatter')->getDefinitions();
ksort($formatter_types);
$output['formatter_types'] = array('#markup' => kprint_r($formatter_types, TRUE, $this->t('Formatter types')));
$output['formatter_types'] = $this->dumper->exportAsRenderable($formatter_types, $this->t('Formatter types'));
$widget_types = \Drupal::service('plugin.manager.field.widget')->getDefinitions();
ksort($widget_types);
$output['widget_types'] = array('#markup' => kprint_r($widget_types, TRUE, $this->t('Widget types')));
$output['widget_types'] = $this->dumper->exportAsRenderable($widget_types, $this->t('Widget types'));
return $output;
}
......@@ -89,7 +115,7 @@ class DevelController extends ControllerBase {
public function entityInfoPage() {
$types = $this->entityTypeManager()->getDefinitions();
ksort($types);
return array('#markup' => kprint_r($types, TRUE));
return $this->dumper->exportAsRenderable($types);
}
/**
......@@ -142,7 +168,7 @@ class DevelController extends ControllerBase {
'class' => 'table-filter-text-source',
),
'value' => array(
'data' => kprint_r($state, TRUE),
'data' => $this->dumper->export($state),
),
);
......@@ -186,9 +212,7 @@ class DevelController extends ControllerBase {
'#rows' => array(array(session_name(), session_id())),
'#empty' => $this->t('No session available.'),
);
$output['data'] = array(
'#markup' => kprint_r($_SESSION, TRUE),
);
$output['data'] = $this->dumper->exportAsRenderable($_SESSION);
return $output;
}
......
......@@ -71,7 +71,7 @@ class SystemStateEdit extends FormBase {
$form['value'] = array(
'#type' => 'item',
'#title' => $this->t('Current value for %name', array('%name' => $state_name)),
'#markup' => kprint_r($old_value, TRUE),
'#markup' => kpr($old_value, TRUE),
);
$transport = 'plain';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment