You are here

function _cms_content_sync_add_version_mismatches_form in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x cms_content_sync.module \_cms_content_sync_add_version_mismatches_form()
  2. 2.0.x cms_content_sync.module \_cms_content_sync_add_version_mismatches_form()

Add a button "Show version mismatches" to show all sites using a different entity type version.

Parameters

array $form:

1 call to _cms_content_sync_add_version_mismatches_form()
cms_content_sync_form_alter in ./cms_content_sync.module
1) Make sure the user is informed that content will not only be deleted on this * instance but also on all connected instances if configured that way.

File

./cms_content_sync.module, line 722
Module file for cms_content_sync.

Code

function _cms_content_sync_add_version_mismatches_form(&$form, $form_state) {
  _cms_content_sync_add_form_group($form);

  // Only add the button for users having the permission
  // "show entity type differences".
  $user = Drupal::currentUser();
  if ($user
    ->hasPermission('show entity type differences')) {

    /**
     * @var \Drupal\Core\Entity\EntityInterface $entity
     */
    $entity = $form_state
      ->getFormObject()
      ->getEntity();
    $form['cms_content_sync_group']['cms_content_sync_version_mismatches'] = [
      '#type' => 'button',
      '#prefix' => '<span id="cms-content-sync-version-mismatches">',
      '#suffix' => '</span>',
      '#value' => t('Show version mismatches'),
      '#entity_type' => $entity
        ->getEntityTypeId(),
      '#bundle' => $entity
        ->bundle(),
      '#recursive' => TRUE,
      '#ajax' => [
        'callback' => '_cms_content_sync_display_version_mismatches',
        'wrapper' => 'cms-content-sync-version-mismatches',
        'effect' => 'fade',
      ],
    ];
  }
}