Bläddra i källkod

add core fileclient script before others

Signed-off-by: Robin Appelman <robin@icewind.nl>
Robin Appelman 9 månader sedan
förälder
incheckning
1df33256be
2 ändrade filer med 10 tillägg och 5 borttagningar
  1. 3 3
      core/Listener/BeforeTemplateRenderedListener.php
  2. 7 2
      lib/public/Util.php

+ 3 - 3
core/Listener/BeforeTemplateRenderedListener.php

@@ -62,9 +62,9 @@ class BeforeTemplateRenderedListener implements IEventListener {
 			Util::addTranslations('core');
 
 			if ($event->getResponse()->getRenderAs() !== TemplateResponse::RENDER_AS_ERROR) {
-				Util::addScript('core', 'files_fileinfo');
-				Util::addScript('core', 'files_client');
-				Util::addScript('core', 'merged-template-prepend');
+				Util::addScript('core', 'merged-template-prepend', 'core', true);
+				Util::addScript('core', 'files_client', 'core', true);
+				Util::addScript('core', 'files_fileinfo', 'core', true);
 
 
 				// If installed and background job is set to ajax, add dedicated script

+ 7 - 2
lib/public/Util.php

@@ -169,9 +169,10 @@ class Util {
 	 * @param string $application
 	 * @param string|null $file
 	 * @param string $afterAppId
+	 * @param bool $prepend
 	 * @since 4.0.0
 	 */
-	public static function addScript(string $application, string $file = null, string $afterAppId = 'core'): void {
+	public static function addScript(string $application, string $file = null, string $afterAppId = 'core', bool $prepend = false): void {
 		if (!empty($application)) {
 			$path = "$application/js/$file";
 		} else {
@@ -194,7 +195,11 @@ class Util {
 			self::$scriptDeps[$application]->addDep($afterAppId);
 		}
 
-		self::$scripts[$application][] = $path;
+		if ($prepend) {
+			array_unshift(self::$scripts[$application], $path);
+		} else {
+			self::$scripts[$application][] = $path;
+		}
 	}
 
 	/**