You are here

public static function Schemas::batchFinished in Express 8

Batch 'finished' callback

Parameters

bool $success: A boolean indicating whether the batch has completed successfully.

array $results: The value(s) set in $context['results'] in \Drupal\bootstrap\Plugin\Setting\Update::batchProcess().

$operations: If $success is FALSE, contains the operations that remained unprocessed.

File

themes/contrib/bootstrap/src/Plugin/Setting/Schemas.php, line 190
Contains \Drupal\bootstrap\Plugin\Setting\Schemas.

Class

Schemas
The "schemas" theme setting.

Namespace

Drupal\bootstrap\Plugin\Setting

Code

public static function batchFinished($success, $results, $operations) {

  /** @type \Drupal\bootstrap\Theme $theme */

  // Reconstruct the theme object this update is being applied to.
  $theme = Bootstrap::getTheme($results['theme_name']);

  // Save the current state of the installed schemas.
  $theme
    ->setSetting('schemas', $results['schemas']);

  // Show successful updates.
  if (!empty($results['success'])) {
    $list = Element::createStandalone([
      '#theme' => 'item_list__theme_update',
      '#items' => $results['success'],
      '#context' => [
        'type' => 'success',
      ],
    ]);
    drupal_set_message(new FormattableMarkup('@message' . $list
      ->renderPlain(), [
      '@message' => t('Successfully completed the following theme updates:'),
    ]));
  }

  // Show failed errors.
  if (!empty($results['errors'])) {
    $list = Element::createStandalone([
      '#theme' => 'item_list__theme_update',
      '#items' => $results['errors'],
      '#context' => [
        'type' => 'errors',
      ],
    ]);
    drupal_set_message(new FormattableMarkup('@message' . $list
      ->renderPlain(), [
      '@message' => t('The following theme updates could not be completed:'),
    ]), 'error');
  }
}