ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
CachedFormulaLoader.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of the Assetic package, an OpenSky project.
5 *
6 * (c) 2010-2014 OpenSky Project Inc
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
13
17
26{
27 private $loader;
28 private $configCache;
29 private $debug;
30
42 {
43 $this->loader = $loader;
44 $this->configCache = $configCache;
45 $this->debug = $debug;
46 }
47
48 public function load(ResourceInterface $resources)
49 {
50 if (!$resources instanceof IteratorResourceInterface) {
51 $resources = array($resources);
52 }
53
54 $formulae = array();
55
56 foreach ($resources as $resource) {
57 $id = (string) $resource;
58 if (!$this->configCache->has($id) || ($this->debug && !$resource->isFresh($this->configCache->getTimestamp($id)))) {
59 $formulae += $this->loader->load($resource);
60 $this->configCache->set($id, $formulae);
61 } else {
62 $formulae += $this->configCache->get($id);
63 }
64 }
65
66 return $formulae;
67 }
68}
A config cache stores values using var_export() and include.
Definition: ConfigCache.php:20
load(ResourceInterface $resources)
Loads formulae from a resource.
__construct(FormulaLoaderInterface $loader, ConfigCache $configCache, $debug=false)
Constructor.
An exception for terminatinating execution or to throw for unit testing.
A resource is something formulae can be loaded from.
A resource is something formulae can be loaded from.