You are here

function search_api_exclude_form_node_type_form_builder in Search API exclude 8

Entity builder for the node type form with search_api_exclude options.

See also

search_api_exclude_form_node_type_form_alter()

1 string reference to 'search_api_exclude_form_node_type_form_builder'
search_api_exclude_form_node_type_form_alter in ./search_api_exclude.module
Implements hook_form_FORM_ID_alter().

File

./search_api_exclude.module, line 81
Allows users to exclude specific nodes from indexing by Search API.

Code

function search_api_exclude_form_node_type_form_builder($entity_type, NodeTypeInterface $type, &$form, FormStateInterface $form_state) {
  $newValue = $form_state
    ->getValue('search_api_exclude_enabled');
  if ($type
    ->getThirdPartySetting('search_api_exclude', 'enabled') !== $newValue) {
    \Drupal::messenger()
      ->addMessage(t('For the changes to have effect, please @link.', [
      '@link' => Link::createFromRoute(t('reindex all items'), 'search_api.overview')
        ->toString(),
    ]));
  }
  $type
    ->setThirdPartySetting('search_api_exclude', 'enabled', $newValue);
}