Skip to content
Snippets Groups Projects
Commit f7ffcd73 authored by Dieter Holvoet's avatar Dieter Holvoet
Browse files

Fix 'hook_easy_responsive_images_image_style_alter(): Argument #1 ($entity)...

Fix 'hook_easy_responsive_images_image_style_alter(): Argument #1 ($entity) must be of type Drupal\image\ImageStyleInterface, null given'
parent c6b01ee9
No related branches found
No related merge requests found
......@@ -8,6 +8,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\image\ImageStyleInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......@@ -236,7 +237,6 @@ class GenerateImageStyles extends ConfigFormBase {
$name = 'responsive_' . $width . 'w';
$generated_styles[] = $name;
if (!$style = $image_style_storage->load($name)) {
/** @var \Drupal\image\ImageStyleInterface $style */
$style = $image_style_storage->create([
'name' => $name,
'label' => $name,
......@@ -250,6 +250,7 @@ class GenerateImageStyles extends ConfigFormBase {
],
]);
}
assert($style instanceof ImageStyleInterface);
$this->moduleHandler->alter('easy_responsive_images_image_style', $style);
$style->save();
}
......@@ -264,8 +265,7 @@ class GenerateImageStyles extends ConfigFormBase {
$height = ($width / $w) * $h;
$name = 'responsive_' . $w . '_' . $h . '_' . $width . 'w';
$generated_styles[] = $name;
if (!$image_style_storage->load($name)) {
/** @var \Drupal\image\ImageStyleInterface $style */
if (!$style = $image_style_storage->load($name)) {
$style = $image_style_storage->create([
'name' => $name,
'label' => $name,
......@@ -289,9 +289,10 @@ class GenerateImageStyles extends ConfigFormBase {
],
]);
}
$this->moduleHandler->alter('easy_responsive_images_image_style', $style);
$style->save();
}
assert($style instanceof ImageStyleInterface);
$this->moduleHandler->alter('easy_responsive_images_image_style', $style);
$style->save();
}
}
}
......@@ -307,7 +308,6 @@ class GenerateImageStyles extends ConfigFormBase {
$name = 'responsive_' . $height . 'h';
$generated_styles[] = $name;
if (!$style = $image_style_storage->load($name)) {
/** @var \Drupal\image\ImageStyleInterface $style */
$style = $image_style_storage->create([
'name' => $name,
'label' => $name,
......@@ -321,6 +321,7 @@ class GenerateImageStyles extends ConfigFormBase {
],
]);
}
assert($style instanceof ImageStyleInterface);
$this->moduleHandler->alter('easy_responsive_images_image_style', $style);
$style->save();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment