]> source.dussan.org Git - nextcloud-server.git/commitdiff
Inject SCSSCacher
authorRoeland Jago Douma <roeland@famdouma.nl>
Wed, 30 Nov 2016 21:09:36 +0000 (22:09 +0100)
committerRoeland Jago Douma <roeland@famdouma.nl>
Fri, 6 Jan 2017 08:42:14 +0000 (09:42 +0100)
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
lib/private/Template/CSSResourceLocator.php
lib/private/TemplateLayout.php

index 757c0232ca75c6a4a5f7ca71586d839fe4cc41e4..34b4d08929aeab85dc9664a72c3ed45f0748e0c7 100755 (executable)
 
 namespace OC\Template;
 
-use OC\SystemConfig;
-use OCP\Files\IAppData;
 use OCP\ILogger;
-use OCP\IURLGenerator;
 
 class CSSResourceLocator extends ResourceLocator {
 
-       /** @var IAppData */
-       protected $appData;
-       /** @var IURLGenerator */
-       protected $urlGenerator;
-       /** @var SystemConfig */
-       protected $systemConfig;
+       /** @var SCSSCacher */
+       protected $scssCacher;
 
        /**
         * @param ILogger $logger
         * @param string $theme
         * @param array $core_map
         * @param array $party_map
-        * @param IAppData $appData
-        * @param IURLGenerator $urlGenerator
-        * @param SystemConfig $systemConfig
+        * @param SCSSCacher $scssCcacher
         */
-       public function __construct(ILogger $logger, $theme, $core_map, $party_map, IAppData $appData, IURLGenerator $urlGenerator, SystemConfig $systemConfig) {
-               $this->appData = $appData;
-               $this->urlGenerator = $urlGenerator;
-               $this->systemConfig = $systemConfig;
+       public function __construct(ILogger $logger, $theme, $core_map, $party_map, SCSSCacher $scssCacher) {
+               $this->scssCacher = $scssCacher;
 
                parent::__construct($logger, $theme, $core_map, $party_map);
        }
@@ -62,8 +51,8 @@ class CSSResourceLocator extends ResourceLocator {
        public function doFind($style) {
                if (strpos($style, '3rdparty') === 0
                        && $this->appendIfExist($this->thirdpartyroot, $style.'.css')
-                       || $this->cacheAndAppendScssIfExist($this->serverroot, $style.'.scss', $this->appData, $this->urlGenerator, $this->systemConfig)
-                       || $this->cacheAndAppendScssIfExist($this->serverroot, 'core/'.$style.'.scss', $this->appData, $this->urlGenerator, $this->systemConfig)
+                       || $this->cacheAndAppendScssIfExist($this->serverroot, $style.'.scss')
+                       || $this->cacheAndAppendScssIfExist($this->serverroot, 'core/'.$style.'.scss')
                        || $this->appendIfExist($this->serverroot, $style.'.css')
                        || $this->appendIfExist($this->serverroot, 'core/'.$style.'.css')
                ) {
@@ -91,22 +80,13 @@ class CSSResourceLocator extends ResourceLocator {
         *
         * @param string $root path to check
         * @param string $file the filename
-        * @param IAppData $appData
-        * @param IURLGenerator $urlGenerator
-        * @param SystemConfig $systemConfig
         * @param string|null $webRoot base for path, default map $root to $webRoot
         * @return bool True if the resource was found and cached, false otherwise
         */
-       protected function cacheAndAppendScssIfExist($root, $file, IAppData $appData, IURLGenerator $urlGenerator, SystemConfig $systemConfig, $webRoot = null) {
+       protected function cacheAndAppendScssIfExist($root, $file, $webRoot = null) {
                if (is_file($root.'/'.$file)) {
-                       $scssCache = new SCSSCacher(
-                               $this->logger,
-                               $appData,
-                               $urlGenerator,
-                               $systemConfig);
-
-                       if($scssCache->process($root, $file)) {
-                               $this->append($root, $scssCache->getCachedSCSS('core', $file), $webRoot, false);
+                       if($this->scssCacher->process($root, $file)) {
+                               $this->append($root, $this->scssCacher->getCachedSCSS('core', $file), $webRoot, false);
                                return true;
                        } else {
                                $this->logger->error('Failed to compile and/or save '.$root.'/'.$file, ['app' => 'core']);
index 8ba5bc561f0110ce808ccc2036aa7778d4bce83f..67ba831dfafeb03db218d141ef2ac4b3ed949ab8 100644 (file)
@@ -36,6 +36,7 @@
 namespace OC;
 
 use OC\Template\JSConfigHelper;
+use OC\Template\SCSSCacher;
 
 class TemplateLayout extends \OC_Template {
 
@@ -193,14 +194,19 @@ class TemplateLayout extends \OC_Template {
                // Read the selected theme from the config file
                $theme = \OC_Util::getTheme();
 
+               $SCSSCacher = new SCSSCacher(
+                       \OC::$server->getLogger(),
+                       \OC::$server->getAppDataDir('css'),
+                       \OC::$server->getURLGenerator(),
+                       \OC::$server->getSystemConfig()
+               );
+
                $locator = new \OC\Template\CSSResourceLocator(
                        \OC::$server->getLogger(),
                        $theme,
                        array( \OC::$SERVERROOT => \OC::$WEBROOT ),
                        array( \OC::$SERVERROOT => \OC::$WEBROOT ),
-                       \OC::$server->getAppDataDir('css'),
-                       \OC::$server->getURLGenerator(),
-                       \OC::$server->getSystemConfig());
+                       $SCSSCacher);
                $locator->find($styles);
                return $locator->getResources();
        }