use Psr\Log\LoggerInterface;
class CSSResourceLocator extends ResourceLocator {
-
- /**
- * @param string $theme
- * @param array $core_map
- * @param array $party_map
- */
- public function __construct(LoggerInterface $logger, $theme, $core_map, $party_map) {
- parent::__construct($logger, $theme, $core_map, $party_map);
+ public function __construct(LoggerInterface $logger) {
+ parent::__construct($logger);
}
/**
protected LoggerInterface $logger;
- /**
- * @param string $theme
- * @param array $core_map
- * @param array $party_map
- */
- public function __construct(LoggerInterface $logger, $theme, $core_map, $party_map) {
+ public function __construct(LoggerInterface $logger) {
$this->logger = $logger;
- $this->theme = $theme;
- $this->mapping = $core_map + $party_map;
- $this->serverroot = key($core_map);
- $this->thirdpartyroot = key($party_map);
+ $this->mapping = [
+ \OC::$SERVERROOT => \OC::$WEBROOT
+ ];
+ $this->serverroot = \OC::$SERVERROOT;
+ $this->thirdpartyroot = \OC::$SERVERROOT;
$this->webroot = $this->mapping[$this->serverroot];
+ $this->theme = \OC_Util::getTheme();
}
/**
use bantu\IniGetWrapper\IniGetWrapper;
use OC\Search\SearchQuery;
-use OC\Template\JSCombiner;
+use OC\Template\CSSResourceLocator;
use OC\Template\JSConfigHelper;
+use OC\Template\JSResourceLocator;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\Defaults;
use OCP\IConfig;
use OCP\IUserSession;
use OCP\Support\Subscription\IRegistry;
use OCP\Util;
-use Psr\Log\LoggerInterface;
class TemplateLayout extends \OC_Template {
private static $versionHash = '';
+ /** @var CSSResourceLocator|null */
+ public static $cssLocator = null;
+
+ /** @var JSResourceLocator|null */
+ public static $jsLocator = null;
+
/** @var IConfig */
private $config;
* @return array
*/
public static function findStylesheetFiles($styles, $compileScss = true) {
- // Read the selected theme from the config file
- $theme = \OC_Util::getTheme();
-
- $locator = new \OC\Template\CSSResourceLocator(
- \OC::$server->get(LoggerInterface::class),
- $theme,
- [ \OC::$SERVERROOT => \OC::$WEBROOT ],
- [ \OC::$SERVERROOT => \OC::$WEBROOT ],
- );
- $locator->find($styles);
- return $locator->getResources();
+ if (!self::$cssLocator) {
+ self::$cssLocator = \OCP\Server::get(CSSResourceLocator::class);
+ }
+ self::$cssLocator->find($styles);
+ return self::$cssLocator->getResources();
}
/**
* @return array
*/
public static function findJavascriptFiles($scripts) {
- // Read the selected theme from the config file
- $theme = \OC_Util::getTheme();
-
- $locator = new \OC\Template\JSResourceLocator(
- \OC::$server->get(LoggerInterface::class),
- $theme,
- [ \OC::$SERVERROOT => \OC::$WEBROOT ],
- [ \OC::$SERVERROOT => \OC::$WEBROOT ],
- \OC::$server->query(JSCombiner::class)
- );
- $locator->find($scripts);
- return $locator->getResources();
+ if (!self::$jsLocator) {
+ self::$jsLocator = \OCP\Server::get(JSResourceLocator::class);
+ }
+ self::$jsLocator->find($scripts);
+ return self::$jsLocator->getResources();
}
/**