4343namespace OC ;
4444
4545use bantu \IniGetWrapper \IniGetWrapper ;
46+ use OC \AppFramework \Utility \QueryNotFoundException ;
4647use OC \Search \SearchQuery ;
4748use OC \Template \JSCombiner ;
4849use OC \Template \JSConfigHelper ;
50+ use OC \Template \JSResourceLocator ;
4951use OCP \AppFramework \Http \TemplateResponse ;
5052use OCP \Defaults ;
5153use OCP \IConfig ;
@@ -68,6 +70,9 @@ class TemplateLayout extends \OC_Template {
6870 /** @var INavigationManager */
6971 private $ navigationManager ;
7072
73+ /** @var JSResourceLocator|null */
74+ public static $ jsLocator = null ;
75+
7176 /**
7277 * @param string $renderAs
7378 * @param string $appId application id
@@ -374,16 +379,24 @@ public function getAppNamefromPath($path) {
374379 public static function findJavascriptFiles ($ scripts ) {
375380 // Read the selected theme from the config file
376381 $ theme = \OC_Util::getTheme ();
377-
378- $ locator = new \OC \Template \JSResourceLocator (
379- \OC ::$ server ->get (LoggerInterface::class),
380- $ theme ,
381- [ \OC ::$ SERVERROOT => \OC ::$ WEBROOT ],
382- [ \OC ::$ SERVERROOT => \OC ::$ WEBROOT ],
383- \OC ::$ server ->query (JSCombiner::class)
382+ try {
383+ // we need the injected form coming with stable26
384+ if (self ::$ jsLocator === null ) {
385+ self ::$ jsLocator = \OCP \Server::get (JSResourceLocator::class);
386+ }
387+ } catch (QueryNotFoundException $ eInject ) {
388+ // but keep the old version just in case theming is not available
389+ self ::$ jsLocator = new JSResourceLocator (
390+ \OC ::$ server ->get (LoggerInterface::class),
391+ $ theme ,
392+ [ \OC ::$ SERVERROOT => \OC ::$ WEBROOT ],
393+ [ \OC ::$ SERVERROOT => \OC ::$ WEBROOT ],
394+ \OC ::$ server ->query (JSCombiner::class)
384395 );
385- $ locator ->find ($ scripts );
386- return $ locator ->getResources ();
396+ }
397+
398+ self ::$ jsLocator ->find ($ scripts );
399+ return self ::$ jsLocator ->getResources ();
387400 }
388401
389402 /**
0 commit comments