Completed
Pull Request — master (#8652)
by Julius
36:11 queued 15:12
created
core/Controller/NavigationController.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -31,91 +31,91 @@
 block discarded – undo
31 31
 
32 32
 class NavigationController extends OCSController {
33 33
 
34
-	/** @var INavigationManager */
35
-	private $navigationManager;
34
+    /** @var INavigationManager */
35
+    private $navigationManager;
36 36
 
37
-	/** @var IURLGenerator */
38
-	private $urlGenerator;
37
+    /** @var IURLGenerator */
38
+    private $urlGenerator;
39 39
 
40
-	public function __construct(string $appName, IRequest $request, INavigationManager $navigationManager, IURLGenerator $urlGenerator) {
41
-		parent::__construct($appName, $request);
42
-		$this->navigationManager = $navigationManager;
43
-		$this->urlGenerator = $urlGenerator;
44
-	}
40
+    public function __construct(string $appName, IRequest $request, INavigationManager $navigationManager, IURLGenerator $urlGenerator) {
41
+        parent::__construct($appName, $request);
42
+        $this->navigationManager = $navigationManager;
43
+        $this->urlGenerator = $urlGenerator;
44
+    }
45 45
 
46
-	/**
47
-	 * @NoAdminRequired
48
-	 * @NoCSRFRequired
49
-	 *
50
-	 * @param bool $absolute
51
-	 * @return DataResponse
52
-	 */
53
-	public function getAppsNavigation(bool $absolute = false): DataResponse {
54
-		$navigation = $this->navigationManager->getAll();
55
-		if ($absolute) {
56
-			$navigation = $this->rewriteToAbsoluteUrls($navigation);
57
-		}
46
+    /**
47
+     * @NoAdminRequired
48
+     * @NoCSRFRequired
49
+     *
50
+     * @param bool $absolute
51
+     * @return DataResponse
52
+     */
53
+    public function getAppsNavigation(bool $absolute = false): DataResponse {
54
+        $navigation = $this->navigationManager->getAll();
55
+        if ($absolute) {
56
+            $navigation = $this->rewriteToAbsoluteUrls($navigation);
57
+        }
58 58
 
59
-		$etag = $this->generateETag($navigation);
60
-		if ($this->request->getHeader('If-None-Match') === $etag) {
61
-			return new DataResponse([], Http::STATUS_NOT_MODIFIED);
62
-		}
63
-		$response = new DataResponse($navigation);
64
-		$response->setETag($etag);
65
-		return $response;
66
-	}
59
+        $etag = $this->generateETag($navigation);
60
+        if ($this->request->getHeader('If-None-Match') === $etag) {
61
+            return new DataResponse([], Http::STATUS_NOT_MODIFIED);
62
+        }
63
+        $response = new DataResponse($navigation);
64
+        $response->setETag($etag);
65
+        return $response;
66
+    }
67 67
 
68
-	/**
69
-	 * @NoAdminRequired
70
-	 * @NoCSRFRequired
71
-	 *
72
-	 * @param bool $absolute
73
-	 * @return DataResponse
74
-	 */
75
-	public function getSettingsNavigation(bool $absolute = false): DataResponse {
76
-		$navigation = $this->navigationManager->getAll('settings');
77
-		if ($absolute) {
78
-			$navigation = $this->rewriteToAbsoluteUrls($navigation);
79
-		}
80
-		$etag = $this->generateETag($navigation);
81
-		if ($this->request->getHeader('If-None-Match') === $etag) {
82
-			return new DataResponse([], Http::STATUS_NOT_MODIFIED);
83
-		}
84
-		$response = new DataResponse($navigation);
85
-		$response->setETag($etag);
86
-		return $response;
87
-	}
68
+    /**
69
+     * @NoAdminRequired
70
+     * @NoCSRFRequired
71
+     *
72
+     * @param bool $absolute
73
+     * @return DataResponse
74
+     */
75
+    public function getSettingsNavigation(bool $absolute = false): DataResponse {
76
+        $navigation = $this->navigationManager->getAll('settings');
77
+        if ($absolute) {
78
+            $navigation = $this->rewriteToAbsoluteUrls($navigation);
79
+        }
80
+        $etag = $this->generateETag($navigation);
81
+        if ($this->request->getHeader('If-None-Match') === $etag) {
82
+            return new DataResponse([], Http::STATUS_NOT_MODIFIED);
83
+        }
84
+        $response = new DataResponse($navigation);
85
+        $response->setETag($etag);
86
+        return $response;
87
+    }
88 88
 
89
-	/**
90
-	 * Generate an ETag for a list of navigation entries
91
-	 *
92
-	 * @param array $navigation
93
-	 * @return string
94
-	 */
95
-	private function generateETag(array $navigation): string {
96
-		foreach ($navigation as &$nav) {
97
-			if ($nav['id'] === 'logout') {
98
-				$nav['href'] = 'logout';
99
-			}
100
-		}
101
-		return md5(json_encode($navigation));
102
-	}
89
+    /**
90
+     * Generate an ETag for a list of navigation entries
91
+     *
92
+     * @param array $navigation
93
+     * @return string
94
+     */
95
+    private function generateETag(array $navigation): string {
96
+        foreach ($navigation as &$nav) {
97
+            if ($nav['id'] === 'logout') {
98
+                $nav['href'] = 'logout';
99
+            }
100
+        }
101
+        return md5(json_encode($navigation));
102
+    }
103 103
 
104
-	/**
105
-	 * Rewrite href attribute of navigation entries to an absolute URL
106
-	 *
107
-	 * @param array $navigation
108
-	 * @return array
109
-	 */
110
-	private function rewriteToAbsoluteUrls(array $navigation): array {
111
-		foreach ($navigation as &$entry) {
112
-			if (0 !== strpos($entry['href'], $this->urlGenerator->getBaseUrl())) {
113
-				$entry['href'] = $this->urlGenerator->getAbsoluteURL($entry['href']);
114
-			}
115
-			if (0 !== strpos($entry['icon'], $this->urlGenerator->getBaseUrl())) {
116
-				$entry['icon'] = $this->urlGenerator->getAbsoluteURL($entry['icon']);
117
-			}
118
-		}
119
-		return $navigation;
120
-	}
104
+    /**
105
+     * Rewrite href attribute of navigation entries to an absolute URL
106
+     *
107
+     * @param array $navigation
108
+     * @return array
109
+     */
110
+    private function rewriteToAbsoluteUrls(array $navigation): array {
111
+        foreach ($navigation as &$entry) {
112
+            if (0 !== strpos($entry['href'], $this->urlGenerator->getBaseUrl())) {
113
+                $entry['href'] = $this->urlGenerator->getAbsoluteURL($entry['href']);
114
+            }
115
+            if (0 !== strpos($entry['icon'], $this->urlGenerator->getBaseUrl())) {
116
+                $entry['icon'] = $this->urlGenerator->getAbsoluteURL($entry['icon']);
117
+            }
118
+        }
119
+        return $navigation;
120
+    }
121 121
 }
Please login to merge, or discard this patch.