Completed
Push — master ( d1314b...8a1471 )
by
unknown
29:50
created
core/Controller/JsController.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -27,77 +27,77 @@
 block discarded – undo
27 27
 
28 28
 #[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
29 29
 class JsController extends Controller {
30
-	protected IAppData $appData;
30
+    protected IAppData $appData;
31 31
 
32
-	public function __construct(
33
-		string $appName,
34
-		IRequest $request,
35
-		Factory $appDataFactory,
36
-		protected ITimeFactory $timeFactory,
37
-	) {
38
-		parent::__construct($appName, $request);
32
+    public function __construct(
33
+        string $appName,
34
+        IRequest $request,
35
+        Factory $appDataFactory,
36
+        protected ITimeFactory $timeFactory,
37
+    ) {
38
+        parent::__construct($appName, $request);
39 39
 
40
-		$this->appData = $appDataFactory->get('js');
41
-	}
40
+        $this->appData = $appDataFactory->get('js');
41
+    }
42 42
 
43
-	/**
44
-	 * @NoSameSiteCookieRequired
45
-	 * @NoTwoFactorRequired
46
-	 *
47
-	 * @param string $fileName js filename with extension
48
-	 * @param string $appName js folder name
49
-	 * @return FileDisplayResponse|NotFoundResponse
50
-	 */
51
-	#[PublicPage]
52
-	#[NoCSRFRequired]
53
-	#[FrontpageRoute(verb: 'GET', url: '/js/{appName}/{fileName}')]
54
-	public function getJs(string $fileName, string $appName): Response {
55
-		try {
56
-			$folder = $this->appData->getFolder($appName);
57
-			$gzip = false;
58
-			$file = $this->getFile($folder, $fileName, $gzip);
59
-		} catch (NotFoundException $e) {
60
-			return new NotFoundResponse();
61
-		}
43
+    /**
44
+     * @NoSameSiteCookieRequired
45
+     * @NoTwoFactorRequired
46
+     *
47
+     * @param string $fileName js filename with extension
48
+     * @param string $appName js folder name
49
+     * @return FileDisplayResponse|NotFoundResponse
50
+     */
51
+    #[PublicPage]
52
+    #[NoCSRFRequired]
53
+    #[FrontpageRoute(verb: 'GET', url: '/js/{appName}/{fileName}')]
54
+    public function getJs(string $fileName, string $appName): Response {
55
+        try {
56
+            $folder = $this->appData->getFolder($appName);
57
+            $gzip = false;
58
+            $file = $this->getFile($folder, $fileName, $gzip);
59
+        } catch (NotFoundException $e) {
60
+            return new NotFoundResponse();
61
+        }
62 62
 
63
-		$response = new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => 'application/javascript']);
64
-		if ($gzip) {
65
-			$response->addHeader('Content-Encoding', 'gzip');
66
-		}
63
+        $response = new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => 'application/javascript']);
64
+        if ($gzip) {
65
+            $response->addHeader('Content-Encoding', 'gzip');
66
+        }
67 67
 
68
-		$ttl = 31536000;
69
-		$response->addHeader('Cache-Control', 'max-age=' . $ttl . ', immutable');
68
+        $ttl = 31536000;
69
+        $response->addHeader('Cache-Control', 'max-age=' . $ttl . ', immutable');
70 70
 
71
-		$expires = new \DateTime();
72
-		$expires->setTimestamp($this->timeFactory->getTime());
73
-		$expires->add(new \DateInterval('PT' . $ttl . 'S'));
74
-		$response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
75
-		return $response;
76
-	}
71
+        $expires = new \DateTime();
72
+        $expires->setTimestamp($this->timeFactory->getTime());
73
+        $expires->add(new \DateInterval('PT' . $ttl . 'S'));
74
+        $response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
75
+        return $response;
76
+    }
77 77
 
78
-	/**
79
-	 * @NoTwoFactorRequired
80
-	 *
81
-	 * @param ISimpleFolder $folder
82
-	 * @param string $fileName
83
-	 * @param bool $gzip is set to true if we use the gzip file
84
-	 * @return ISimpleFile
85
-	 *
86
-	 * @throws NotFoundException
87
-	 */
88
-	private function getFile(ISimpleFolder $folder, string $fileName, bool &$gzip): ISimpleFile {
89
-		$encoding = $this->request->getHeader('Accept-Encoding');
78
+    /**
79
+     * @NoTwoFactorRequired
80
+     *
81
+     * @param ISimpleFolder $folder
82
+     * @param string $fileName
83
+     * @param bool $gzip is set to true if we use the gzip file
84
+     * @return ISimpleFile
85
+     *
86
+     * @throws NotFoundException
87
+     */
88
+    private function getFile(ISimpleFolder $folder, string $fileName, bool &$gzip): ISimpleFile {
89
+        $encoding = $this->request->getHeader('Accept-Encoding');
90 90
 
91
-		if (str_contains($encoding, 'gzip')) {
92
-			try {
93
-				$gzip = true;
94
-				return $folder->getFile($fileName . '.gzip'); # Safari doesn't like .gz
95
-			} catch (NotFoundException $e) {
96
-				// continue
97
-			}
98
-		}
91
+        if (str_contains($encoding, 'gzip')) {
92
+            try {
93
+                $gzip = true;
94
+                return $folder->getFile($fileName . '.gzip'); # Safari doesn't like .gz
95
+            } catch (NotFoundException $e) {
96
+                // continue
97
+            }
98
+        }
99 99
 
100
-		$gzip = false;
101
-		return $folder->getFile($fileName);
102
-	}
100
+        $gzip = false;
101
+        return $folder->getFile($fileName);
102
+    }
103 103
 }
Please login to merge, or discard this patch.