@@ -35,70 +35,70 @@ |
||
35 | 35 | class CompileService |
36 | 36 | { |
37 | 37 | |
38 | - /** |
|
39 | - * @param string $file |
|
40 | - * @return bool|string |
|
41 | - * @throws \Exception |
|
42 | - */ |
|
43 | - public static function getCompiledFile($file) |
|
44 | - { |
|
45 | - $file = GeneralUtility::getFileAbsFileName($file); |
|
46 | - $pathParts = pathinfo($file); |
|
47 | - if ($pathParts['extension'] === 'less') { |
|
48 | - try { |
|
49 | - $options = array( |
|
50 | - 'cache_dir' => GeneralUtility::getFileAbsFileName('typo3temp/mooxcore') |
|
51 | - ); |
|
52 | - $settings = ($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_mooxcore.']['settings.'] ?: array()); |
|
53 | - if ($settings['cssSourceMapping']) { |
|
54 | - // enable source mapping |
|
55 | - $optionsForSourceMap = array( |
|
56 | - 'sourceMap' => true, |
|
57 | - 'sourceMapWriteTo' => GeneralUtility::getFileAbsFileName('typo3temp/mooxcore') . '/mooxcore.map', |
|
58 | - 'sourceMapURL' => '/typo3temp/mooxcore/mooxcore.map', |
|
59 | - 'sourceMapBasepath' => PATH_site, |
|
60 | - 'sourceMapRootpath' => '/' |
|
61 | - ); |
|
62 | - $options += $optionsForSourceMap; |
|
38 | + /** |
|
39 | + * @param string $file |
|
40 | + * @return bool|string |
|
41 | + * @throws \Exception |
|
42 | + */ |
|
43 | + public static function getCompiledFile($file) |
|
44 | + { |
|
45 | + $file = GeneralUtility::getFileAbsFileName($file); |
|
46 | + $pathParts = pathinfo($file); |
|
47 | + if ($pathParts['extension'] === 'less') { |
|
48 | + try { |
|
49 | + $options = array( |
|
50 | + 'cache_dir' => GeneralUtility::getFileAbsFileName('typo3temp/mooxcore') |
|
51 | + ); |
|
52 | + $settings = ($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_mooxcore.']['settings.'] ?: array()); |
|
53 | + if ($settings['cssSourceMapping']) { |
|
54 | + // enable source mapping |
|
55 | + $optionsForSourceMap = array( |
|
56 | + 'sourceMap' => true, |
|
57 | + 'sourceMapWriteTo' => GeneralUtility::getFileAbsFileName('typo3temp/mooxcore') . '/mooxcore.map', |
|
58 | + 'sourceMapURL' => '/typo3temp/mooxcore/mooxcore.map', |
|
59 | + 'sourceMapBasepath' => PATH_site, |
|
60 | + 'sourceMapRootpath' => '/' |
|
61 | + ); |
|
62 | + $options += $optionsForSourceMap; |
|
63 | 63 | |
64 | - // disable CSS compression |
|
65 | - /** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */ |
|
66 | - $pageRenderer = $GLOBALS['TSFE']->getPageRenderer(); |
|
67 | - $pageRenderer->disableCompressCss(); |
|
68 | - } |
|
69 | - if ($settings['overrideLessVariables']) { |
|
70 | - $variables = self::getVariablesFromConstants(); |
|
71 | - } else { |
|
72 | - $variables = array(); |
|
73 | - } |
|
74 | - $files = array(); |
|
75 | - $files[$file] = '../../' . str_replace(PATH_site, '', dirname($file)) . '/'; |
|
76 | - $compiledFile = \Less_Cache::Get($files, $options, $variables); |
|
77 | - $file = "typo3temp/mooxcore/" . $compiledFile; |
|
64 | + // disable CSS compression |
|
65 | + /** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */ |
|
66 | + $pageRenderer = $GLOBALS['TSFE']->getPageRenderer(); |
|
67 | + $pageRenderer->disableCompressCss(); |
|
68 | + } |
|
69 | + if ($settings['overrideLessVariables']) { |
|
70 | + $variables = self::getVariablesFromConstants(); |
|
71 | + } else { |
|
72 | + $variables = array(); |
|
73 | + } |
|
74 | + $files = array(); |
|
75 | + $files[$file] = '../../' . str_replace(PATH_site, '', dirname($file)) . '/'; |
|
76 | + $compiledFile = \Less_Cache::Get($files, $options, $variables); |
|
77 | + $file = "typo3temp/mooxcore/" . $compiledFile; |
|
78 | 78 | |
79 | - return $file; |
|
80 | - } catch (\Exception $e) { |
|
81 | - throw new \Exception($e->getMessage()); |
|
82 | - } |
|
83 | - } |
|
84 | - return false; |
|
85 | - } |
|
79 | + return $file; |
|
80 | + } catch (\Exception $e) { |
|
81 | + throw new \Exception($e->getMessage()); |
|
82 | + } |
|
83 | + } |
|
84 | + return false; |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * @return array |
|
89 | - */ |
|
90 | - public static function getVariablesFromConstants() |
|
91 | - { |
|
92 | - $variables = array(); |
|
93 | - $prefix = "plugin.tx_mooxcore.settings.less."; |
|
94 | - if (!isset($GLOBALS['TSFE']->tmpl->flatSetup) || !is_array($GLOBALS['TSFE']->tmpl->flatSetup) || count($GLOBALS['TSFE']->tmpl->flatSetup) === 0) { |
|
95 | - $GLOBALS['TSFE']->tmpl->generateConfig(); |
|
96 | - } |
|
97 | - foreach ($GLOBALS['TSFE']->tmpl->flatSetup as $constant => $value) { |
|
98 | - if (strpos($constant, $prefix) === 0) { |
|
99 | - $variables[substr($constant, strlen($prefix))] = $value; |
|
100 | - } |
|
101 | - } |
|
102 | - return $variables; |
|
103 | - } |
|
87 | + /** |
|
88 | + * @return array |
|
89 | + */ |
|
90 | + public static function getVariablesFromConstants() |
|
91 | + { |
|
92 | + $variables = array(); |
|
93 | + $prefix = "plugin.tx_mooxcore.settings.less."; |
|
94 | + if (!isset($GLOBALS['TSFE']->tmpl->flatSetup) || !is_array($GLOBALS['TSFE']->tmpl->flatSetup) || count($GLOBALS['TSFE']->tmpl->flatSetup) === 0) { |
|
95 | + $GLOBALS['TSFE']->tmpl->generateConfig(); |
|
96 | + } |
|
97 | + foreach ($GLOBALS['TSFE']->tmpl->flatSetup as $constant => $value) { |
|
98 | + if (strpos($constant, $prefix) === 0) { |
|
99 | + $variables[substr($constant, strlen($prefix))] = $value; |
|
100 | + } |
|
101 | + } |
|
102 | + return $variables; |
|
103 | + } |
|
104 | 104 | } |
105 | 105 | \ No newline at end of file |