Пример #1
0
 /**
  * Format config schema as list table.
  *
  * @param string $config_name
  *   The config name.
  * @param array|object $config_schema
  *   An array of config elements with key.
  *
  * @return array
  *   The list table as a render array.
  */
 protected function formatList($config_name, $config_schema)
 {
     $rows = array();
     $errors = (array) $this->configInspectorManager->checkValues($config_name);
     $schema = $this->configInspectorManager->convertConfigElementToList($config_schema);
     foreach ($schema as $key => $element) {
         $definition = $element->getDataDefinition();
         $rows[] = array('class' => isset($errors[$config_name . ':' . $key]) ? array('config-inspector-error') : array(), 'data' => array(array('class' => array('icon'), 'data' => ''), $key, $definition['label'], $definition['type'], $this->formatValue($element), @$errors[$config_name . ':' . $key] ?: ''));
     }
     return array('#attached' => array('library' => array('config_inspector/config_inspector')), '#type' => 'table', '#header' => array('', t('Name'), t('Label'), t('Type'), t('Value'), t('Error')), '#rows' => $rows);
 }
Пример #2
0
 /**
  * Format config schema as list table.
  */
 protected function formatList($config_name, $config_schema)
 {
     $rows = array();
     $errors = (array) $this->configInspectorManager->checkValues($config_name);
     $schema = $this->configInspectorManager->convertConfigElementToList($config_schema);
     foreach ($schema as $key => $element) {
         $definition = $element->getDataDefinition();
         // Define the 'VALUE' column element of the table.
         // A special case is required for Mapping and Sequence as there is no getString() method.
         switch (get_class($element)) {
             case 'Drupal\\Core\\Config\\Schema\\Mapping':
             case 'Drupal\\Core\\Config\\Schema\\Sequence':
                 $value = $element->getValue();
                 $value = empty($value) ? '<empty>' : '<see below>';
                 break;
             default:
                 $value = $element->getString();
         }
         $rows[] = array('class' => isset($errors[$config_name . ':' . $key]) ? array('config-inspector-error') : array(), 'data' => array(array('class' => array('icon'), 'data' => ''), $key, $definition['label'], $definition['type'], $value, @$errors[$config_name . ':' . $key] ?: ''));
     }
     return array('#attached' => array('css' => array(drupal_get_path('module', 'config_inspector') . '/css/config_inspector.css')), '#type' => 'table', '#header' => array('', t('Name'), t('Label'), t('Type'), t('Value'), t('Error')), '#rows' => $rows);
 }