Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294107

Customize how various Drupal classes are output by Symfony's dump()

$
0
0

Problem/Motivation

Symfony dump() function can be used in Drupal tests (and in Drupal in general!) for debugging output.

However, if you dump() a whole entity or a plugin, you get a HUGE amount of output on the terminal, because an entity object includes the field definitions, which in turn have the definitions of ALL the field types and the data types. Similarly, plugins can have a large amount of data from injected services.

Steps to reproduce

Load an entity in a kernel test and dump() it.

Proposed resolution

Symfony's VarDumper component provides various ways in which the output can be customized: https://symfony.com/doc/current/components/var_dumper/advanced.html

For example, one quick and dirty way would be to register a caster for the entity and plugin base classes and unset some of the internal properties -- like this code does: https://github.com/joachim-n/mutable-typed-data/blob/main/Test/src/VarDu...

More elegantly perhaps, a Cloner can be registered and use withRefHandles() to remove the properties.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 294107

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>