vendor/ezsystems/ezplatform-kernel/eZ/Publish/Core/Repository/Strategy/ContentThumbnail/ThumbnailChainStrategy.php line 16

Open in your IDE?
  1. <?php
  2. /**
  3.  * @copyright Copyright (C) Ibexa AS. All rights reserved.
  4.  * @license For full copyright and license information view LICENSE file distributed with this source code.
  5.  */
  6. declare(strict_types=1);
  7. namespace eZ\Publish\Core\Repository\Strategy\ContentThumbnail;
  8. use eZ\Publish\API\Repository\Values\Content\Thumbnail;
  9. use eZ\Publish\API\Repository\Values\Content\VersionInfo;
  10. use eZ\Publish\API\Repository\Values\ContentType\ContentType;
  11. use eZ\Publish\SPI\Repository\Strategy\ContentThumbnail\ThumbnailStrategy;
  12. final class ThumbnailChainStrategy implements ThumbnailStrategy
  13. {
  14.     /** @var \eZ\Publish\SPI\Repository\Strategy\ContentThumbnail\ThumbnailStrategy[] */
  15.     private $strategies;
  16.     /**
  17.      * @param \eZ\Publish\SPI\Repository\Strategy\ContentThumbnail\ThumbnailStrategy[] $strategies
  18.      */
  19.     public function __construct(iterable $strategies)
  20.     {
  21.         $this->strategies $strategies;
  22.     }
  23.     public function getThumbnail(ContentType $contentType, array $fields, ?VersionInfo $versionInfo null): ?Thumbnail
  24.     {
  25.         foreach ($this->strategies as $strategy) {
  26.             $thumbnail $strategy->getThumbnail($contentType$fields$versionInfo);
  27.             if ($thumbnail !== null) {
  28.                 return $thumbnail;
  29.             }
  30.         }
  31.         return null;
  32.     }
  33. }