@@ -7,19 +7,19 @@ discard block |
||
| 7 | 7 | namespace Transphporm; |
| 8 | 8 | //Separates out TSS file loading/caching from parsing |
| 9 | 9 | class SheetLoader { |
| 10 | - private $cache; |
|
| 11 | - private $prefix; |
|
| 12 | - private $sheet; |
|
| 13 | - private $time; |
|
| 14 | - private $import = []; |
|
| 15 | - |
|
| 16 | - public function __construct(Cache $cache, FilePath $filePath, $tss, $prefix, $time) { |
|
| 17 | - $this->cache = $cache; |
|
| 18 | - $this->filePath = $filePath; |
|
| 19 | - $this->prefix = $prefix; |
|
| 20 | - $this->tss = $tss; |
|
| 21 | - $this->time = $time; |
|
| 22 | - } |
|
| 10 | + private $cache; |
|
| 11 | + private $prefix; |
|
| 12 | + private $sheet; |
|
| 13 | + private $time; |
|
| 14 | + private $import = []; |
|
| 15 | + |
|
| 16 | + public function __construct(Cache $cache, FilePath $filePath, $tss, $prefix, $time) { |
|
| 17 | + $this->cache = $cache; |
|
| 18 | + $this->filePath = $filePath; |
|
| 19 | + $this->prefix = $prefix; |
|
| 20 | + $this->tss = $tss; |
|
| 21 | + $this->time = $time; |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | 24 | private function getRulesFromCache($file) { |
| 25 | 25 | //The cache for the key: the filename and template prefix |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | return $file . $this->prefix . dirname(realpath($file)) . DIRECTORY_SEPARATOR; |
| 45 | 45 | } |
| 46 | 46 | //write the sheet to cache |
| 47 | - public function write($file, $rules, $imports = []) { |
|
| 47 | + public function write($file, $rules, $imports = []) { |
|
| 48 | 48 | if (is_file($file)) { |
| 49 | 49 | $key = $this->getCacheKey($file); |
| 50 | 50 | $existing = $this->cache->load($key, filemtime($file)); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $this->cache->write($key, ['rules' => $rules, 'import' => $imports]); |
| 53 | 53 | } |
| 54 | 54 | return $rules; |
| 55 | - } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | public function processRules($template, \Transphporm\Config $config) { |
| 58 | 58 | $rules = $this->getRules($this->tss, $config->getCssToXpath(), $config->getValueParser()); |
@@ -69,12 +69,12 @@ discard block |
||
| 69 | 69 | //Load the TSS |
| 70 | 70 | public function getRules($tss, $cssToXpath, $valueParser) { |
| 71 | 71 | if (is_file($tss)) { |
| 72 | - //$rules = $this->cache->load($tss); |
|
| 73 | - $rules = $this->getRulesFromCache($tss)['rules']; |
|
| 72 | + //$rules = $this->cache->load($tss); |
|
| 73 | + $rules = $this->getRulesFromCache($tss)['rules']; |
|
| 74 | 74 | $this->filePath->addPath(dirname(realpath($tss))); |
| 75 | 75 | if (empty($rules)) $tss = file_get_contents($tss); |
| 76 | 76 | else return $rules; |
| 77 | - } |
|
| 77 | + } |
|
| 78 | 78 | return (new Parser\Sheet($tss, $cssToXpath, $valueParser, $this->filePath, $this))->parse(); |
| 79 | 79 | } |
| 80 | 80 | |
@@ -41,9 +41,9 @@ discard block |
||
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | public function setLocale($locale) { |
| 44 | - $format = new \Transphporm\Module\Format($locale); |
|
| 45 | - $this->modules[get_class($format)] = $format; |
|
| 46 | - } |
|
| 44 | + $format = new \Transphporm\Module\Format($locale); |
|
| 45 | + $this->modules[get_class($format)] = $format; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | 48 | public function addPath($dir) { |
| 49 | 49 | $this->filePath->addPath($dir); |
@@ -82,15 +82,15 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | //Load a template, firstly check if it's a file or a valid string |
| 84 | 84 | private function loadTemplate() { |
| 85 | - $result = ['body' => $this->template, 'headers' => []]; |
|
| 85 | + $result = ['body' => $this->template, 'headers' => []]; |
|
| 86 | 86 | if (strpos($this->template, "\n") === false && is_file($this->template)) $result = $this->loadTemplateFromFile($this->template); |
| 87 | 87 | return $result; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - private function loadTemplateFromFile($file) { |
|
| 91 | - $xml = $this->cache->load($this->template, filemtime($this->template)); |
|
| 92 | - return $xml ? $xml : ['body' => file_get_contents($this->template) ?: "", 'headers' => []]; |
|
| 93 | - } |
|
| 90 | + private function loadTemplateFromFile($file) { |
|
| 91 | + $xml = $this->cache->load($this->template, filemtime($this->template)); |
|
| 92 | + return $xml ? $xml : ['body' => file_get_contents($this->template) ?: "", 'headers' => []]; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | 95 | public function setCache(\ArrayAccess $cache) { |
| 96 | 96 | $this->cache = new Cache($cache); |