Skip to content
Snippets Groups Projects
Commit c7726e8c authored by git's avatar git Committed by Miro Dietiker
Browse files

Issue #2808993 by ModernMantra, yongt9412: Remove content type diff view mode setting

parent ccf59b8b
No related branches found
No related tags found
No related merge requests found
......@@ -43,16 +43,6 @@ diff.settings:
sequence:
- type: integer
label: 'Compare base field'
content_type_settings:
type: sequence
label: 'Content type settings'
sequence:
type: mapping
label: 'Content type'
mapping:
view_mode:
type: string
label: 'View mode'
diff.plugins:
type: config_object
......
......@@ -142,3 +142,12 @@ function diff_update_8008() {
$config->set('general_settings.visual_inline_theme', 'default');
$config->save();
}
/**
* Remove content type settings.
*/
function diff_update_8009() {
$config = \Drupal::configFactory()->getEditable('diff.settings');
$config->clear('content_type_settings');
$config->save();
}
......@@ -7,57 +7,6 @@
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_form_BASE_FORM_ID_alter().
*/
function diff_form_node_type_edit_form_alter(&$form, FormStateInterface $form_state) {
// @todo Follow this issue: https://www.drupal.org/node/1728788.
$type = $form_state->getFormObject()->getEntity();
if ($type->id()) {
$config = \Drupal::configFactory()->get('diff.settings');
$form['diff'] = array(
'#title' => t('Compare revisions'),
'#type' => 'details',
'#group' => 'additional_settings',
'#tree' => FALSE,
);
$options = array();
// Get all view modes for node entity type.
/* @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_service */
$entity_display_service = \Drupal::service('entity_display.repository');
$node_view_modes = $entity_display_service->getViewModes('node');
foreach ($node_view_modes as $view_mode => $view_mode_info) {
$options[$view_mode] = $view_mode_info['label'];
}
$form['diff']['view_mode'] = array(
'#type' => 'select',
'#title' => t('View mode to use to compare revisions'),
'#description' => t('This view mode will be used to compare revisions. You can select which fields should be shown at the Manage display tab.'),
'#options' => $options,
'#weight' => 13,
'#default_value' => $config->get('content_type_settings.' . $type->id() . '.view_mode'),
'#empty_value' => '',
);
$form['actions']['submit']['#submit'][] = 'diff_form_node_type_form_submit';
}
}
/**
* Submit handler for forms with menu options.
*
* @see diff_form_node_type_edit_form_alter().
*/
function diff_form_node_type_form_submit(&$form, $form_state) {
$type = $form_state->getFormObject()->getEntity();
\Drupal::configFactory()->getEditable('diff.settings')
->set('content_type_settings.' . $type->id() . '.view_mode', $form_state->getValue('view_mode'))
->save();
}
/**
* Implements hook_help().
*/
......
......@@ -153,12 +153,7 @@ class DiffBuilderManager extends DefaultPluginManager {
// If entity is set load its form display settings.
if ($bundle) {
$storage = $this->entityTypeManager->getStorage('entity_form_display');
$view_mode = $this->config->get('content_type_settings.' . $bundle . '.view_mode');
// If no view mode is selected use the default view mode.
if ($view_mode == NULL) {
$view_mode = 'default';
}
if ($display = $storage->load($field_definition->getTargetEntityTypeId() . '.' . $bundle . '.' . $view_mode)) {
if ($display = $storage->load($field_definition->getTargetEntityTypeId() . '.' . $bundle . '.default')) {
$visible = (bool) $display->getComponent($field_definition->getName());
}
}
......
......@@ -96,17 +96,6 @@ class AdminFormsTest extends DiffTestBase {
$this->assertText('Your settings have been saved.');
}
/**
* Tests the Compare Revisions vertical tab.
*/
public function testCompareRevisionsTab() {
$edit = [
'view_mode' => 'full',
];
$this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type'));
$this->assertText('The content type Article has been updated.');
}
/**
* Tests the Compare Revisions vertical tab.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment