allow more than one plugin per share type

however it does not dedupe (appears too complex/expensive while we don't
havve the issue currently)

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2017-09-06 22:51:18 +02:00
parent f7713e5f3f
commit c55583d1b4
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
2 changed files with 12 additions and 8 deletions

View File

@ -198,6 +198,8 @@ class ShareesAPIController extends OCSController {
list($result, $hasMoreResults) = $this->collaboratorSearch->search($search, $shareTypes, $lookup, $this->limit, $this->offset);
// extra treatment for 'exact' subarray, with a single merge expected keys might be lost
$result['exact'] = array_merge($this->result['exact'], $result['exact']);
$this->result = array_merge($this->result, $result);
$response = new DataResponse($this->result);

View File

@ -35,10 +35,10 @@ class Search implements ISearch {
private $c;
protected $pluginList = [
Share::SHARE_TYPE_USER => UserPlugin::class,
Share::SHARE_TYPE_GROUP => GroupPlugin::class,
Share::SHARE_TYPE_EMAIL => MailPlugin::class,
Share::SHARE_TYPE_REMOTE => RemotePlugin::class,
Share::SHARE_TYPE_USER => [UserPlugin::class],
Share::SHARE_TYPE_GROUP => [GroupPlugin::class],
Share::SHARE_TYPE_EMAIL => [MailPlugin::class],
Share::SHARE_TYPE_REMOTE => [RemotePlugin::class],
];
public function __construct(IContainer $c) {
@ -55,9 +55,11 @@ class Search implements ISearch {
if(!isset($this->pluginList[$type])) {
continue;
}
/** @var ISearchPlugin $searchPlugin */
$searchPlugin = $this->c->resolve($this->pluginList[$type]);
$hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult);
foreach ($this->pluginList[$type] as $plugin) {
/** @var ISearchPlugin $searchPlugin */
$searchPlugin = $this->c->resolve($plugin);
$hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult);
}
}
// Get from lookup server, not a separate share type
@ -87,6 +89,6 @@ class Search implements ISearch {
if($shareType === null) {
throw new \InvalidArgumentException('Provided ShareType is invalid');
}
$this->pluginList[$shareType] = $pluginInfo['class'];
$this->pluginList[$shareType][] = $pluginInfo['class'];
}
}