diff options
author | Julius Härtl <jus@bitgrid.net> | 2022-11-17 08:32:16 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2022-12-07 22:32:05 +0100 |
commit | 3e5838198c6e5f879d3448cfb6c25babd83ca0c4 (patch) | |
tree | 78d072159ea235cd0897458ddd9a39cf911df6f4 /lib/private/TemplateLayout.php | |
parent | b2af916872b88d1cb1739904ec66fc4417ac0112 (diff) | |
download | nextcloud-server-3e5838198c6e5f879d3448cfb6c25babd83ca0c4.tar.gz nextcloud-server-3e5838198c6e5f879d3448cfb6c25babd83ca0c4.zip |
Use single resource locator instance
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib/private/TemplateLayout.php')
-rw-r--r-- | lib/private/TemplateLayout.php | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index e043f79745a..aa1ee203f31 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -44,8 +44,9 @@ namespace OC; 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; @@ -54,11 +55,16 @@ use OCP\INavigationManager; 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; @@ -332,17 +338,11 @@ class TemplateLayout extends \OC_Template { * @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(); } /** @@ -366,18 +366,11 @@ class TemplateLayout extends \OC_Template { * @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(); } /** |