vendor/vich/uploader-bundle/src/Metadata/CacheWarmer.php line 16

Open in your IDE?
  1. <?php
  2. namespace Vich\UploaderBundle\Metadata;
  3. use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
  4. /**
  5.  * @internal
  6.  */
  7. final class CacheWarmer implements CacheWarmerInterface
  8. {
  9.     public function __construct(private readonly string $dir, private readonly MetadataReader $metadataReader)
  10.     {
  11.     }
  12.     public function warmUp(string $cacheDirstring $buildDir null): array
  13.     {
  14.         if (empty($this->dir)) {
  15.             return [];
  16.         }
  17.         $files = [];
  18.         if (!\is_dir($this->dir)) {
  19.             if (!\mkdir($concurrentDirectory $this->dir0o777true) && !\is_dir($concurrentDirectory)) {
  20.                 throw new \RuntimeException(\sprintf('Directory "%s" was not created'$concurrentDirectory));
  21.             }
  22.         }
  23.         $uploadableClasses $this->metadataReader->getUploadableClasses();
  24.         foreach ($uploadableClasses as $class) {
  25.             $this->metadataReader->getUploadableFields($class);
  26.             $files[] = $class;
  27.         }
  28.         // TODO it could be nice if we return $files, to allow to exploit preloading...
  29.         return [];
  30.     }
  31.     public function isOptional(): bool
  32.     {
  33.         return true;
  34.     }
  35. }