diff --git a/core-bundle/src/Image/Studio/ImageResult.php b/core-bundle/src/Image/Studio/ImageResult.php index 09d86d9869c..b6982d8618b 100644 --- a/core-bundle/src/Image/Studio/ImageResult.php +++ b/core-bundle/src/Image/Studio/ImageResult.php @@ -146,7 +146,7 @@ public function getFilePath($absolute = false): string } /** - * Synchronously process images if they are deferred. + * Synchronously processes images if they are deferred. * * This will make sure that the target files physically exist instead of * being generated by the Contao\CoreBundle\Controller\ImagesController @@ -155,7 +155,6 @@ public function getFilePath($absolute = false): string public function createIfDeferred(): void { $picture = $this->getPicture(); - $candidates = []; foreach (array_merge([$picture->getImg()], $picture->getSources()) as $source) { @@ -177,7 +176,7 @@ static function ($image): bool { return; } - $resizer = $this->resizer(); + $resizer = $this->locator->get('contao.image.resizer'); if (!$resizer instanceof DeferredResizerInterface) { throw new \RuntimeException('The "contao.image.resizer" service does not support deferred resizing.'); @@ -198,11 +197,6 @@ private function pictureFactory(): PictureFactoryInterface return $this->locator->get('contao.image.picture_factory'); } - private function resizer(): ResizerInterface - { - return $this->locator->get('contao.image.resizer'); - } - private function staticUrl(): string { return $this->locator->get('contao.assets.files_context')->getStaticUrl(); diff --git a/core-bundle/tests/Image/Studio/ImageResultTest.php b/core-bundle/tests/Image/Studio/ImageResultTest.php index b8a946c1116..d886413473f 100644 --- a/core-bundle/tests/Image/Studio/ImageResultTest.php +++ b/core-bundle/tests/Image/Studio/ImageResultTest.php @@ -224,10 +224,7 @@ public function testCreateIfDeferred(array $img, array $sources, array $expected $deferredResizer = $this->createMock(DeferredResizerInterface::class); $deferredResizer - ->expects( - empty($expectedDeferredImages) ? - $this->never() : $this->atLeast(\count($expectedDeferredImages)) - ) + ->expects(empty($expectedDeferredImages) ? $this->never() : $this->atLeast(\count($expectedDeferredImages))) ->method('resizeDeferredImage') ->with($this->callback( static function ($deferredImage) use (&$expectedDeferredImages) { @@ -408,7 +405,6 @@ public function testCreateIfDeferredDoesNotFailWithoutDeferredResizerIfThereAreN ; $imageResult = new ImageResult($locator, '/project/dir', '/project/dir/image.jpg'); - $imageResult->createIfDeferred(); } @@ -434,7 +430,6 @@ private function getPictureFactoryMock($filePathOrImage, $sizeConfiguration, Pic private function getLocatorMock(?PictureFactoryInterface $pictureFactory = null, string $staticUrl = null) { $locator = $this->createMock(ContainerInterface::class); - $context = null; if (null !== $staticUrl) {