You are here

function xmlsitemap_process_form_link_options in XML sitemap 8

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

Submit callback for the entity form to save.

1 string reference to 'xmlsitemap_process_form_link_options'
xmlsitemap_add_form_link_options in ./xmlsitemap.module
Add a link's XML sitemap options to the link's form.

File

./xmlsitemap.module, line 1298
xmlsitemap XML sitemap

Code

function xmlsitemap_process_form_link_options(array $form, FormStateInterface $form_state) {
  $link = $form_state
    ->getValue('xmlsitemap');
  $fields = [
    'status' => XMLSITEMAP_STATUS_DEFAULT,
    'priority' => XMLSITEMAP_PRIORITY_DEFAULT,
  ];
  foreach ($fields as $field => $default) {
    if ($link[$field] === 'default') {
      $link[$field] = isset($link[$field . '_default']) ? $link[$field . '_default'] : $default;
      $link[$field . '_override'] = 0;
    }
    else {
      $link[$field . '_override'] = 1;
    }
  }
  $form_state
    ->setValue('xmlsitemap', $link);
  $entity = $form_state
    ->getFormObject()
    ->getEntity();
  $entity->xmlsitemap = $form_state
    ->getValue('xmlsitemap');
}