~ubuntu-branches/debian/stretch/assetic/stretch

« back to all changes in this revision

Viewing changes to src/Assetic/Factory/LazyAssetManager.php

  • Committer: Package Import Robot
  • Author(s): David Prévot
  • Date: 2014-10-17 19:00:55 UTC
  • mfrom: (2.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20141017190055-zt3ohxer91ybtjkn
Tags: 1.2.0-2
Upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
/*
4
4
 * This file is part of the Assetic package, an OpenSky project.
5
5
 *
6
 
 * (c) 2010-2013 OpenSky Project Inc
 
6
 * (c) 2010-2014 OpenSky Project Inc
7
7
 *
8
8
 * For the full copyright and license information, please view the LICENSE
9
9
 * file that was distributed with this source code.
11
11
 
12
12
namespace Assetic\Factory;
13
13
 
14
 
use Assetic\Asset\AssetCollectionInterface;
15
14
use Assetic\Asset\AssetInterface;
16
15
use Assetic\AssetManager;
17
16
use Assetic\Factory\Loader\FormulaLoaderInterface;
18
17
use Assetic\Factory\Resource\ResourceInterface;
19
 
use Assetic\Filter\DependencyExtractorInterface;
20
18
 
21
19
/**
22
20
 * A lazy asset manager is a composition of a factory and many formula loaders.
207
205
 
208
206
    public function getLastModified(AssetInterface $asset)
209
207
    {
210
 
        $mtime = 0;
211
 
        foreach ($asset instanceof AssetCollectionInterface ? $asset : array($asset) as $leaf) {
212
 
            $mtime = max($mtime, $leaf->getLastModified());
213
 
 
214
 
            if (!$filters = $leaf->getFilters()) {
215
 
                continue;
216
 
            }
217
 
 
218
 
            // prepare load path
219
 
            $sourceRoot = $leaf->getSourceRoot();
220
 
            $sourcePath = $leaf->getSourcePath();
221
 
            $loadPath = $sourceRoot && $sourcePath ? dirname($sourceRoot.'/'.$sourcePath) : null;
222
 
 
223
 
            $prevFilters = array();
224
 
            foreach ($filters as $filter) {
225
 
                $prevFilters[] = $filter;
226
 
 
227
 
                if (!$filter instanceof DependencyExtractorInterface) {
228
 
                    continue;
229
 
                }
230
 
 
231
 
                // extract children from leaf after running all preceeding filters
232
 
                $clone = clone $leaf;
233
 
                $clone->clearFilters();
234
 
                foreach (array_slice($prevFilters, 0, -1) as $prevFilter) {
235
 
                    $clone->ensureFilter($prevFilter);
236
 
                }
237
 
                $clone->load();
238
 
 
239
 
                foreach ($filter->getChildren($this->factory, $clone->getContent(), $loadPath) as $child) {
240
 
                    $mtime = max($mtime, $this->getLastModified($child));
241
 
                }
242
 
            }
243
 
        }
244
 
 
245
 
        return $mtime;
 
208
        return $this->factory->getLastModified($asset);
246
209
    }
247
210
}