You are here

public function SimpleSitemapQueue::createItems in Simple XML sitemap 4.x

Same name and namespace in other branches
  1. 8.3 src/Queue/SimplesitemapQueue.php \Drupal\simple_sitemap\Queue\SimplesitemapQueue::createItems()

File

src/Queue/SimpleSitemapQueue.php, line 76

Class

SimpleSitemapQueue
Class SimpleSitemapQueue

Namespace

Drupal\simple_sitemap\Queue

Code

public function createItems($data_sets) {
  $try_again = FALSE;
  try {
    $id = $this
      ->doCreateItems($data_sets);
  } catch (\Exception $e) {

    // If there was an exception, try to create the table.
    if (!($try_again = $this
      ->ensureTableExists())) {

      // If the exception happened for other reason than the missing table,
      // propagate the exception.
      throw $e;
    }
  }

  // Now that the table has been created, try again if necessary.
  if ($try_again) {
    $id = $this
      ->doCreateItems($data_sets);
  }
  return $id;
}