diff options
author | Olivier Paroz <github@oparoz.com> | 2015-07-27 23:13:05 +0300 |
---|---|---|
committer | Olivier Paroz <github@oparoz.com> | 2015-07-27 23:13:05 +0300 |
commit | 5eef87ec8ccd2d444571c16bb49d0dab6ebb9a15 (patch) | |
tree | 07dd62ad86537355fc2debc8e9a52f8c6ab06e43 | |
parent | ce4d186c54c27020a015af4fd091e609ba34e0af (diff) |
Reduce complexity of ConfigService::getFeaturesList()
-rw-r--r-- | environment/environment.php | 2 | ||||
-rw-r--r-- | service/configservice.php | 15 | ||||
-rw-r--r-- | service/filesservice.php | 2 |
3 files changed, 14 insertions, 5 deletions
diff --git a/environment/environment.php b/environment/environment.php index a2f0c9e3..2cf642c0 100644 --- a/environment/environment.php +++ b/environment/environment.php @@ -230,7 +230,7 @@ class Environment { public function getVirtualRootFolder() { $rootFolder = $this->userFolder; if (!empty($this->sharedNodeId)) { - $node = $this->getResourceFromId($this->sharedNodeId); + $node = $this->getSharedNode(); if ($node->getType() === 'dir') { $rootFolder = $node; } else { diff --git a/service/configservice.php b/service/configservice.php index 44248b17..cf676e63 100644 --- a/service/configservice.php +++ b/service/configservice.php @@ -72,9 +72,7 @@ class ConfigService extends FilesService { $featuresList = []; /** @var Folder $rootFolder */ $rootFolder = $this->environment->getVirtualRootFolder(); - if ($rootFolder && $this->isAllowedAndAvailable($rootFolder) - && $rootFolder->nodeExists($this->configName) - ) { + if ($this->isAllowedAndAvailable($rootFolder) && $this->configExists($rootFolder)) { try { $featuresList = $this->configParser->getFeaturesList($rootFolder, $this->configName); @@ -122,6 +120,17 @@ class ConfigService extends FilesService { } /** + * Determines if we have a configuration file to work with + * + * @param Folder $rootFolder + * + * @return bool + */ + private function configExists($rootFolder) { + return $rootFolder && $rootFolder->nodeExists($this->configName); + } + + /** * Returns an album configuration array * * Goes through all the parent folders until either we're told the album is private or we've diff --git a/service/filesservice.php b/service/filesservice.php index c9783bbf..f2d14e96 100644 --- a/service/filesservice.php +++ b/service/filesservice.php @@ -118,7 +118,7 @@ class FilesService extends Service { */ protected function isAllowedAndAvailable($node) { try { - return $this->isAllowed($node) && $this->isAvailable($node); + return $node && $this->isAllowed($node) && $this->isAvailable($node); } catch (\Exception $exception) { $message = 'The folder is not available: ' . $exception->getMessage(); $this->logger->error($message); |