You are here

public function ModifierIndex::rebuild in Persistent URL 8

File

src/Plugin/ModifierIndex.php, line 69

Class

ModifierIndex

Namespace

Drupal\purl\Plugin

Code

public function rebuild($providerId = null, $immediately = false) {
  if ($immediately) {
    if (!$providerId) {
      throw new \BadMethodCallException('A provider must be specified during immediate rebuilds.');
    }
    $provider = $this->providerManager
      ->getProvider($providerId);
    $definition = $this->providerManager
      ->getDefinition($providerId);
    if (!$definition['method']) {
      return;
    }
    $this
      ->indexModifiers($providerId, $definition['method']);
  }
  else {
    $statement = $this->connection
      ->update('purl_providers_settings')
      ->fields(array(
      'rebuild' => 1,
    ));
    if ($providerId) {
      $statement
        ->condition('provider', $providerId);
    }
    $statement
      ->execute();
  }
}