]> source.dussan.org Git - nextcloud-server.git/commitdiff
inject logger
authorRobin Appelman <icewind@owncloud.com>
Thu, 28 Jan 2016 12:07:19 +0000 (13:07 +0100)
committerRobin Appelman <icewind@owncloud.com>
Fri, 29 Jan 2016 13:51:30 +0000 (14:51 +0100)
apps/files_external/controller/globalstoragescontroller.php
apps/files_external/controller/storagescontroller.php
apps/files_external/controller/userglobalstoragescontroller.php
apps/files_external/controller/userstoragescontroller.php
apps/files_external/tests/controller/globalstoragescontrollertest.php
apps/files_external/tests/controller/userstoragescontrollertest.php

index 64bbf0feb3ffb87bf8ac7bb1ae6b20799eba965e..069e41a96b898ee31d051715e5e04ff4486c30fc 100644 (file)
@@ -24,6 +24,7 @@ namespace OCA\Files_External\Controller;
 
 
 use \OCP\IConfig;
+use OCP\ILogger;
 use \OCP\IUserSession;
 use \OCP\IRequest;
 use \OCP\IL10N;
@@ -46,18 +47,21 @@ class GlobalStoragesController extends StoragesController {
         * @param IRequest $request request object
         * @param IL10N $l10n l10n service
         * @param GlobalStoragesService $globalStoragesService storage service
+        * @param ILogger $logger
         */
        public function __construct(
                $AppName,
                IRequest $request,
                IL10N $l10n,
-               GlobalStoragesService $globalStoragesService
+               GlobalStoragesService $globalStoragesService,
+               ILogger $logger
        ) {
                parent::__construct(
                        $AppName,
                        $request,
                        $l10n,
-                       $globalStoragesService
+                       $globalStoragesService,
+                       $logger
                );
        }
 
index b09774ef515f3ac7d64b931e0597e21025f39acd..d71c4ff5ef7f85692d3ed18e94fe5dc79ba92fda 100644 (file)
@@ -25,6 +25,7 @@ namespace OCA\Files_External\Controller;
 
 
 use \OCP\IConfig;
+use OCP\ILogger;
 use OCP\IUser;
 use \OCP\IUserSession;
 use \OCP\IRequest;
@@ -60,6 +61,11 @@ abstract class StoragesController extends Controller {
         */
        protected $service;
 
+       /**
+        * @var ILogger
+        */
+       protected $logger;
+
        /**
         * Creates a new storages controller.
         *
@@ -67,16 +73,19 @@ abstract class StoragesController extends Controller {
         * @param IRequest $request request object
         * @param IL10N $l10n l10n service
         * @param StoragesService $storagesService storage service
+        * @param ILogger $logger
         */
        public function __construct(
                $AppName,
                IRequest $request,
                IL10N $l10n,
-               StoragesService $storagesService
+               StoragesService $storagesService,
+               ILogger $logger
        ) {
                parent::__construct($AppName, $request);
                $this->l10n = $l10n;
                $this->service = $storagesService;
+               $this->logger = $logger;
        }
 
        /**
@@ -115,7 +124,7 @@ abstract class StoragesController extends Controller {
                                $priority
                        );
                } catch (\InvalidArgumentException $e) {
-                       \OC::$server->getLogger()->logException($e);
+                       $this->logger->logException($e);
                        return new DataResponse(
                                [
                                        'message' => (string)$this->l10n->t('Invalid backend or authentication mechanism class')
@@ -129,7 +138,7 @@ abstract class StoragesController extends Controller {
         * Validate storage config
         *
         * @param StorageConfig $storage storage config
-        *
+        *1
         * @return DataResponse|null returns response in case of validation error
         */
        protected function validate(StorageConfig $storage) {
index 6b39b3dc92d5e5e14a858af1f5aae63021b63b9f..c6b51d9404790cb327d0a18c05da51a6589a6a28 100644 (file)
@@ -24,6 +24,7 @@ namespace OCA\Files_External\Controller;
 use OCA\Files_External\Lib\Auth\AuthMechanism;
 use OCA\Files_External\Lib\Auth\IUserProvided;
 use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
+use OCP\ILogger;
 use \OCP\IRequest;
 use \OCP\IL10N;
 use \OCP\AppFramework\Http\DataResponse;
@@ -57,13 +58,15 @@ class UserGlobalStoragesController extends StoragesController {
                IRequest $request,
                IL10N $l10n,
                UserGlobalStoragesService $userGlobalStoragesService,
-               IUserSession $userSession
+               IUserSession $userSession,
+               ILogger $logger
        ) {
                parent::__construct(
                        $AppName,
                        $request,
                        $l10n,
-                       $userGlobalStoragesService
+                       $userGlobalStoragesService,
+                       $logger
                );
                $this->userSession = $userSession;
        }
index ccf8bc24e0985528cd08752fe89d340062817169..2a2a0bc63a6420cef7f986c5f422e552b21060f6 100644 (file)
@@ -25,6 +25,7 @@ namespace OCA\Files_External\Controller;
 
 use OCA\Files_External\Lib\Auth\AuthMechanism;
 use \OCP\IConfig;
+use OCP\ILogger;
 use OCP\IUser;
 use \OCP\IUserSession;
 use \OCP\IRequest;
@@ -55,19 +56,22 @@ class UserStoragesController extends StoragesController {
         * @param IL10N $l10n l10n service
         * @param UserStoragesService $userStoragesService storage service
         * @param IUserSession $userSession
+        * @param ILogger $logger
         */
        public function __construct(
                $AppName,
                IRequest $request,
                IL10N $l10n,
                UserStoragesService $userStoragesService,
-               IUserSession $userSession
+               IUserSession $userSession,
+               ILogger $logger
        ) {
                parent::__construct(
                        $AppName,
                        $request,
                        $l10n,
-                       $userStoragesService
+                       $userStoragesService,
+                       $logger
                );
                $this->userSession = $userSession;
        }
index a3c911b511c867746f972dd1b9f7d22d03ba3476..9256569f22a75624b8a2b7b516afc0d9d78b978a 100644 (file)
@@ -41,7 +41,8 @@ class GlobalStoragesControllerTest extends StoragesControllerTest {
                        'files_external',
                        $this->getMock('\OCP\IRequest'),
                        $this->getMock('\OCP\IL10N'),
-                       $this->service
+                       $this->service,
+                       $this->getMock('\OCP\ILogger')
                );
        }
 }
index 671e019fea06d7509f68d435b77b0df26ae84153..342f6b853859610001248a55fe03c13905dca262 100644 (file)
@@ -49,7 +49,8 @@ class UserStoragesControllerTest extends StoragesControllerTest {
                        $this->getMock('\OCP\IRequest'),
                        $this->getMock('\OCP\IL10N'),
                        $this->service,
-                       $this->getMock('\OCP\IUserSession')
+                       $this->getMock('\OCP\IUserSession'),
+                       $this->getMock('\OCP\ILogger')
                );
        }