You are here

public function XmlSitemapLinkBundleSettingsForm::buildForm in XML sitemap 2.x

Same name and namespace in other branches
  1. 8 src/Form/XmlSitemapLinkBundleSettingsForm.php \Drupal\xmlsitemap\Form\XmlSitemapLinkBundleSettingsForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

src/Form/XmlSitemapLinkBundleSettingsForm.php, line 70

Class

XmlSitemapLinkBundleSettingsForm
Configure what entities will be included in sitemap.

Namespace

Drupal\xmlsitemap\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, $entity = NULL, $bundle = NULL) {
  $this->entity_type = $entity;
  $this->bundle_type = $bundle;
  $request = $this
    ->getRequest();
  $form['#title'] = $this
    ->t('@bundle XML sitemap settings', [
    '@bundle' => $bundle,
  ]);
  xmlsitemap_add_link_bundle_settings($form, $form_state, $entity, $bundle);
  $form['xmlsitemap']['#type'] = 'markup';
  $form['xmlsitemap']['#value'] = '';
  $form['xmlsitemap']['#access'] = TRUE;
  $form['xmlsitemap']['#show_message'] = TRUE;
  $destination = $request
    ->get('destination');
  $form['actions']['cancel'] = [
    '#type' => 'link',
    '#title' => $this
      ->t('Cancel'),
    '#href' => isset($destination) ? $destination : 'admin/config/search/xmlsitemap/settings',
    '#weight' => 10,
  ];
  $form = parent::buildForm($form, $form_state);
  return $form;
}