mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 00:12:30 -05:00
use array_filter instead of array_map + array_search
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
This commit is contained in:
parent
8766e4f242
commit
b22d4e6306
1 changed files with 5 additions and 5 deletions
|
|
@ -244,15 +244,15 @@ class ReferenceManager implements IReferenceManager {
|
|||
*/
|
||||
public function touchProvider(string $userId, string $providerId, ?int $timestamp = null): bool {
|
||||
$providers = $this->getDiscoverableProviders();
|
||||
$providerIds = array_map(static function (IDiscoverableReferenceProvider $provider) {
|
||||
return $provider->getId();
|
||||
}, $providers);
|
||||
if (array_search($providerId, $providerIds, true) !== false) {
|
||||
$configKey = 'provider-last-use_' . $providerId;
|
||||
$matchingProviders = array_filter($providers, static function (IDiscoverableReferenceProvider $provider) use ($providerId) {
|
||||
return $provider->getId() === $providerId;
|
||||
});
|
||||
if (!empty($matchingProviders)) {
|
||||
if ($timestamp === null) {
|
||||
$timestamp = time();
|
||||
}
|
||||
|
||||
$configKey = 'provider-last-use_' . $providerId;
|
||||
$this->config->setUserValue($userId, 'references', $configKey, (string) $timestamp);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue