DevelDumperBase.php 982 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace Drupal\devel;
  3. use Drupal\Core\Plugin\PluginBase;
  4. use Drupal\devel\Render\FilteredMarkup;
  5. /**
  6. * Defines a base devel dumper implementation.
  7. *
  8. * @see \Drupal\devel\Annotation\DevelDumper
  9. * @see \Drupal\devel\DevelDumperInterface
  10. * @see \Drupal\devel\DevelDumperPluginManager
  11. * @see plugin_api
  12. */
  13. abstract class DevelDumperBase extends PluginBase implements DevelDumperInterface {
  14. /**
  15. * {@inheritdoc}
  16. */
  17. public function dump($input, $name = NULL) {
  18. echo (string) $this->export($input, $name);
  19. }
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function exportAsRenderable($input, $name = NULL) {
  24. return ['#markup' => $this->export($input, $name)];
  25. }
  26. /**
  27. * Wrapper for \Drupal\Core\Render\Markup::create().
  28. *
  29. * @param string $input
  30. * The input string to mark as safe.
  31. *
  32. * @return string
  33. * The unaltered input value.
  34. */
  35. protected function setSafeMarkup($input) {
  36. return FilteredMarkup::create($input);
  37. }
  38. }