1 | <?php namespace Spekkionu\Assetcachebuster; |
||
5 | class Assetcachebuster |
||
6 | { |
||
7 | |||
8 | /** |
||
9 | * Flag for if the package is anabled |
||
10 | * |
||
11 | * @var boolean $enabled |
||
12 | */ |
||
13 | protected $enabled = false; |
||
14 | |||
15 | /** |
||
16 | * CDN Url |
||
17 | * |
||
18 | * @var string $cdn The url for the cdn |
||
19 | */ |
||
20 | protected $cdn = '/'; |
||
21 | |||
22 | /** |
||
23 | * Asset cache busting hash |
||
24 | * |
||
25 | * @var string $hash The hash to use to bust the cache |
||
26 | */ |
||
27 | protected $hash = null; |
||
28 | |||
29 | /** |
||
30 | * Asset prefix |
||
31 | * |
||
32 | * @var string $prefix A prefix containing assets |
||
33 | */ |
||
34 | protected $prefix = null; |
||
35 | |||
36 | /** |
||
37 | * Class constructor |
||
38 | * |
||
39 | * @param array $options Array of options from the config file |
||
40 | */ |
||
41 | 8 | public function __construct(array $options) |
|
56 | |||
57 | /** |
||
58 | * Enables / Disables the package |
||
59 | * |
||
60 | * @param boolean $enabled True to enable, false to disable |
||
61 | */ |
||
62 | 6 | public function setEnabled($enabled = true) |
|
66 | |||
67 | /** |
||
68 | * Sets the hash |
||
69 | * |
||
70 | * @param string $hash The hash to use to bust the cache |
||
71 | */ |
||
72 | 7 | public function setHash($hash) |
|
81 | |||
82 | /** |
||
83 | * @return string |
||
84 | */ |
||
85 | 1 | public function getHash() |
|
89 | |||
90 | |||
91 | /** |
||
92 | * Sets the asset prefix path |
||
93 | * |
||
94 | * @param string $prefix A prefix containing assets |
||
95 | */ |
||
96 | 6 | public function setPrefix($prefix = null) |
|
102 | |||
103 | /** |
||
104 | * Sets the CDN url |
||
105 | * |
||
106 | * @param string $cdn The url for the cdn |
||
107 | */ |
||
108 | 6 | public function setCdnUrl($cdn = null) |
|
112 | |||
113 | /** |
||
114 | * Generates an asset url |
||
115 | * |
||
116 | * @param string $path The path to the asset |
||
117 | * |
||
118 | * @return string The asset url with the cache busting hash |
||
119 | */ |
||
120 | 5 | public function url($path = '') |
|
131 | |||
132 | /** |
||
133 | * Generate a random key for the application. |
||
134 | * |
||
135 | * @return string |
||
136 | */ |
||
137 | 1 | public function generateHash() |
|
141 | } |
||
142 |