diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2017-09-06 16:09:29 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2017-09-26 23:10:23 +0200 |
commit | 4a96e222588104f647f911857e370b3ab692ea22 (patch) | |
tree | c0859c504c83b8e4e6f11a2d1c39974ca338e63b /lib/private/Collaboration/Collaborators/SearchResult.php | |
parent | 579c1476a3ec5d9b93130c84a5cc1438b9bd03a9 (diff) | |
download | nextcloud-server-4a96e222588104f647f911857e370b3ab692ea22.tar.gz nextcloud-server-4a96e222588104f647f911857e370b3ab692ea22.zip |
don't keep result types hard coded
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib/private/Collaboration/Collaborators/SearchResult.php')
-rw-r--r-- | lib/private/Collaboration/Collaborators/SearchResult.php | 41 |
1 files changed, 15 insertions, 26 deletions
diff --git a/lib/private/Collaboration/Collaborators/SearchResult.php b/lib/private/Collaboration/Collaborators/SearchResult.php index f3559c9327f..9c9503ea945 100644 --- a/lib/private/Collaboration/Collaborators/SearchResult.php +++ b/lib/private/Collaboration/Collaborators/SearchResult.php @@ -25,30 +25,21 @@ namespace OC\Collaboration\Collaborators; use OCP\Collaboration\Collaborators\ISearchResult; +use OCP\Collaboration\Collaborators\SearchResultType; class SearchResult implements ISearchResult { protected $result = [ - 'exact' => [ - 'users' => [], - 'groups' => [], - 'remotes' => [], - 'emails' => [], - 'circles' => [], - ], - 'users' => [], - 'groups' => [], - 'remotes' => [], - 'emails' => [], - 'lookup' => [], - 'circles' => [], + 'exact' => [], ]; protected $exactIdMatches = []; - public function addResultSet($type, array $matches, array $exactMatches = null) { + public function addResultSet(SearchResultType $type, array $matches, array $exactMatches = null) { + $type = $type->getLabel(); if(!isset($this->result[$type])) { - throw new \InvalidArgumentException('Invalid type provided'); + $this->result[$type] = []; + $this->result['exact'][$type] = []; } $this->result[$type] = array_merge($this->result[$type], $matches); @@ -57,17 +48,18 @@ class SearchResult implements ISearchResult { } } - public function markExactIdMatch($type) { - $this->exactIdMatches[$type] = 1; + public function markExactIdMatch(SearchResultType $type) { + $this->exactIdMatches[$type->getLabel()] = 1; } - public function hasExactIdMatch($type) { - return isset($this->exactIdMatches[$type]); + public function hasExactIdMatch(SearchResultType$type) { + return isset($this->exactIdMatches[$type->getLabel()]); } - public function hasResult($type, $collaboratorId) { + public function hasResult(SearchResultType $type, $collaboratorId) { + $type = $type->getLabel(); if(!isset($this->result[$type])) { - throw new \InvalidArgumentException('Invalid type provided'); + return false; } $resultArrays = [$this->result['exact'][$type], $this->result[$type]]; @@ -84,11 +76,8 @@ class SearchResult implements ISearchResult { return $this->result; } - public function unsetResult($type) { - if(!isset($this->result[$type])) { - throw new \InvalidArgumentException('Invalid type provided'); - } - + public function unsetResult(SearchResultType $type) { + $type = $type->getLabel(); $this->result[$type] = []; if(isset($this->$result['exact'][$type])) { $this->result['exact'][$type] = []; |