diff --git a/core/lib/Drupal/Core/Batch/Batch.php b/core/lib/Drupal/Core/Batch/Batch.php index 03ee311..32a5ff0 100644 --- a/core/lib/Drupal/Core/Batch/Batch.php +++ b/core/lib/Drupal/Core/Batch/Batch.php @@ -75,11 +75,11 @@ class Batch { protected $file; /** - * An array of CSS file to be included when processing the batch. + * An array of libraries to be included when processing the batch. * - * @var array + * @var string[] */ - protected $css = []; + protected $libraries = []; /** * An array of options to be used with the redirect URL. @@ -182,13 +182,8 @@ public static function createFromArray(array $batch_definition) { $new_batch->setFile($batch_definition['file']); } - if (isset($batch_definition['css'])) { - if (is_array($batch_definition['css'])) { - $new_batch->setCss($batch_definition['css']); - } - else { - $new_batch->addCss($batch_definition['css']); - } + if (isset($batch_definition['library'])) { + $new_batch->addLibraries($batch_definition['library']); } if (isset($batch_definition['url_options'])) { @@ -298,18 +293,19 @@ public function setFile($filename) { } /** - * Sets the location of CSS files. + * Sets the libraries to use when processing the batch. * - * Adds the CSS files for use on the progress page. Any previously added CSS - * files are removed. Use \Drupal\Core\Batch\Batch::addCss() to add a file. + * Adds the libraries for use on the progress page. Any previously added + * libraries are removed. Use \Drupal\Core\Batch\Batch::addLibraries() to add + * one or more libraries. * - * @param string[] $filenames - * The CSS files to be used. + * @param string[] $libraries + * The libraries to be used. * * @return $this */ - public function setCss(array $filenames) { - $this->css = $filenames; + public function setLibraries(array $libraries) { + $this->libraries = $libraries; return $this; } @@ -387,15 +383,18 @@ public function addOperation($callback, array $arguments = []) { } /** - * Adds a CSS file to be used on the process page. + * Adds libraries to be used on the process page. * - * @param string $filename - * The CSS file to use. + * @param string|string[] $libraries + * The libraries to add. * * @return $this */ - public function addCss($filename) { - $this->css[] = $filename; + public function addLibraries($libraries) { + if (!is_array($libraries)) { + $libraries = [$libraries]; + } + $this->libraries = $this->libraries + $libraries; return $this; } @@ -429,7 +428,7 @@ public function toArray() { 'error_message' => $this->errorMessage ?: '', 'finished' => $this->finished, 'file' => $this->file, - 'css' => $this->css ?: [], + 'library' => $this->libraries ?: [], 'url_options' => $this->urlOptions ?: [], 'progressive' => $this->progressive, 'queue' => $this->queue ?: NULL,