Last active
January 5, 2017 09:24
-
-
Save Patricy/02b43e85238223217b0457d619b1bbfa to your computer and use it in GitHub Desktop.
Yii2 "assets does not updates" issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $config['components']['assetManager']['hashCallback'] = function($path){ | |
| $mostRecentFileMTime = 0; | |
| if (is_dir($path)){ | |
| $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::CHILD_FIRST); | |
| foreach ($iterator as $fileinfo) { | |
| if ($fileinfo->isFile() && $fileinfo->getMTime() > $mostRecentFileMTime) { | |
| $mostRecentFileMTime = $fileinfo->getMTime(); | |
| } | |
| } | |
| $path = (is_file($path) ? dirname($path) : $path) . $mostRecentFileMTime; | |
| } else { | |
| $path = (is_file($path) ? dirname($path) : $path) . filemtime($path); | |
| } | |
| return sprintf('%x', crc32($path . Yii::getVersion())); | |
| }; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yiisoft/yii2#8197