Passed
Push — master ( ffc85a...19e1ef )
by Joas
12:53 queued 12s
created
core/Controller/AutoCompleteController.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -39,85 +39,85 @@
 block discarded – undo
39 39
 use OCP\Share\IShare;
40 40
 
41 41
 class AutoCompleteController extends Controller {
42
-	/** @var ISearch */
43
-	private $collaboratorSearch;
44
-	/** @var IManager */
45
-	private $autoCompleteManager;
46
-	/** @var IEventDispatcher */
47
-	private $dispatcher;
42
+    /** @var ISearch */
43
+    private $collaboratorSearch;
44
+    /** @var IManager */
45
+    private $autoCompleteManager;
46
+    /** @var IEventDispatcher */
47
+    private $dispatcher;
48 48
 
49
-	public function __construct(
50
-		string $appName,
51
-		IRequest $request,
52
-		ISearch $collaboratorSearch,
53
-		IManager $autoCompleteManager,
54
-		IEventDispatcher $dispatcher
55
-	) {
56
-		parent::__construct($appName, $request);
49
+    public function __construct(
50
+        string $appName,
51
+        IRequest $request,
52
+        ISearch $collaboratorSearch,
53
+        IManager $autoCompleteManager,
54
+        IEventDispatcher $dispatcher
55
+    ) {
56
+        parent::__construct($appName, $request);
57 57
 
58
-		$this->collaboratorSearch = $collaboratorSearch;
59
-		$this->autoCompleteManager = $autoCompleteManager;
60
-		$this->dispatcher = $dispatcher;
61
-	}
58
+        $this->collaboratorSearch = $collaboratorSearch;
59
+        $this->autoCompleteManager = $autoCompleteManager;
60
+        $this->dispatcher = $dispatcher;
61
+    }
62 62
 
63
-	/**
64
-	 * @NoAdminRequired
65
-	 *
66
-	 * @param string $search
67
-	 * @param string $itemType
68
-	 * @param string $itemId
69
-	 * @param string|null $sorter can be piped, top prio first, e.g.: "commenters|share-recipients"
70
-	 * @param array $shareTypes
71
-	 * @param int $limit
72
-	 * @return DataResponse
73
-	 */
74
-	public function get($search, $itemType, $itemId, $sorter = null, $shareTypes = [IShare::TYPE_USER], $limit = 10): DataResponse {
75
-		// if enumeration/user listings are disabled, we'll receive an empty
76
-		// result from search() – thus nothing else to do here.
77
-		[$results,] = $this->collaboratorSearch->search($search, $shareTypes, false, $limit, 0);
63
+    /**
64
+     * @NoAdminRequired
65
+     *
66
+     * @param string $search
67
+     * @param string $itemType
68
+     * @param string $itemId
69
+     * @param string|null $sorter can be piped, top prio first, e.g.: "commenters|share-recipients"
70
+     * @param array $shareTypes
71
+     * @param int $limit
72
+     * @return DataResponse
73
+     */
74
+    public function get($search, $itemType, $itemId, $sorter = null, $shareTypes = [IShare::TYPE_USER], $limit = 10): DataResponse {
75
+        // if enumeration/user listings are disabled, we'll receive an empty
76
+        // result from search() – thus nothing else to do here.
77
+        [$results,] = $this->collaboratorSearch->search($search, $shareTypes, false, $limit, 0);
78 78
 
79
-		$event = new AutoCompleteEvent([
80
-			'search' => $search,
81
-			'results' => $results,
82
-			'itemType' => $itemType,
83
-			'itemId' => $itemId,
84
-			'sorter' => $sorter,
85
-			'shareTypes' => $shareTypes,
86
-			'limit' => $limit,
87
-		]);
88
-		$this->dispatcher->dispatch(IManager::class . '::filterResults', $event);
89
-		$results = $event->getResults();
79
+        $event = new AutoCompleteEvent([
80
+            'search' => $search,
81
+            'results' => $results,
82
+            'itemType' => $itemType,
83
+            'itemId' => $itemId,
84
+            'sorter' => $sorter,
85
+            'shareTypes' => $shareTypes,
86
+            'limit' => $limit,
87
+        ]);
88
+        $this->dispatcher->dispatch(IManager::class . '::filterResults', $event);
89
+        $results = $event->getResults();
90 90
 
91
-		$exactMatches = $results['exact'];
92
-		unset($results['exact']);
93
-		$results = array_merge_recursive($exactMatches, $results);
91
+        $exactMatches = $results['exact'];
92
+        unset($results['exact']);
93
+        $results = array_merge_recursive($exactMatches, $results);
94 94
 
95
-		if ($sorter !== null) {
96
-			$sorters = array_reverse(explode('|', $sorter));
97
-			$this->autoCompleteManager->runSorters($sorters, $results, [
98
-				'itemType' => $itemType,
99
-				'itemId' => $itemId,
100
-			]);
101
-		}
95
+        if ($sorter !== null) {
96
+            $sorters = array_reverse(explode('|', $sorter));
97
+            $this->autoCompleteManager->runSorters($sorters, $results, [
98
+                'itemType' => $itemType,
99
+                'itemId' => $itemId,
100
+            ]);
101
+        }
102 102
 
103
-		// transform to expected format
104
-		$results = $this->prepareResultArray($results);
103
+        // transform to expected format
104
+        $results = $this->prepareResultArray($results);
105 105
 
106
-		return new DataResponse($results);
107
-	}
106
+        return new DataResponse($results);
107
+    }
108 108
 
109 109
 
110
-	protected function prepareResultArray(array $results): array {
111
-		$output = [];
112
-		foreach ($results as $type => $subResult) {
113
-			foreach ($subResult as $result) {
114
-				$output[] = [
115
-					'id' => (string) $result['value']['shareWith'],
116
-					'label' => $result['label'],
117
-					'source' => $type,
118
-				];
119
-			}
120
-		}
121
-		return $output;
122
-	}
110
+    protected function prepareResultArray(array $results): array {
111
+        $output = [];
112
+        foreach ($results as $type => $subResult) {
113
+            foreach ($subResult as $result) {
114
+                $output[] = [
115
+                    'id' => (string) $result['value']['shareWith'],
116
+                    'label' => $result['label'],
117
+                    'source' => $type,
118
+                ];
119
+            }
120
+        }
121
+        return $output;
122
+    }
123 123
 }
Please login to merge, or discard this patch.