1 | <?php namespace Modules\Core\Foundation\Asset\Pipeline; |
||
7 | class AsgardAssetPipeline implements AssetPipeline |
||
8 | { |
||
9 | /** |
||
10 | * @var Collection |
||
11 | */ |
||
12 | protected $css; |
||
13 | /** |
||
14 | * @var Collection |
||
15 | */ |
||
16 | protected $js; |
||
17 | |||
18 | public function __construct(AssetManager $assetManager) |
||
24 | |||
25 | /** |
||
26 | * Add a javascript dependency on the view |
||
27 | * @param string $dependency |
||
28 | * @return $this |
||
29 | * @throws AssetNotFoundException |
||
30 | */ |
||
31 | public function requireJs($dependency) |
||
47 | |||
48 | /** |
||
49 | * Add a CSS dependency on the view |
||
50 | * @param string $dependency |
||
51 | * @return $this |
||
52 | * @throws AssetNotFoundException |
||
53 | */ |
||
54 | public function requireCss($dependency) |
||
70 | |||
71 | /** |
||
72 | * Add the dependency after another one |
||
73 | * @param string $dependency |
||
74 | * @return void |
||
75 | */ |
||
76 | public function after($dependency) |
||
80 | |||
81 | /** |
||
82 | * Add the dependency before another one |
||
83 | * @param string $dependency |
||
84 | * @return void |
||
85 | */ |
||
86 | public function before($dependency) |
||
90 | |||
91 | /** |
||
92 | * Insert a dependency before or after in the right dependency array |
||
93 | * @param string $dependency |
||
94 | * @param string $offset |
||
95 | */ |
||
96 | private function insert($dependency, $offset = 'before') |
||
113 | |||
114 | /** |
||
115 | * Return all css files to include |
||
116 | * @return \Illuminate\Support\Collection |
||
117 | */ |
||
118 | public function allCss() |
||
122 | |||
123 | /** |
||
124 | * Return all js files to include |
||
125 | * @return \Illuminate\Support\Collection |
||
126 | */ |
||
127 | public function allJs() |
||
131 | |||
132 | /** |
||
133 | * Find in which collection the given dependency exists |
||
134 | * @param string $dependency |
||
135 | * @return array |
||
136 | */ |
||
137 | private function findDependenciesForKey($dependency) |
||
145 | |||
146 | /** |
||
147 | * Get the last key and value the given array |
||
148 | * @param array $dependencyArray |
||
149 | * @return array |
||
150 | */ |
||
151 | private function getLastKeyAndValueOf(array $dependencyArray) |
||
159 | |||
160 | /** |
||
161 | * Return the position in the array of the given key |
||
162 | * |
||
163 | * @param $dependency |
||
164 | * @param array $dependencyArray |
||
165 | * @return int |
||
166 | */ |
||
167 | private function getPositionInArray($dependency, array $dependencyArray) |
||
173 | |||
174 | /** |
||
175 | * If asset was not found, throw an exception |
||
176 | * @param string $assetPath |
||
177 | * @throws AssetNotFoundException |
||
178 | */ |
||
179 | private function guardForAssetNotFound($assetPath) |
||
185 | } |
||
186 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: