/** * Returns a form element for the given overrides. * * @param array $package * A package array. * @param array $overrides * An array of overrides. * @param array $missing * An array of missing config. * * @return array * A form element. */ protected function diffOutput($package, $overrides, $missing = array()) { $element = array(); $config = $this->featuresManager->getConfigCollection(); $components = array_merge($missing, $overrides); $header = array( array('data' => '', 'class' => 'diff-marker'), array('data' => t('Active site config'), 'class' => 'diff-context'), array('data' => '', 'class' => 'diff-marker'), array('data' => t('Feature code config'), 'class' => 'diff-context'), ); foreach ($components as $name) { $rows[] = array(array('data' => $name, 'colspan' => 4, 'header' => TRUE)); if (!isset($config[$name])) { $details = array( '#markup' => t('Component in feature missing from active config.'), ); } else { $active = $this->featuresManager->getActiveStorage()->read($name); $extension = $this->featuresManager->getExtensionStorage()->read($name); if (empty($extension)) { $details = array( '#markup' => t('Dependency detected in active config but not exported to the feature.'), ); } else { $diff = $this->configDiff->diff($active, $extension); $details = array( '#type' => 'table', '#header' => $header, '#rows' => $this->diffFormatter->format($diff), '#attributes' => array('class' => array('diff', 'features-diff')), ); } } $element[$name] = array( 'row' => array( 'data' => array( '#type' => 'details', '#title' => SafeMarkup::checkPlain($name), '#open' => TRUE, '#description' => array( 'data' => $details, ), ), ), '#attributes' => array( 'class' => 'diff-' . $package['machine_name'], ), ); } return $element; }
/** * Shows the diff between active and provided configuration. * * @param string $config_type * The type of configuration. * @param string $config_name * The name of the config item, without the prefix. * * @return array * Render array for page showing differences between them. */ public function diff($config_type, $config_name) { $diff = $this->configDiff->diff($this->configRevert->getFromExtension($config_type, $config_name), $this->configRevert->getFromActive($config_type, $config_name)); $build = array(); $definition = $this->configList->getType($config_type); $config_type_label = $definition ? $definition->getLabel() : $this->t('Simple configuration'); $build['#title'] = $this->t('Config difference for @type @name', array('@type' => $config_type_label, '@name' => $config_name)); $build['#attached']['library'][] = 'system/diff'; $build['diff'] = array('#type' => 'table', '#header' => array(array('data' => $this->t('Source config'), 'colspan' => '2'), array('data' => $this->t('Site config'), 'colspan' => '2')), '#rows' => $this->diffFormatter->format($diff), '#attributes' => array('class' => array('diff'))); $url = new Url('config_update_ui.report'); $build['back'] = array('#type' => 'link', '#attributes' => array('class' => array('dialog-cancel')), '#title' => $this->t("Back to 'Updates report' page."), '#url' => $url); return $build; }