aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2021-03-04 12:29:49 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2021-03-04 12:29:49 +0100
commitf04a2ce19f07a4b63adcfa6111bba4ea66f8cd72 (patch)
tree189a045746d5929aecdfededeafd263ca84eb154 /lib/private
parentc3361a2b131027e0133719f07a17fbae34445106 (diff)
downloadnextcloud-server-f04a2ce19f07a4b63adcfa6111bba4ea66f8cd72.tar.gz
nextcloud-server-f04a2ce19f07a4b63adcfa6111bba4ea66f8cd72.zip
Pimp ActionProviderStore
* Fix paradoxale condition * Add types * Move away from ILogger Makes psalm happy, and thus me happy Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Contacts/ContactsMenu/ActionProviderStore.php33
1 files changed, 16 insertions, 17 deletions
diff --git a/lib/private/Contacts/ContactsMenu/ActionProviderStore.php b/lib/private/Contacts/ContactsMenu/ActionProviderStore.php
index 5513dd06362..10b83adf92d 100644
--- a/lib/private/Contacts/ContactsMenu/ActionProviderStore.php
+++ b/lib/private/Contacts/ContactsMenu/ActionProviderStore.php
@@ -1,4 +1,6 @@
<?php
+
+declare(strict_types=1);
/**
* @copyright 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
*
@@ -28,9 +30,9 @@ use OC\App\AppManager;
use OC\Contacts\ContactsMenu\Providers\EMailProvider;
use OCP\AppFramework\QueryException;
use OCP\Contacts\ContactsMenu\IProvider;
-use OCP\ILogger;
use OCP\IServerContainer;
use OCP\IUser;
+use Psr\Log\LoggerInterface;
class ActionProviderStore {
@@ -40,15 +42,10 @@ class ActionProviderStore {
/** @var AppManager */
private $appManager;
- /** @var ILogger */
+ /** @var LoggerInterface */
private $logger;
- /**
- * @param IServerContainer $serverContainer
- * @param AppManager $appManager
- * @param ILogger $logger
- */
- public function __construct(IServerContainer $serverContainer, AppManager $appManager, ILogger $logger) {
+ public function __construct(IServerContainer $serverContainer, AppManager $appManager, LoggerInterface $logger) {
$this->serverContainer = $serverContainer;
$this->appManager = $appManager;
$this->logger = $logger;
@@ -59,7 +56,7 @@ class ActionProviderStore {
* @return IProvider[]
* @throws Exception
*/
- public function getProviders(IUser $user) {
+ public function getProviders(IUser $user): array {
$appClasses = $this->getAppProviderClasses($user);
$providerClasses = $this->getServerProviderClasses();
$allClasses = array_merge($providerClasses, $appClasses);
@@ -69,11 +66,13 @@ class ActionProviderStore {
try {
$providers[] = $this->serverContainer->query($class);
} catch (QueryException $ex) {
- $this->logger->logException($ex, [
- 'message' => "Could not load contacts menu action provider $class",
- 'app' => 'core',
- ]);
- throw new Exception("Could not load contacts menu action provider");
+ $this->logger->error('Could not load contacts menu action provider ' . $class,
+ [
+ 'app' => 'core',
+ 'exception' => $ex,
+ ]
+ );
+ throw new Exception('Could not load contacts menu action provider');
}
}
@@ -83,7 +82,7 @@ class ActionProviderStore {
/**
* @return string[]
*/
- private function getServerProviderClasses() {
+ private function getServerProviderClasses(): array {
return [
EMailProvider::class,
];
@@ -93,11 +92,11 @@ class ActionProviderStore {
* @param IUser $user
* @return string[]
*/
- private function getAppProviderClasses(IUser $user) {
+ private function getAppProviderClasses(IUser $user): array {
return array_reduce($this->appManager->getEnabledAppsForUser($user), function ($all, $appId) {
$info = $this->appManager->getAppInfo($appId);
- if (!isset($info['contactsmenu']) || !isset($info['contactsmenu'])) {
+ if (!isset($info['contactsmenu'])) {
// Nothing to add
return $all;
}