AssetReference.php
2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
/*
* This file is part of the Assetic package, an OpenSky project.
*
* (c) 2010-2014 OpenSky Project Inc
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Assetic\Asset;
use Assetic\AssetManager;
use Assetic\Filter\FilterInterface;
/**
* A reference to an asset in the asset manager.
*
* @author Kris Wallsmith <kris.wallsmith@gmail.com>
*/
class AssetReference implements AssetInterface
{
private $am;
private $name;
private $filters = array();
public function __construct(AssetManager $am, $name)
{
$this->am = $am;
$this->name = $name;
}
public function ensureFilter(FilterInterface $filter)
{
$this->filters[] = $filter;
}
public function getFilters()
{
$this->flushFilters();
return $this->callAsset(__FUNCTION__);
}
public function clearFilters()
{
$this->filters = array();
$this->callAsset(__FUNCTION__);
}
public function load(FilterInterface $additionalFilter = null)
{
$this->flushFilters();
return $this->callAsset(__FUNCTION__, array($additionalFilter));
}
public function dump(FilterInterface $additionalFilter = null)
{
$this->flushFilters();
return $this->callAsset(__FUNCTION__, array($additionalFilter));
}
public function getContent()
{
return $this->callAsset(__FUNCTION__);
}
public function setContent($content)
{
$this->callAsset(__FUNCTION__, array($content));
}
public function getSourceRoot()
{
return $this->callAsset(__FUNCTION__);
}
public function getSourcePath()
{
return $this->callAsset(__FUNCTION__);
}
public function getSourceDirectory()
{
return $this->callAsset(__FUNCTION__);
}
public function getTargetPath()
{
return $this->callAsset(__FUNCTION__);
}
public function setTargetPath($targetPath)
{
$this->callAsset(__FUNCTION__, array($targetPath));
}
public function getLastModified()
{
return $this->callAsset(__FUNCTION__);
}
public function getVars()
{
return $this->callAsset(__FUNCTION__);
}
public function getValues()
{
return $this->callAsset(__FUNCTION__);
}
public function setValues(array $values)
{
$this->callAsset(__FUNCTION__, array($values));
}
// private
private function callAsset($method, $arguments = array())
{
$asset = $this->am->get($this->name);
return call_user_func_array(array($asset, $method), $arguments);
}
private function flushFilters()
{
$asset = $this->am->get($this->name);
while ($filter = array_shift($this->filters)) {
$asset->ensureFilter($filter);
}
}
}