@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | class TemplateResponse extends Response { |
| 39 | 39 | |
| 40 | - const EVENT_LOAD_ADDITIONAL_SCRIPTS = self::class . '::loadAdditionalScripts'; |
|
| 41 | - const EVENT_LOAD_ADDITIONAL_SCRIPTS_LOGGEDIN = self::class . '::loadAdditionalScriptsLoggedIn'; |
|
| 40 | + const EVENT_LOAD_ADDITIONAL_SCRIPTS = self::class.'::loadAdditionalScripts'; |
|
| 41 | + const EVENT_LOAD_ADDITIONAL_SCRIPTS_LOGGEDIN = self::class.'::loadAdditionalScriptsLoggedIn'; |
|
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * name of the template |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | * @param string $renderAs how the page should be rendered, defaults to user |
| 74 | 74 | * @since 6.0.0 - parameters $params and $renderAs were added in 7.0.0 |
| 75 | 75 | */ |
| 76 | - public function __construct($appName, $templateName, array $params=array(), |
|
| 77 | - $renderAs='user') { |
|
| 76 | + public function __construct($appName, $templateName, array $params = array(), |
|
| 77 | + $renderAs = 'user') { |
|
| 78 | 78 | $this->templateName = $templateName; |
| 79 | 79 | $this->appName = $appName; |
| 80 | 80 | $this->params = $params; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @return TemplateResponse Reference to this object |
| 90 | 90 | * @since 6.0.0 - return value was added in 7.0.0 |
| 91 | 91 | */ |
| 92 | - public function setParams(array $params){ |
|
| 92 | + public function setParams(array $params) { |
|
| 93 | 93 | $this->params = $params; |
| 94 | 94 | |
| 95 | 95 | return $this; |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @return array the params |
| 102 | 102 | * @since 6.0.0 |
| 103 | 103 | */ |
| 104 | - public function getParams(){ |
|
| 104 | + public function getParams() { |
|
| 105 | 105 | return $this->params; |
| 106 | 106 | } |
| 107 | 107 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @return string the name of the used template |
| 112 | 112 | * @since 6.0.0 |
| 113 | 113 | */ |
| 114 | - public function getTemplateName(){ |
|
| 114 | + public function getTemplateName() { |
|
| 115 | 115 | return $this->templateName; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | * @return TemplateResponse Reference to this object |
| 126 | 126 | * @since 6.0.0 - return value was added in 7.0.0 |
| 127 | 127 | */ |
| 128 | - public function renderAs($renderAs){ |
|
| 128 | + public function renderAs($renderAs) { |
|
| 129 | 129 | $this->renderAs = $renderAs; |
| 130 | 130 | |
| 131 | 131 | return $this; |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @return string the renderAs value |
| 138 | 138 | * @since 6.0.0 |
| 139 | 139 | */ |
| 140 | - public function getRenderAs(){ |
|
| 140 | + public function getRenderAs() { |
|
| 141 | 141 | return $this->renderAs; |
| 142 | 142 | } |
| 143 | 143 | |
@@ -147,13 +147,13 @@ discard block |
||
| 147 | 147 | * @return string the rendered html |
| 148 | 148 | * @since 6.0.0 |
| 149 | 149 | */ |
| 150 | - public function render(){ |
|
| 150 | + public function render() { |
|
| 151 | 151 | // \OCP\Template needs an empty string instead of 'blank' for an unwrapped response |
| 152 | 152 | $renderAs = $this->renderAs === 'blank' ? '' : $this->renderAs; |
| 153 | 153 | |
| 154 | 154 | $template = new \OCP\Template($this->appName, $this->templateName, $renderAs); |
| 155 | 155 | |
| 156 | - foreach($this->params as $key => $value){ |
|
| 156 | + foreach ($this->params as $key => $value) { |
|
| 157 | 157 | $template->assign($key, $value); |
| 158 | 158 | } |
| 159 | 159 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param array $urlParams |
| 83 | 83 | * @param ServerContainer|null $server |
| 84 | 84 | */ |
| 85 | - public function __construct($appName, $urlParams = array(), ServerContainer $server = null){ |
|
| 85 | + public function __construct($appName, $urlParams = array(), ServerContainer $server = null) { |
|
| 86 | 86 | parent::__construct(); |
| 87 | 87 | $this['AppName'] = $appName; |
| 88 | 88 | $this['urlParams'] = $urlParams; |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | /** |
| 105 | 105 | * Core services |
| 106 | 106 | */ |
| 107 | - $this->registerService(IOutput::class, function(){ |
|
| 107 | + $this->registerService(IOutput::class, function() { |
|
| 108 | 108 | return new Output($this->getServer()->getWebRoot()); |
| 109 | 109 | }); |
| 110 | 110 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | return $this->getServer()->getUserFolder(); |
| 113 | 113 | }); |
| 114 | 114 | |
| 115 | - $this->registerService(IAppData::class, function (SimpleContainer $c) { |
|
| 115 | + $this->registerService(IAppData::class, function(SimpleContainer $c) { |
|
| 116 | 116 | return $this->getServer()->getAppDataDir($c->query('AppName')); |
| 117 | 117 | }); |
| 118 | 118 | |
@@ -121,41 +121,41 @@ discard block |
||
| 121 | 121 | }); |
| 122 | 122 | |
| 123 | 123 | // Log wrapper |
| 124 | - $this->registerService(ILogger::class, function ($c) { |
|
| 124 | + $this->registerService(ILogger::class, function($c) { |
|
| 125 | 125 | return new OC\AppFramework\Logger($this->server->query(ILogger::class), $c->query('AppName')); |
| 126 | 126 | }); |
| 127 | 127 | |
| 128 | - $this->registerService(IServerContainer::class, function () { |
|
| 128 | + $this->registerService(IServerContainer::class, function() { |
|
| 129 | 129 | return $this->getServer(); |
| 130 | 130 | }); |
| 131 | 131 | $this->registerAlias('ServerContainer', IServerContainer::class); |
| 132 | 132 | |
| 133 | - $this->registerService(\OCP\WorkflowEngine\IManager::class, function ($c) { |
|
| 133 | + $this->registerService(\OCP\WorkflowEngine\IManager::class, function($c) { |
|
| 134 | 134 | return $c->query(Manager::class); |
| 135 | 135 | }); |
| 136 | 136 | |
| 137 | - $this->registerService(\OCP\AppFramework\IAppContainer::class, function ($c) { |
|
| 137 | + $this->registerService(\OCP\AppFramework\IAppContainer::class, function($c) { |
|
| 138 | 138 | return $c; |
| 139 | 139 | }); |
| 140 | 140 | |
| 141 | 141 | // commonly used attributes |
| 142 | - $this->registerService('UserId', function ($c) { |
|
| 142 | + $this->registerService('UserId', function($c) { |
|
| 143 | 143 | return $c->query(IUserSession::class)->getSession()->get('user_id'); |
| 144 | 144 | }); |
| 145 | 145 | |
| 146 | - $this->registerService('WebRoot', function ($c) { |
|
| 146 | + $this->registerService('WebRoot', function($c) { |
|
| 147 | 147 | return $c->query('ServerContainer')->getWebRoot(); |
| 148 | 148 | }); |
| 149 | 149 | |
| 150 | - $this->registerService('OC_Defaults', function ($c) { |
|
| 150 | + $this->registerService('OC_Defaults', function($c) { |
|
| 151 | 151 | return $c->getServer()->getThemingDefaults(); |
| 152 | 152 | }); |
| 153 | 153 | |
| 154 | - $this->registerService(IConfig::class, function ($c) { |
|
| 154 | + $this->registerService(IConfig::class, function($c) { |
|
| 155 | 155 | return $c->query(OC\GlobalScale\Config::class); |
| 156 | 156 | }); |
| 157 | 157 | |
| 158 | - $this->registerService('Protocol', function($c){ |
|
| 158 | + $this->registerService('Protocol', function($c) { |
|
| 159 | 159 | /** @var \OC\Server $server */ |
| 160 | 160 | $server = $c->query('ServerContainer'); |
| 161 | 161 | $protocol = $server->getRequest()->getHttpProtocol(); |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * Middleware |
| 183 | 183 | */ |
| 184 | 184 | $this->registerService('MiddlewareDispatcher', function(SimpleContainer $c) { |
| 185 | - $server = $this->getServer(); |
|
| 185 | + $server = $this->getServer(); |
|
| 186 | 186 | |
| 187 | 187 | $dispatcher = new MiddlewareDispatcher(); |
| 188 | 188 | $dispatcher->registerMiddleware( |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | $c->query(\OC\AppFramework\Middleware\AdditionalScriptsMiddleware::class) |
| 266 | 266 | ); |
| 267 | 267 | |
| 268 | - foreach($this->middleWares as $middleWare) { |
|
| 268 | + foreach ($this->middleWares as $middleWare) { |
|
| 269 | 269 | $dispatcher->registerMiddleware($c[$middleWare]); |
| 270 | 270 | } |
| 271 | 271 | |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | * @return mixed |
| 334 | 334 | */ |
| 335 | 335 | public function log($message, $level) { |
| 336 | - switch($level){ |
|
| 336 | + switch ($level) { |
|
| 337 | 337 | case 'debug': |
| 338 | 338 | $level = ILogger::DEBUG; |
| 339 | 339 | break; |
@@ -399,12 +399,12 @@ discard block |
||
| 399 | 399 | return parent::query($name); |
| 400 | 400 | } else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) { |
| 401 | 401 | return parent::query($name); |
| 402 | - } else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']) . '\\') === 0) { |
|
| 402 | + } else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']).'\\') === 0) { |
|
| 403 | 403 | return parent::query($name); |
| 404 | 404 | } |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - throw new QueryException('Could not resolve ' . $name . '!' . |
|
| 407 | + throw new QueryException('Could not resolve '.$name.'!'. |
|
| 408 | 408 | ' Class can not be instantiated', 1); |
| 409 | 409 | } |
| 410 | 410 | } |