43
43
namespace OC ;
44
44
45
45
use bantu \IniGetWrapper \IniGetWrapper ;
46
+ use OC \AppFramework \Utility \QueryNotFoundException ;
46
47
use OC \Search \SearchQuery ;
47
48
use OC \Template \JSCombiner ;
48
49
use OC \Template \JSConfigHelper ;
50
+ use OC \Template \JSResourceLocator ;
49
51
use OCP \AppFramework \Http \TemplateResponse ;
50
52
use OCP \Defaults ;
51
53
use OCP \IConfig ;
@@ -68,6 +70,9 @@ class TemplateLayout extends \OC_Template {
68
70
/** @var INavigationManager */
69
71
private $ navigationManager ;
70
72
73
+ /** @var JSResourceLocator|null */
74
+ public static $ jsLocator = null ;
75
+
71
76
/**
72
77
* @param string $renderAs
73
78
* @param string $appId application id
@@ -374,16 +379,24 @@ public function getAppNamefromPath($path) {
374
379
public static function findJavascriptFiles ($ scripts ) {
375
380
// Read the selected theme from the config file
376
381
$ 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)
384
395
);
385
- $ locator ->find ($ scripts );
386
- return $ locator ->getResources ();
396
+ }
397
+
398
+ self ::$ jsLocator ->find ($ scripts );
399
+ return self ::$ jsLocator ->getResources ();
387
400
}
388
401
389
402
/**
0 commit comments