You are here

public function Tracker::setConfiguration in Menu Entity Index 8

Sets configuration values and triggers rescanning of menus as needed.

Updates the tracker service configuration with the new values. If menus or entity types are to be removed, database records will be deleted as needed. If menus or entity types are added, a batch process will be initiated to rescan and add database records for menu links as needed.

Parameters

array $form_values: The submitted form values of the configuration form.

bool $force_rebuild: Whether or not to force a rebuild for all menu's.

Overrides TrackerInterface::setConfiguration

File

src/Tracker.php, line 229

Class

Tracker
Tracks menu links and their referenced entities.

Namespace

Drupal\menu_entity_index

Code

public function setConfiguration(array $form_values = [], $force_rebuild = FALSE) {
  $entity_type_ids = !empty($form_values['entity_types']) ? array_filter($form_values['entity_types']) : [];
  $force = $force_rebuild || $this
    ->setTrackedEntityTypes($entity_type_ids);
  if ($form_values['all_menus']) {
    $this
      ->setTrackAllMenus($force);
  }
  elseif (!empty($form_values['menus'])) {
    $menus = array_filter($form_values['menus']);
    $this
      ->setTrackedMenus($menus, $force);
  }

  // Clear views table data cache.
  if (is_object($this->viewsData)) {
    $this->viewsData
      ->clear();
  }
}