public static function Schemas::updateTheme in Express 8
Callback for updating a theme.
Parameters
array $form: Nested array of form elements that comprise the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
File
- themes/
contrib/ bootstrap/ src/ Plugin/ Setting/ Schemas.php, line 90 - Contains \Drupal\bootstrap\Plugin\Setting\Schemas.
Class
- Schemas
- The "schemas" theme setting.
Namespace
Drupal\bootstrap\Plugin\SettingCode
public static function updateTheme(array $form, FormStateInterface $form_state) {
if ($theme = SystemThemeSettings::getTheme($form, $form_state)) {
// Due to the fact that the batch API stores it's arguments in DB storage,
// theme based objects cannot be passed as an operation argument here.
// During _batch_page(), the DB item will attempt to restore the arguments
// using unserialize() and the autoload fix include added below may not
// yet have been invoked to register the theme namespaces. So instead,
// we capture the relevant information needed to reconstruct these objects
// in the batch processing callback.
$theme_name = $theme
->getName();
// Create an operation for each update.
$operations = [];
foreach ($theme
->getPendingUpdates() as $update) {
$operations[] = [
[
__CLASS__,
'batchProcessUpdate',
],
[
$theme_name,
$update
->getProvider() . ':' . $update
->getSchema(),
],
];
}
if ($operations) {
$variables = [
'@theme_title' => $theme
->getTitle(),
];
batch_set([
'operations' => $operations,
'finished' => [
__CLASS__,
'batchFinished',
],
'title' => t('Updating @theme_title', $variables),
'init_message' => \Drupal::translation()
->formatPlural(count($operations), 'Initializing 1 theme update for @theme_title...', 'Initializing @count theme updates for @theme_title...', $variables),
'progress_message' => t('Processing update @current of @total...', $variables),
'error_message' => t('An error was encountered while attempting to update the @theme_title theme.', $variables),
'file' => Bootstrap::autoloadFixInclude(),
]);
}
}
}