You are here

protected function BackgroundImageCssController::dump in Background Image 2.x

Same name and namespace in other branches
  1. 8 src/Controller/BackgroundImageCssController.php \Drupal\background_image\Controller\BackgroundImageCssController::dump()
  2. 2.0.x src/Controller/BackgroundImageCssController.php \Drupal\background_image\Controller\BackgroundImageCssController::dump()
1 call to BackgroundImageCssController::dump()
BackgroundImageCssController::buildCss in src/Controller/BackgroundImageCssController.php
Generates the necessary CSS for a background image.

File

src/Controller/BackgroundImageCssController.php, line 265

Class

BackgroundImageCssController
Defines a controller to serve image styles.

Namespace

Drupal\background_image\Controller

Code

protected function dump($data, $uri) {

  // Save the file.
  $this->fileSystem
    ->prepareDirectory($path, FileSystemInterface::CREATE_DIRECTORY);
  try {
    $this->fileSystem
      ->saveData($data, $uri, FileSystemInterface::EXISTS_REPLACE);

    // Create gzipped file.
    if ($this->gzip) {
      $this->fileSystem
        ->saveData(gzencode($data, 9, FORCE_GZIP), $uri . '.gz', FileSystemInterface::EXISTS_REPLACE);
    }
  } catch (FileWriteException $e) {
    $this->logger
      ->error($this
      ->t('Unable to create save the CSS file: @uri', [
      '@uri' => $uri,
    ]));
    return FALSE;
  } catch (FileException $e) {
    return FALSE;
  }
  return $uri;
}