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);
}
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')
) {
*
* @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']);
namespace OC;
use OC\Template\JSConfigHelper;
+use OC\Template\SCSSCacher;
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();
}