@@ -363,6 +363,7 @@ the :class:`Symfony\\Component\\HttpKernel\\CacheWarmer\\CacheWarmerInterface` i
363
363
// src/Cache/MyCustomWarmer.php
364
364
namespace App\Cache;
365
365
366
+ use App\Foo\Bar;
366
367
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
367
368
368
369
class MyCustomWarmer implements CacheWarmerInterface
@@ -371,16 +372,16 @@ the :class:`Symfony\\Component\\HttpKernel\\CacheWarmer\\CacheWarmerInterface` i
371
372
{
372
373
// ... do some sort of operations to "warm" your cache
373
374
374
- // this method must return an array with the file paths of the
375
- // PHP files to preload. If you don't have any, return an empty array
376
- $filesToPreload = [];
375
+ $filesAndClassesToPreload = [];
376
+ $filesAndClassesToPreload[] = Bar::class;
377
+
377
378
foreach (scandir($someCacheDir) as $file) {
378
379
if (!is_dir($file = $someCacheDir.'/'.$file)) {
379
- $filesToPreload [] = $file;
380
+ $filesAndClassesToPreload [] = $file;
380
381
}
381
382
}
382
383
383
- return $filesToPreload ;
384
+ return $filesAndClassesToPreload ;
384
385
}
385
386
386
387
public function isOptional()
@@ -389,6 +390,11 @@ the :class:`Symfony\\Component\\HttpKernel\\CacheWarmer\\CacheWarmerInterface` i
389
390
}
390
391
}
391
392
393
+ The ``warmUp() `` method must return an array with the files and classes to
394
+ preload. Files must be absolute paths and classes must be fully-qualified class
395
+ names. The only restriction is that files must be stored in the cache directory.
396
+ If you don't need to preload anything, return an empty array
397
+
392
398
.. deprecated :: 5.1
393
399
394
400
Not returning an array from the ``warmUp() `` method with the files to
0 commit comments