Problem/Motivation

When trying to get the dynamically generated CSS on a site without the language module installed I get:

The website encountered an unexpected error. Please try again later.<br /><em class="placeholder">TypeError</em>: Drupal\background_image\Controller\BackgroundImageCssController::deliver(): Argument #4 ($language) must be of type Drupal\Core\Language\Language, string given 

This happens because the function expects a Language entity to be passed in, which it does not exist.

Proposed resolution

This is essentially a hidden dependency on the language module. In order to not force the sites to install it if it is not needed otherwise I'd suggest that we accept a string parameter instead.

CommentFileSizeAuthor
#2 3370488_2.patch2.74 KBslashrsm

Comments

slashrsm created an issue. See original summary.

slashrsm’s picture

StatusFileSize
new2.74 KB
slashrsm’s picture

Status: Active » Needs review
gmaximus’s picture

I've tested this on the dev branch.

I also had to change line 206 of the controller to $css_minifier->addLicense($data, preg_replace('/\.min\.css$/', '.css', \Drupal::service('file_url_generator')->generateAbsoluteString($uri)));

Otherwise I was getting this error:

Error: Call to undefined function Drupal\background_image\Controller\file_create_url() in Drupal\background_image\Controller\BackgroundImageCssController->buildCss() (line 206 of \background_image\src\Controller\BackgroundImageCssController.php).

The file_create_url() method is deprecated. See this: https://www.drupal.org/node/2940031

Thanks for your patch. I've been stuck on this for a couple of days.

nigelcunningham’s picture

Status: Needs review » Fixed

Thanks for the report.

I saw this too today and have committed the same change; it is working for me now on the dev branch. I hope to make a new release shortly. If you have any further issues, please let me know.

Thanks again!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.