]> source.dussan.org Git - nextcloud-server.git/commitdiff
Apply suggestions from code review
authorRobin Appelman <robin@icewind.nl>
Thu, 24 Mar 2022 16:34:13 +0000 (16:34 +0000)
committerRobin Appelman <robin@icewind.nl>
Thu, 24 Mar 2022 16:41:37 +0000 (17:41 +0100)
Co-authored-by: Louis <6653109+artonge@users.noreply.github.com>
Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
Signed-off-by: Robin Appelman <robin@icewind.nl>
apps/files_external/lib/Service/StoragesService.php
lib/private/Files/Config/MountProviderCollection.php
lib/private/Files/SetupManager.php
lib/public/Files/Config/IMountProviderCollection.php

index 6d03590d345e8263c5fc91e6b2008aca988bf58b..489192dbdc23c8ef2c47b76d3eb77997d383e946 100644 (file)
@@ -349,7 +349,7 @@ abstract class StoragesService {
         * @param string $mountType hook mount type param
         * @param array $applicableArray array of applicable users/groups for which to trigger the hook
         */
-       protected function triggerApplicableHooks($signal, $mountPoint, $mountType, $applicableArray) {
+       protected function triggerApplicableHooks($signal, $mountPoint, $mountType, $applicableArray): void {
                $this->eventDispatcher->dispatchTyped(new InvalidateMountCacheEvent(null));
                foreach ($applicableArray as $applicable) {
                        \OCP\Util::emitHook(
index a3c20bdbfbb0359ad36ed6e34f7789605b43230b..f88ffe2561d88671aeff5f7945aea542eac1d135 100644 (file)
@@ -79,7 +79,7 @@ class MountProviderCollection implements IMountProviderCollection, Emitter {
         * @param IMountProvider[] $providers
         * @return IMountPoint[]
         */
-       private function getMountsForFromProviders(IUser $user, array $providers): array {
+       private function getUserMountsForProviders(IUser $user, array $providers): array {
                $loader = $this->loader;
                $mounts = array_map(function (IMountProvider $provider) use ($user, $loader) {
                        return $provider->getMountsForUser($user, $loader);
@@ -94,14 +94,15 @@ class MountProviderCollection implements IMountProviderCollection, Emitter {
        }
 
        public function getMountsForUser(IUser $user): array {
-               return $this->getMountsForFromProviders($user, $this->providers);
+               return $this->getUserMountsForProviders($user, $this->providers);
        }
 
-       public function getMountsFromProvider(IUser $user, string $mountProviderClass): array {
-               $providers = array_filter($this->providers, function (IMountProvider $mountProvider) use ($mountProviderClass) {
-                       return get_class($mountProvider) === $mountProviderClass;
-               });
-               return $this->getMountsForFromProviders($user, $providers);
+       public function getUserMountsForProviderClass(IUser $user, string $mountProviderClass): array {
+               $providers = array_filter(
+                       $this->providers,
+                       fn (IMountProvider $mountProvider) => (get_class($mountProvider) === $mountProviderClass)
+               );
+               return $this->getUserMountsForProviders($user, $providers);
        }
 
        public function addMountForUser(IUser $user, IMountManager $mountManager, callable $providerFilter = null) {
index cb39ec90245db4a58e5d8a7619020d5249614e11..da50983da326a4a9aba0a13a7c72ca6aec03e706 100644 (file)
@@ -381,7 +381,7 @@ class SetupManager {
                        $setupProviders[] = $cachedMount->getMountProvider();
                        $currentProviders[] = $cachedMount->getMountProvider();
                        if ($cachedMount->getMountProvider()) {
-                               $mounts = $this->mountProviderCollection->getMountsFromProvider($user, $cachedMount->getMountProvider());
+                               $mounts = $this->mountProviderCollection->getUserMountsForProviderClass($user, $cachedMount->getMountProvider());
                        } else {
                                $this->logger->debug("mount at " . $cachedMount->getMountPoint() . " has no provider set, performing full setup");
                                $this->setupForUser($user);
@@ -396,7 +396,7 @@ class SetupManager {
                                        $setupProviders[] = $cachedMount->getMountProvider();
                                        $currentProviders[] = $cachedMount->getMountProvider();
                                        if ($cachedMount->getMountProvider()) {
-                                               $mounts = array_merge($mounts, $this->mountProviderCollection->getMountsFromProvider($user, $cachedMount->getMountProvider()));
+                                               $mounts = array_merge($mounts, $this->mountProviderCollection->getUserMountsForProviderClass($user, $cachedMount->getMountProvider()));
                                        } else {
                                                $this->logger->debug("mount at " . $cachedMount->getMountPoint() . " has no provider set, performing full setup");
                                                $this->setupForUser($user);
index 8a98c614a42c8b1e47ef9d7272cc1f6627cc588a..5894d06a388900a4572200ad214c8aadeef128dd 100644 (file)
@@ -46,7 +46,7 @@ interface IMountProviderCollection {
         * @return \OCP\Files\Mount\IMountPoint[]
         * @since 24.0.0
         */
-       public function getMountsFromProvider(IUser $user, string $mountProviderClass);
+       public function getUserMountsForProviderClass(IUser $user, string $mountProviderClass);
 
        /**
         * Get the configured home mount for this user