You are here

function onlyone_help in Allow a content type only once (Only One) 8

Same name and namespace in other branches
  1. 7 onlyone.module \onlyone_help()

Implements hook_help().

File

./onlyone.module, line 19
Contains onlyone.module.

Code

function onlyone_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {

    // Main module help.
    case 'help.page.onlyone':

      // The route onlyone.add_page exists or not?
      if (\Drupal::service('config.factory')
        ->get('onlyone.settings')
        ->get('onlyone_new_menu_entry')) {

        // Creating the link.
        $onlyone_add_page_link = Link::fromTextAndUrl(t('Add content (Only One)'), Url::fromRoute('onlyone.add_page'))
          ->toString();
        $onlyone_add_page = t('@link page', [
          '@link' => $onlyone_add_page_link,
        ]);
      }
      else {

        // As the route doesn't exists we use a string.
        $onlyone_add_page = t('<em>Add content (Only One)</em> page (onlyone/add)');
      }

      // Array with routes to replace.
      $routes = [
        ':settings-page' => Url::fromRoute('onlyone.admin_settings')
          ->toString(),
        ':content' => Url::fromRoute('system.admin_content')
          ->toString(),
        '@onlyone_add_page' => $onlyone_add_page,
        ':add-content' => Url::fromRoute('node.add_page')
          ->toString(),
      ];

      // Getting the help link for the admin_toolbar module.
      $admin_toolbar_page = \Drupal::service('onlyone.module_handler')
        ->getModuleHelpPageLink('admin_toolbar', 'Admin Toolbar', TRUE);

      // Getting the help link for the admin_toolbar_tools module.
      $admin_toolbar_tools_page = \Drupal::service('onlyone.module_handler')
        ->getModuleHelpPageLink('admin_toolbar_tools', 'Admin Toolbar Extra Tools', TRUE);

      // Getting the help link for the onlyone_admin_toolbar module.
      $onlyone_admin_toolbar = \Drupal::service('onlyone.module_handler')
        ->getModuleHelpPageLink('onlyone_admin_toolbar', 'Allow a content type only once (Only One) for Admin Toolbar');
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('The Allow a content type only once (Only One) module allows the creation of Only One content per language in the selected content types for this configuration.') . '</p>';
      $output .= '<h3>' . t('Uses') . '</h3>';
      $output .= '<dl>';
      $output .= '<dt>' . t('Configuring content types') . '</dt>';
      $output .= '<dd>' . t('To configure the content types to allow for Only One content per language, visit the <a href=":config-page">Only One</a> page, in the <em>Available content types for Only One</em> section and <em>check</em> the content types that should have Only One content per language. For this you need the <em>Administer Only One</em> permission.', [
        ':config-page' => Url::fromRoute('onlyone.config_content_types')
          ->toString(),
      ]) . '</dd>';
      $output .= '<dt>' . t('Configuring module settings') . '</dt>';
      $output .= '<dd>' . t('To configure the module settings visit the <a href=":settings-page">Settings</a> page, if you want to have the configured content types in a new menu entry named <em>Add content (Only One)</em> you must check the option <em>Show configured content types in a new menu entry</em>, the new menu link will be available in the <a href=":content">Content</a> page as an action link to the @onlyone_add_page, then the <a href=":add-content">Add content</a> page will show the not configured content types. For this you need the <em>Administer Only One</em> permission.', $routes) . '</dd>';
      $output .= '<dt>' . t('Creating content') . '</dt>';
      $output .= '<dd>' . t('Once you try to <a href=":add-content">Add content</a>, if the chosen content type is configured to have Only One content and it already has one content created in the actual language, you will be redirected to <em>edit</em> the content, otherwise, you will go to create a new one.', [
        ':add-content' => Url::fromRoute('node.add_page')
          ->toString(),
      ]) . '</dd>';
      $output .= '</dl>';
      $output .= '<h3>' . t('Aditionals modules') . '</h3>';
      $output .= '<dl>';
      $output .= '<dt>' . $onlyone_admin_toolbar . '</dt>';
      $output .= '<dd>' . t('Very useful if you use the @admin_toolbar_page module as it handles modifications to the @admin_toolbar_tools_page module menu entries related to the configured content types.', [
        '@admin_toolbar_page' => $admin_toolbar_page,
        '@admin_toolbar_tools_page' => $admin_toolbar_tools_page,
      ]) . '</dd>';
      $output .= '</dl>';
      return $output;
  }
}