Completed
Pull Request — master (#8652)
by Julius
21:41
created
core/Controller/NavigationController.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -31,85 +31,85 @@
 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
-	private function generateETag($navigation) {
90
-		foreach ($navigation as &$nav) {
91
-			if ($nav['id'] === 'logout') {
92
-				$nav['href'] = 'logout';
93
-			}
94
-		}
95
-		return md5(json_encode($navigation));
96
-	}
89
+    private function generateETag($navigation) {
90
+        foreach ($navigation as &$nav) {
91
+            if ($nav['id'] === 'logout') {
92
+                $nav['href'] = 'logout';
93
+            }
94
+        }
95
+        return md5(json_encode($navigation));
96
+    }
97 97
 
98
-	/**
99
-	 * Rewrite href attribute of navigation entries to an absolute URL
100
-	 *
101
-	 * @param array $navigation
102
-	 * @return array
103
-	 */
104
-	private function rewriteToAbsoluteUrls(array $navigation): array {
105
-		foreach ($navigation as &$entry) {
106
-			if (0 !== strpos($entry['href'], $this->urlGenerator->getBaseUrl())) {
107
-				$entry['href'] = $this->urlGenerator->getAbsoluteURL($entry['href']);
108
-			}
109
-			if (0 !== strpos($entry['icon'], $this->urlGenerator->getBaseUrl())) {
110
-				$entry['icon'] = $this->urlGenerator->getAbsoluteURL($entry['icon']);
111
-			}
112
-		}
113
-		return $navigation;
114
-	}
98
+    /**
99
+     * Rewrite href attribute of navigation entries to an absolute URL
100
+     *
101
+     * @param array $navigation
102
+     * @return array
103
+     */
104
+    private function rewriteToAbsoluteUrls(array $navigation): array {
105
+        foreach ($navigation as &$entry) {
106
+            if (0 !== strpos($entry['href'], $this->urlGenerator->getBaseUrl())) {
107
+                $entry['href'] = $this->urlGenerator->getAbsoluteURL($entry['href']);
108
+            }
109
+            if (0 !== strpos($entry['icon'], $this->urlGenerator->getBaseUrl())) {
110
+                $entry['icon'] = $this->urlGenerator->getAbsoluteURL($entry['icon']);
111
+            }
112
+        }
113
+        return $navigation;
114
+    }
115 115
 }
Please login to merge, or discard this patch.