11<?php 
22
3+ /* 
4+  * This file is part of the `liip/LiipImagineBundle` project. 
5+  * 
6+  * (c) https://github.com/liip/LiipImagineBundle/graphs/contributors 
7+  * 
8+  * For the full copyright and license information, please view the LICENSE.md 
9+  * file that was distributed with this source code. 
10+  */ 
11+ 
312namespace  Liip \ImagineBundle \Imagine \Cache ;
413
514use  Liip \ImagineBundle \Imagine \Cache \Warmer \WarmerInterface ;
1322 */ 
1423class  CacheWarmer
1524{
16- 
1725    /** 
1826     * @var WarmerInterface[] 
1927     */ 
20-     protected  $ warmersarray () ;
28+     protected  $ warmers[] ;
2129
2230    /** 
2331     * Chunk size to query warmer in one step 
@@ -97,34 +105,34 @@ public function addWarmer($name, WarmerInterface $warmer)
97105
98106    /** 
99107     * @param bool       $force           If set to true, cache is warmed up for paths already stored in cached (regenerate thumbs) 
100-      * @param null| array $selectedWarmers An optional array of warmers to process, if null - all warmers will be processed 
108+      * @param array|null  $selectedWarmers An optional array of warmers to process, if null - all warmers will be processed 
101109     * 
102-      * @return void 
103110     * @throws \InvalidArgumentException 
111+      * 
112+      * @return void 
104113     */ 
105114    public  function  warm ($ forcefalse , $ selectedWarmersnull )
106115    {
107116        $ filtersByWarmer$ this getFiltersByWarmers ();
108117        if  (!$ filtersByWarmer
109-             $ this log (sprintf ('No warmes are configured - add some as `warmers` param in your filter sets ' ));
118+             $ this log ('No warmes are configured - add some as `warmers` param in your filter sets ' );
119+ 
110120            return ;
111121        }
112122
113123        foreach  ($ filtersByWarmeras  $ warmerName$ filters
114-             if  (isset ($ selectedWarmersempty ($ selectedWarmersin_array ($ warmerName$ selectedWarmers
124+             if  (isset ($ selectedWarmersempty ($ selectedWarmersin_array ($ warmerName$ selectedWarmers,  true )) {
115125                $ this log (
116126                    sprintf (
117127                        'Skipping warmer %s as it \'s not listed in selected warmers: [%s] ' ,
118128                        $ warmerName
119-                         join (',  ' , $ selectedWarmers
129+                         implode (',  ' , $ selectedWarmers
120130                    )
121131                );
122132                continue ;
123133            }
124134            if  (!isset ($ this warmers [$ warmerName
125-                 throw  new  \InvalidArgumentException (sprintf (
126-                     'Could not find warmer "%s" ' , $ warmerName
127-                 ));
135+                 throw  new  \InvalidArgumentException (sprintf ('Could not find warmer "%s" ' , $ warmerName
128136            }
129137
130138            $ this log (sprintf ('Processing warmer "%s" ' , $ warmerName
@@ -153,9 +161,7 @@ public function clearWarmed($paths, $filters)
153161        foreach  ($ filtersByWarmeras  $ warmerName$ warmerFilters
154162            if  (array_intersect ($ filters$ warmerFilters
155163                if  (!isset ($ this warmers [$ warmerName
156-                     throw  new  \InvalidArgumentException (sprintf (
157-                         'Could not find warmer "%s" ' , $ warmerName
158-                     ));
164+                     throw  new  \InvalidArgumentException (sprintf ('Could not find warmer "%s" ' , $ warmerName
159165                }
160166                $ warmer$ this warmers [$ warmerName
161167                $ warmerclearWarmed ($ paths
@@ -166,12 +172,12 @@ public function clearWarmed($paths, $filters)
166172    protected  function  getFiltersByWarmers ()
167173    {
168174        $ all$ this filterManager ->getFilterConfiguration ()->all ();
169-         $ warmersarray () ;
175+         $ warmers[] ;
170176        foreach  ($ allas  $ filterSet$ config
171177            if  (isset ($ config'warmers ' ]) && $ config'warmers ' ]) {
172178                foreach  ($ config'warmers ' ] as  $ warmer
173179                    if  (!isset ($ warmers$ warmer
174-                         $ warmers$ warmerarray ( $ filterSet) ;
180+                         $ warmers$ warmer[ $ filterSet] ;
175181                    } else  {
176182                        $ warmers$ warmer$ filterSet
177183                    }
@@ -194,14 +200,14 @@ protected function warmPaths($paths, $filters, $force)
194200        $ successfulWarmedPaths
195201        foreach  ($ pathsas  $ pathData
196202            $ aPath$ pathData'path ' ];
197-             $ binariesarray () ;
203+             $ binaries[] ;
198204            foreach  ($ filtersas  $ filter
199205                $ this log (sprintf ('Warming up path "%s" for filter "%s" ' , $ aPath$ filter
200206
201207                $ isStored$ this cacheManager ->isStored ($ aPath$ filter
202208                if  ($ force$ isStored
203209                    // this is to avoid loading binary with the same loader for multiple filters 
204-                     $ loader   = $ this dataManager ->getLoader ($ filter
210+                     $ loader$ this dataManager ->getLoader ($ filter
205211                    $ isStoredfalse ;
206212
207213                    try  {
0 commit comments