PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.2.3
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.2.3
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / kriswallsmith / assetic / src / Assetic / Asset / GlobAsset.php

GlobAsset.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.3, at vendor/kriswallsmith/assetic/src/Assetic/Asset/GlobAsset.php

116 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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
12 namespace Assetic\Asset;
13
14 use Assetic\Filter\FilterInterface;
15 use Assetic\Util\VarUtils;
16
17 /**
18 * A collection of assets loaded by glob.
19 *
20 * @author Kris Wallsmith <[email protected]>
21 */
22 class GlobAsset extends AssetCollection
23 {
24 private $globs;
25 private $initialized;
26
27 /**
28 * Constructor.
29 *
30 * @param string|array $globs A single glob path or array of paths
31 * @param array $filters An array of filters
32 * @param string $root The root directory
33 * @param array $vars
34 */
35 public function __construct($globs, $filters = array(), $root = null, array $vars = array())
36 {
37 $this->globs = (array) $globs;
38 $this->initialized = false;
39
40 parent::__construct(array(), $filters, $root, $vars);
41 }
42
43 public function all()
44 {
45 if (!$this->initialized) {
46 $this->initialize();
47 }
48
49 return parent::all();
50 }
51
52 public function load(FilterInterface $additionalFilter = null)
53 {
54 if (!$this->initialized) {
55 $this->initialize();
56 }
57
58 parent::load($additionalFilter);
59 }
60
61 public function dump(FilterInterface $additionalFilter = null)
62 {
63 if (!$this->initialized) {
64 $this->initialize();
65 }
66
67 return parent::dump($additionalFilter);
68 }
69
70 public function getLastModified()
71 {
72 if (!$this->initialized) {
73 $this->initialize();
74 }
75
76 return parent::getLastModified();
77 }
78
79 public function getIterator()
80 {
81 if (!$this->initialized) {
82 $this->initialize();
83 }
84
85 return parent::getIterator();
86 }
87
88 public function setValues(array $values)
89 {
90 parent::setValues($values);
91 $this->initialized = false;
92 }
93
94 /**
95 * Initializes the collection based on the glob(s) passed in.
96 */
97 private function initialize()
98 {
99 foreach ($this->globs as $glob) {
100 $glob = VarUtils::resolve($glob, $this->getVars(), $this->getValues());
101
102 if (false !== $paths = glob($glob)) {
103 foreach ($paths as $path) {
104 if (is_file($path)) {
105 $asset = new FileAsset($path, array(), $this->getSourceRoot(), null, $this->getVars());
106 $asset->setValues($this->getValues());
107 $this->add($asset);
108 }
109 }
110 }
111 }
112
113 $this->initialized = true;
114 }
115 }
116