Remove dependency on container, removing service locator antipattern

This commit is contained in:
Bernhard Posselt 2014-04-02 17:54:33 +02:00
parent 16d10844cd
commit 5f3b8c45d7
1 changed files with 7 additions and 7 deletions

View 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);