forked from janmarek/WebLoader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CssLoader.php
66 lines (53 loc) · 1.04 KB
/
CssLoader.php
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
<?php
namespace WebLoader;
use Nette\Web\Html;
use Nette\IComponentContainer;
/**
* Css loader
*
* @author Jan Marek
* @license MIT
*/
class CssLoader extends WebLoader {
/** @var string */
private $media;
/**
* Construct
* @param IComponentContainer parent
* @param string name
*/
public function __construct(IComponentContainer $parent = null, $name = null) {
parent::__construct($parent, $name);
$this->setGeneratedFileNamePrefix("cssloader-");
$this->setGeneratedFileNameSuffix(".css");
$this->fileFilters[] = new CssUrlsFilter;
}
/**
* Get media
* @return string
*/
public function getMedia() {
return $this->media;
}
/**
* Set media
* @param string media
* @return CssLoader
*/
public function setMedia($media) {
$this->media = $media;
return $this;
}
/**
* Get link element
* @param string $source
* @return Html
*/
public function getElement($source) {
return Html::el("link")
->rel("stylesheet")
->type("text/css")
->media($this->media)
->href($source);
}
}