]> source.dussan.org Git - nextcloud-server.git/commitdiff
Remove dependency on container, removing service locator antipattern
authorBernhard Posselt <Raydiation@users.noreply.github.com>
Wed, 2 Apr 2014 15:54:33 +0000 (17:54 +0200)
committerBernhard Posselt <Raydiation@users.noreply.github.com>
Wed, 2 Apr 2014 15:54:33 +0000 (17:54 +0200)
lib/public/appframework/controller.php

index 7c2219bd046ed3346243c49bd71237b5ea90d734..758f0a80083ce3adb3186759fb3dce762208a056 100644 (file)
@@ -38,10 +38,10 @@ use OCP\IRequest;
 abstract class Controller {
 
        /**
-        * app container for dependency injection
-        * @var \OCP\AppFramework\IAppContainer
+        * app name
+        * @var string
         */
-       protected $app;
+       protected $appName;
 
        /**
         * current request
@@ -51,11 +51,11 @@ abstract class Controller {
 
        /**
         * constructor of the controller
-        * @param IAppContainer $app interface to the app
+        * @param string $appName the name of the app
         * @param IRequest $request an instance of the request
         */
-       public function __construct(IAppContainer $app, IRequest $request){
-               $this->app = $app;
+       public function __construct($appName, IRequest $request){
+               $this->appName = $appName;
                $this->request = $request;
        }
 
@@ -136,7 +136,7 @@ abstract class Controller {
         */
        public function render($templateName, array $params=array(),
                                                        $renderAs='user', array $headers=array()){
-               $response = new TemplateResponse($this->app->getAppName(), $templateName);
+               $response = new TemplateResponse($this->appName, $templateName);
                $response->setParams($params);
                $response->renderAs($renderAs);