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.
Comments
Comment #2
slashrsm commentedComment #3
slashrsm commentedComment #4
gmaximus commentedI'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.
Comment #5
nigelcunningham commentedThanks 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!