You are here

protected function ConfigInspectorController::formatValue in Configuration Inspector 8

Formats a value as a string, for readable output.

Parameters

\Drupal\Core\TypedData\TypedDataInterface $element: The value element.

Return value

string The value in string form.

2 calls to ConfigInspectorController::formatValue()
ConfigInspectorController::formatList in src/Controller/ConfigInspectorController.php
Format config schema as list table.
ConfigInspectorController::formatTree in src/Controller/ConfigInspectorController.php
Format config schema as a tree.

File

src/Controller/ConfigInspectorController.php, line 399

Class

ConfigInspectorController
Defines a controller for the config_inspector module.

Namespace

Drupal\config_inspector\Controller

Code

protected function formatValue(TypedDataInterface $element) {
  $value = $element
    ->getValue();
  if (is_bool($value)) {
    return $value ? 'true' : 'false';
  }
  if (is_scalar($value)) {
    return $value;
  }
  if (empty($value)) {
    return '<' . $this
      ->t('empty') . '>';
  }
  return '<' . gettype($value) . '>';
}