1 | <?php |
||
9 | class SheetLoader { |
||
10 | private $tss; |
||
11 | private $filePath; |
||
12 | private $time; |
||
13 | private $import = []; |
||
14 | |||
15 | public function __construct(\Transphporm\Cache $cache, \Transphporm\FilePath $filePath, TSSRules $tss, $time) { |
||
16 | $this->cache = $cache; |
||
|
|||
17 | $this->filePath = $filePath; |
||
18 | $this->tss = $tss; |
||
19 | $this->time = isset($time) ? $time : time(); |
||
20 | } |
||
21 | |||
22 | //Allows controlling whether any updates are required to the template |
||
23 | //e.g. return false |
||
24 | // 1. If all update-frequencies haven't expired |
||
25 | // 2. If the data hasn't changed since the last run |
||
26 | //If this function returns false, the rendered template is sent straight from the cache skipping 99% of transphporm's code |
||
27 | public function updateRequired($data) { |
||
30 | |||
31 | public function addImport($import) { |
||
35 | |||
36 | public function setCacheKey($tokens) { |
||
37 | $newTokens = []; |
||
38 | foreach ($tokens as $token) { |
||
39 | if ($token['type'] == \Transphporm\Parser\Tokenizer::NAME && $token['value'] == 'data') { |
||
40 | $tokens->next(); |
||
41 | $newTokens = array_merge($newTokens, iterator_to_array($tokens->current()['value'])); |
||
42 | } |
||
43 | else $newTokens[] = $token; |
||
44 | } |
||
45 | |||
46 | $this->tss->setCacheKey(new \Transphporm\Parser\Tokens($newTokens)); |
||
47 | } |
||
48 | |||
49 | public function getCacheKey($data) { |
||
52 | |||
53 | |||
54 | public function processRules($template, \Transphporm\Config $config) { |
||
67 | |||
68 | //Load the TSS |
||
69 | public function getRules($cssToXpath, $valueParser, $indexStart = 0) { |
||
72 | |||
73 | //Process a TSS rule e.g. `ul li {content: "foo"; format: bar} |
||
74 | private function executeTssRule($rule, $template, $config) { |
||
83 | |||
84 | |||
85 | private function sortRules($a, $b) { |
||
94 | |||
95 | |||
96 | private function sortPseudo($a, $b) { |
||
99 | } |
||
100 |
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: