You are here

function simplify_get_fields in Simplify 8

Same name and namespace in other branches
  1. 7.3 simplify.module \simplify_get_fields()

Get an array of fields (by type) that can be hidden.

Parameters

string $type: The category type of fields to build.

Return value

array An array of cehckbox option fields.

5 calls to simplify_get_fields()
SimplifyAdminForm::buildForm in src/Form/SimplifyAdminForm.php
Form constructor.
simplify_form_block_content_type_edit_form_alter in ./simplify.module
Implements hook_form_FORM_ID_alter() for block_content_type_edit_form().
simplify_form_comment_type_edit_form_alter in ./simplify.module
Implements hook_form_FORM_ID_alter() for node_type_form().
simplify_form_node_type_edit_form_alter in ./simplify.module
Implements hook_form_FORM_ID_alter() for node_type_form().
simplify_form_taxonomy_vocabulary_form_alter in ./simplify.module
Implements hook_form_FORM_ID_alter() for taxonomy_form_vocabulary().

File

./simplify.module, line 384
Hooks implemented by the simplify module.

Code

function simplify_get_fields($type) {
  $fields = [];
  switch ($type) {

    // Nodes.
    case 'nodes':

      // Drupal core:
      $fields['author'] = t('Authoring information');
      $fields['format'] = t('Text format selection');
      $fields['options'] = t('Promotion options');
      $fields['revision_information'] = t('Revision information');
      if (\Drupal::moduleHandler()
        ->moduleExists('book')) {
        $fields['book'] = t('Book outline');
      }
      if (\Drupal::moduleHandler()
        ->moduleExists('comment')) {
        $fields['comment'] = t('Comment settings');
      }
      if (\Drupal::moduleHandler()
        ->moduleExists('menu_ui')) {
        $fields['menu'] = t('Menu settings');
      }
      if (\Drupal::moduleHandler()
        ->moduleExists('path')) {
        $fields['path_settings'] = t('URL path settings');
      }
      if (\Drupal::moduleHandler()
        ->moduleExists('content_translation')) {
        $fields['content_translation'] = t('Content translation');
      }

      // Third-party modules:
      if (\Drupal::moduleHandler()
        ->moduleExists('domain_access')) {
        $fields['domain'] = t('Domain access');
      }
      if (\Drupal::moduleHandler()
        ->moduleExists('entity_translation') && entity_translation_enabled('node')) {
        $fields['entity_translation'] = t('Entity translation');
      }
      if (\Drupal::moduleHandler()
        ->moduleExists('metatag')) {
        $fields['metatags'] = t('Meta tags');
      }
      if (\Drupal::moduleHandler()
        ->moduleExists('node_noindex')) {
        $fields['node_noindex'] = t('Node noindex');
      }
      if (\Drupal::moduleHandler()
        ->moduleExists('redirect')) {
        $fields['url_redirects'] = t('URL redirects');
      }
      if (\Drupal::moduleHandler()
        ->moduleExists('xmlsitemap')) {
        $fields['xmlsitemap'] = t('XML sitemap');
      }
      break;

    // Users.
    case 'users':

      // Drupal core:
      $fields['format'] = t('Text format selection');
      $fields['status'] = t('Status (blocked/active)');
      $fields['timezone'] = t('Locale settings');
      if (\Drupal::moduleHandler()
        ->moduleExists('contact')) {
        $fields['contact'] = t('Contact settings');
      }
      if (\Drupal::moduleHandler()
        ->moduleExists('overlay')) {
        $fields['overlay_control'] = t('Administrative overlay');
      }
      if (\Drupal::moduleHandler()
        ->moduleExists('content_translation')) {
        $fields['content_translation'] = t('Content translation');
      }
      if (\Drupal::moduleHandler()
        ->moduleExists('comment')) {
        $fields['comment'] = t('Comment settings');
      }

      // Third-party modules:
      if (\Drupal::moduleHandler()
        ->moduleExists('domain_access')) {
        $fields['domain'] = t('Domain access');
      }
      if (\Drupal::moduleHandler()
        ->moduleExists('metatag')) {
        $fields['metatags'] = t('Meta tags');
      }
      if (\Drupal::moduleHandler()
        ->moduleExists('redirect')) {
        $fields['url_redirects'] = t('URL redirects');
      }
      if (\Drupal::moduleHandler()
        ->moduleExists('xmlsitemap')) {
        $fields['xmlsitemap'] = t('XML sitemap');
      }
      break;

    // Comments.
    case 'comments':

      // Drupal core:
      $fields['format'] = t('Text format selection');
      break;

    // Taxonomy.
    case 'taxonomy':

      // Drupal core:
      $fields['format'] = t('Text format selection');
      $fields['relations'] = t('Relations');
      if (\Drupal::moduleHandler()
        ->moduleExists('path')) {
        $fields['path'] = t('URL alias');
      }
      if (\Drupal::moduleHandler()
        ->moduleExists('content_translation')) {
        $fields['content_translation'] = t('Content translation');
      }
      if (\Drupal::moduleHandler()
        ->moduleExists('comment')) {
        $fields['comment'] = t('Comment settings');
      }

      // Third-party modules:
      if (\Drupal::moduleHandler()
        ->moduleExists('metatag')) {
        $fields['metatags'] = t('Meta tags');
      }
      if (\Drupal::moduleHandler()
        ->moduleExists('redirect')) {
        $fields['url_redirects'] = t('URL redirects');
      }
      if (\Drupal::moduleHandler()
        ->moduleExists('xmlsitemap')) {
        $fields['xmlsitemap'] = t('XML sitemap');
      }
      break;

    // Blocks.
    case 'blocks':

      // Drupal core:
      $fields['format'] = t('Text format selection');
      $fields['revision_information'] = t('Revision information');
      break;

    // Profiles.
    case 'profiles':
      $fields['format'] = t('Text format selection');
      break;
  }

  // Allow other modules to alter the array of fields that can be hidden.
  \Drupal::moduleHandler()
    ->alter('simplify_get_fields', $fields, $type);
  return $fields;
}