Skip to content

Commit

Permalink
Remove unnecessary methods calls.
Browse files Browse the repository at this point in the history
The class can directly use it's protected properties.
  • Loading branch information
ADmad committed May 4, 2018
1 parent d9e8330 commit 5a43435
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/Controller/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public function __construct(ServerRequest $request = null, Response $response =
}

$this->setRequest($request ?: new ServerRequest());
$this->setResponse($response ?: new Response());
$this->response = $response ?: new Response();

if ($eventManager !== null) {
$this->setEventManager($eventManager);
Expand Down Expand Up @@ -734,7 +734,7 @@ public function redirect($url, $status = 302)
*/
public function setAction($action, ...$args)
{
$this->setRequest($this->getRequest()->withParam('action', $action));
$this->setRequest($this->request->withParam('action', $action));

return $this->$action(...$args);
}
Expand All @@ -754,7 +754,7 @@ public function render($view = null, $layout = null)
$builder->setTemplatePath($this->_viewPath());
}

if ($this->getRequest()->getParam('bare')) {
if ($this->request->getParam('bare')) {
$builder->enableAutoLayout(false);
}
$this->autoRender = false;
Expand All @@ -764,18 +764,18 @@ public function render($view = null, $layout = null)
return $event->getResult();
}
if ($event->isStopped()) {
return $this->getResponse();
return $this->response;
}

if ($builder->getTemplate() === null && $this->getRequest()->getParam('action')) {
$builder->setTemplate($this->getRequest()->getParam('action'));
if ($builder->getTemplate() === null && $this->request->getParam('action')) {
$builder->setTemplate($this->request->getParam('action'));
}

$this->View = $this->createView();
$contents = $this->View->render($view, $layout);
$this->setResponse($this->View->response->withStringBody($contents));
$this->response = $this->View->response->withStringBody($contents);

return $this->getResponse();
return $this->response;
}

/**
Expand All @@ -786,10 +786,10 @@ public function render($view = null, $layout = null)
protected function _viewPath()
{
$viewPath = $this->name;
if ($this->getRequest()->getParam('prefix')) {
if ($this->request->getParam('prefix')) {
$prefixes = array_map(
'Cake\Utility\Inflector::camelize',
explode('/', $this->getRequest()->getParam('prefix'))
explode('/', $this->request->getParam('prefix'))
);
$viewPath = implode(DIRECTORY_SEPARATOR, $prefixes) . DIRECTORY_SEPARATOR . $viewPath;
}
Expand All @@ -806,14 +806,14 @@ protected function _viewPath()
*/
public function referer($default = null, $local = false)
{
if (!$this->getRequest()) {
if (!$this->request) {
return Router::url($default, !$local);
}

$referer = $this->getRequest()->referer($local);
$referer = $this->request->referer($local);
if ($referer === '/' && $default && $default !== $referer) {
$url = Router::url($default, !$local);
$base = $this->getRequest()->getAttribute('base');
$base = $this->request->getAttribute('base');
if ($local && $base && strpos($url, $base) === 0) {
$url = substr($url, strlen($base));
if ($url[0] !== '/') {
Expand Down

0 comments on commit 5a43435

Please sign in to comment.