Skip to content

Commit

Permalink
CS
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Oct 9, 2020
1 parent 4f30e2f commit 6f0b976
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
10 changes: 2 additions & 8 deletions core-bundle/src/Image/Studio/ImageResult.php
Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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.');
Expand All @@ -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();
Expand Down
7 changes: 1 addition & 6 deletions core-bundle/tests/Image/Studio/ImageResultTest.php
Expand Up @@ -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) {
Expand Down Expand Up @@ -408,7 +405,6 @@ public function testCreateIfDeferredDoesNotFailWithoutDeferredResizerIfThereAreN
;

$imageResult = new ImageResult($locator, '/project/dir', '/project/dir/image.jpg');

$imageResult->createIfDeferred();
}

Expand All @@ -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) {
Expand Down

0 comments on commit 6f0b976

Please sign in to comment.