@@ -468,13 +468,25 @@ the :class:`Symfony\\Component\\HttpKernel\\CacheWarmer\\CacheWarmerInterface` i
468468 // src/Cache/MyCustomWarmer.php
469469 namespace App\Cache;
470470
471+ use App\Foo\Bar;
471472 use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
472473
473474 class MyCustomWarmer implements CacheWarmerInterface
474475 {
475476 public function warmUp($cacheDirectory)
476477 {
477478 // ... do some sort of operations to "warm" your cache
479+
480+ $filesAndClassesToPreload = [];
481+ $filesAndClassesToPreload[] = Bar::class;
482+
483+ foreach (scandir($someCacheDir) as $file) {
484+ if (!is_dir($file = $someCacheDir.'/'.$file)) {
485+ $filesAndClassesToPreload[] = $file;
486+ }
487+ }
488+
489+ return $filesAndClassesToPreload;
478490 }
479491
480492 public function isOptional()
@@ -483,6 +495,16 @@ the :class:`Symfony\\Component\\HttpKernel\\CacheWarmer\\CacheWarmerInterface` i
483495 }
484496 }
485497
498+ The ``warmUp() `` method must return an array with the files and classes to
499+ preload. Files must be absolute paths and classes must be fully-qualified class
500+ names. The only restriction is that files must be stored in the cache directory.
501+ If you don't need to preload anything, return an empty array
502+
503+ .. deprecated :: 5.1
504+
505+ Not returning an array from the ``warmUp() `` method with the files to
506+ preload is deprecated since Symfony 5.1.
507+
486508The ``isOptional() `` method should return true if it's possible to use the
487509application without calling this cache warmer. In Symfony, optional warmers
488510are always executed by default (you can change this by using the
0 commit comments