You are here

function _cms_content_sync_add_usage_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_usage_form()
  2. 2.0.x cms_content_sync.module \_cms_content_sync_add_usage_form()

Add a button "Show usage" to show all sites using this content.

Parameters

array $form:

\Drupal\Core\Entity\EntityInterface $entity:

1 call to _cms_content_sync_add_usage_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 817
Module file for cms_content_sync.

Code

function _cms_content_sync_add_usage_form(&$form, $entity) {
  _cms_content_sync_add_form_group($form);
  $used = EntityStatus::getLastPushForEntity($entity);
  if (!$used) {
    $used = EntityStatus::getLastPullForEntity($entity);
  }
  if ($used) {
    $form['cms_content_sync_group']['cms_content_sync_usage'] = [
      '#type' => 'button',
      '#prefix' => '<span id="cms-content-sync-usage">',
      '#suffix' => '</span>',
      '#value' => t('Show usage'),
      '#ajax' => [
        'callback' => '_cms_content_sync_display_usage',
        'wrapper' => 'cms-content-sync-usage',
        'effect' => 'fade',
      ],
    ];
  }
}