Skip to content

Commit 27dd8f3

Browse files
committed
Document that cache warmers now must return an array of files to preload
1 parent e9d8a21 commit 27dd8f3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

reference/dic_tags.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,17 @@ the :class:`Symfony\\Component\\HttpKernel\\CacheWarmer\\CacheWarmerInterface` i
370370
public function warmUp($cacheDirectory)
371371
{
372372
// ... do some sort of operations to "warm" your cache
373+
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 = [];
377+
foreach (scandir($someCacheDir) as $file) {
378+
if (!is_dir($file = $someCacheDir.'/'.$file)) {
379+
$filesToPreload[] = $file;
380+
}
381+
}
382+
383+
return $filesToPreload;
373384
}
374385

375386
public function isOptional()
@@ -378,6 +389,11 @@ the :class:`Symfony\\Component\\HttpKernel\\CacheWarmer\\CacheWarmerInterface` i
378389
}
379390
}
380391

392+
.. deprecated:: 5.1
393+
394+
Not returning an array from the ``warmUp()`` method with the files to
395+
preload is deprecated since Symfony 5.1.
396+
381397
The ``isOptional()`` method should return true if it's possible to use the
382398
application without calling this cache warmer. In Symfony, optional warmers
383399
are always executed by default (you can change this by using the

0 commit comments

Comments
 (0)