You are here

function xmlsitemap_add_link_bundle_settings in XML sitemap 8

Same name and namespace in other branches
  1. 6.2 xmlsitemap.admin.inc \xmlsitemap_add_link_bundle_settings()
  2. 7.2 xmlsitemap.admin.inc \xmlsitemap_add_link_bundle_settings()
  3. 2.x xmlsitemap.module \xmlsitemap_add_link_bundle_settings()

Add the link type XML sitemap options to the link type's form.

Caller is responsible for ensuring xmlsitemap_link_bundle_settings_save() is called during submission.

Parameters

array $form: Form array.

Drupal\Core\Form\FormStateInterface $form_state: Form state array.

string $entity: Entity type id.

string $bundle: Bundle id.

1 call to xmlsitemap_add_link_bundle_settings()
XmlSitemapLinkBundleSettingsForm::buildForm in src/Form/XmlSitemapLinkBundleSettingsForm.php
Form constructor.

File

./xmlsitemap.module, line 2130
xmlsitemap XML sitemap

Code

function xmlsitemap_add_link_bundle_settings(array &$form, FormStateInterface $form_state, $entity, $bundle) {
  $entity_info = xmlsitemap_get_link_info($entity);
  $bundle_info = xmlsitemap_link_bundle_load($entity, $bundle);
  $form['xmlsitemap'] = [
    '#type' => 'details',
    '#title' => t('XML sitemap'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#access' => \Drupal::currentUser()
      ->hasPermission('administer xmlsitemap'),
    '#group' => 'advanced',
    '#tree' => TRUE,
    '#entity' => $entity,
    '#bundle' => $bundle,
    '#entity_info' => $entity_info,
    '#bundle_info' => $bundle_info,
  ];
  $form['xmlsitemap']['description'] = [
    '#prefix' => '<div class="description">',
    '#suffix' => '</div>',
    '#markup' => t('Changing these type settings will affect any items of this type that have either inclusion or priority set to default.'),
  ];
  $form['xmlsitemap']['status'] = [
    '#type' => 'select',
    '#title' => t('Inclusion'),
    '#options' => xmlsitemap_get_status_options(),
    '#default_value' => (int) $bundle_info['status'],
  ];
  $form['xmlsitemap']['priority'] = [
    '#type' => 'select',
    '#title' => t('Default priority'),
    '#options' => xmlsitemap_get_priority_options(),
    '#default_value' => $bundle_info['priority'],
    '#states' => [
      'invisible' => [
        'select[name="xmlsitemap[status]"]' => [
          'value' => '0',
        ],
      ],
    ],
  ];
  $form['xmlsitemap']['changefreq'] = [
    '#type' => 'select',
    '#title' => t('Default change frequency'),
    '#options' => xmlsitemap_get_changefreq_options(),
    '#default_value' => $bundle_info['changefreq'],
    '#states' => [
      'invisible' => [
        'select[name="xmlsitemap[status]"]' => [
          'value' => '0',
        ],
      ],
    ],
  ];
}