You are here

function content_sync_help in Content Synchronization 3.0.x

Same name and namespace in other branches
  1. 8.2 content_sync.module \content_sync_help()
  2. 8 content_sync.module \content_sync_help()

Implements hook_help().

File

./content_sync.module, line 18
Allows site administrators to modify content.

Code

function content_sync_help($route_name, RouteMatchInterface $route_match) {

  // Get path from route match.
  $path = preg_replace('/^' . preg_quote(base_path(), '/') . '/', '/', Url::fromRouteMatch($route_match)
    ->setAbsolute(FALSE)
    ->toString());
  if (!in_array($route_name, [
    'system.modules_list',
  ]) && strpos($route_name, 'help.page.content_sync') === FALSE && strpos($path, '/content') === FALSE) {
    return NULL;
  }

  /** @var \Drupal\content_sync\ContentSyncHelpManagerInterface $help_manager */
  $help_manager = \Drupal::service('content_sync.help_manager');
  if ($route_name == 'help.page.content_sync') {
    $build = $help_manager
      ->buildIndex();
  }
  else {
    $build = $help_manager
      ->buildHelp($route_name, $route_match);
  }
  if ($build) {
    $renderer = \Drupal::service('renderer');
    $config = \Drupal::config('content_sync.settings');
    $renderer
      ->addCacheableDependency($build, $config);
    return $build;
  }
  else {
    return NULL;
  }
  switch ($route_name) {
    case 'help.page.content_sync':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('The Content Synchronization module provides a user interface for importing and exporting content changes between installations of your website in different environments. Content is stored in YAML format. For more information, see the <a href=":url">online documentation for the Content Synchronization module</a>.', [
        ':url' => 'https://www.drupal.org/project/content_sync',
      ]) . '</p>';
      $output .= '<h3>' . t('Uses') . '</h3>';
      $output .= '<dl>';
      $output .= '<dt>' . t('Exporting the full content') . '</dt>';
      $output .= '<dd>' . t('You can create and download an archive consisting of all your site\'s content exported as <em>*.yml</em> files on the <a href=":url">Export</a> page.', [
        ':url' => \Drupal::url('content.export_full'),
      ]) . '</dd>';
      $output .= '<dt>' . t('Importing a full content') . '</dt>';
      $output .= '<dd>' . t('You can upload a full site content from an archive file on the <a href=":url">Import</a> page. When importing data from a different environment, the site and import files must have matching configuration values for UUID in the <em>system.site</em> configuration item. That means that your other environments should initially be set up as clones of the target site.', [
        ':url' => \Drupal::url('content.import_full'),
      ]) . '</dd>';
      $output .= '<dt>' . t('Exporting a single content item') . '</dt>';
      $output .= '<dd>' . t('You can export a single content item by selecting a <em>Content type</em> and <em>Content name</em> on the <a href=":single-export">Single export</a> page. The content and its corresponding <em>*.yml file name</em> are then displayed on the page for you to copy.', [
        ':single-export' => \Drupal::url('content.export_single'),
      ]) . '</dd>';
      $output .= '<dt>' . t('Importing a single content item') . '</dt>';
      $output .= '<dd>' . t('You can import a single content item by pasting it in YAML format into the form on the <a href=":single-import">Single import</a> page.', [
        ':single-import' => \Drupal::url('content.import_single'),
      ]) . '</dd>';
      $output .= '<dt>' . t('Synchronizing content') . '</dt>';
      $output .= '<dd>' . t('You can review differences between the active content and an imported content archive on the <a href=":synchronize">Synchronize</a> page to ensure that the changes are as expected, before finalizing the import. The <a href=":synchronize">Synchronize</a>Synchronize</a> page also shows content items that would be added or removed.', [
        ':synchronize' => \Drupal::url('content.sync'),
      ]) . '</dd>';
      $output .= '<dt>' . t('Content logs') . '</dt>';
      $output .= '<dd>' . t('You can view a chronological list of recorded events containing errors, warnings and operational information of the content import, export and synchronization on the <a href=":content-logs">Logs</a> page.', [
        ':content-logs' => \Drupal::url('content.overview'),
      ]) . '</dd>';
      $output .= '<dt>' . t('Content synchronization settings') . '</dt>';
      $output .= '<dd>' . t('You can set specific settings for the content synchronization behavior as ignore the UUID Site validation and more on the <a href=":settings">Settings</a> page.', [
        ':settings' => \Drupal::url('content.settings'),
      ]) . '</dd>';
      $output .= '</dl>';

    //return $output;
    case 'content.export_full':
      $output = '';
      $output .= '<p>' . t('Export and download the full content of this site as a gzipped tar file.') . '</p>';
      return $output;
    case 'content.import_full':
      $output = '';
      $output .= '<p>' . t('Upload a full site content archive to the content sync directory to be imported.') . '</p>';
      return $output;
    case 'content.export_single':
      $output = '';
      $output .= '<p>' . t('Choose a content item to display its YAML structure.') . '</p>';
      return $output;
    case 'content.import_single':
      $output = '';
      $output .= '<p>' . t('Import a single content item by pasting its YAML structure into the text field.') . '</p>';
      return $output;
    case 'content.sync':
      $output = '';
      $output .= '<p>' . t('Compare the content uploaded to your content sync directory with the active content before completing the import.') . '</p>';
      return $output;
    case 'content.settings':
      $output = '';
      $output .= '<p>' . t('Set specific settings for the content synchronization behavior.') . '</p>';
      return $output;
    case 'content.overview':
      $output = '';
      $output .= '<p>' . t('chronological list of recorded events containing errors, warnings and operational information of the content import, export and synchronization.') . '</p>';
      return $output;
  }
}