Skip to content

Commit 5a43435

Browse files
committed
Remove unnecessary methods calls.
The class can directly use it's protected properties.
1 parent d9e8330 commit 5a43435

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/Controller/Controller.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public function __construct(ServerRequest $request = null, Response $response =
252252
}
253253

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

257257
if ($eventManager !== null) {
258258
$this->setEventManager($eventManager);
@@ -734,7 +734,7 @@ public function redirect($url, $status = 302)
734734
*/
735735
public function setAction($action, ...$args)
736736
{
737-
$this->setRequest($this->getRequest()->withParam('action', $action));
737+
$this->setRequest($this->request->withParam('action', $action));
738738

739739
return $this->$action(...$args);
740740
}
@@ -754,7 +754,7 @@ public function render($view = null, $layout = null)
754754
$builder->setTemplatePath($this->_viewPath());
755755
}
756756

757-
if ($this->getRequest()->getParam('bare')) {
757+
if ($this->request->getParam('bare')) {
758758
$builder->enableAutoLayout(false);
759759
}
760760
$this->autoRender = false;
@@ -764,18 +764,18 @@ public function render($view = null, $layout = null)
764764
return $event->getResult();
765765
}
766766
if ($event->isStopped()) {
767-
return $this->getResponse();
767+
return $this->response;
768768
}
769769

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

774774
$this->View = $this->createView();
775775
$contents = $this->View->render($view, $layout);
776-
$this->setResponse($this->View->response->withStringBody($contents));
776+
$this->response = $this->View->response->withStringBody($contents);
777777

778-
return $this->getResponse();
778+
return $this->response;
779779
}
780780

781781
/**
@@ -786,10 +786,10 @@ public function render($view = null, $layout = null)
786786
protected function _viewPath()
787787
{
788788
$viewPath = $this->name;
789-
if ($this->getRequest()->getParam('prefix')) {
789+
if ($this->request->getParam('prefix')) {
790790
$prefixes = array_map(
791791
'Cake\Utility\Inflector::camelize',
792-
explode('/', $this->getRequest()->getParam('prefix'))
792+
explode('/', $this->request->getParam('prefix'))
793793
);
794794
$viewPath = implode(DIRECTORY_SEPARATOR, $prefixes) . DIRECTORY_SEPARATOR . $viewPath;
795795
}
@@ -806,14 +806,14 @@ protected function _viewPath()
806806
*/
807807
public function referer($default = null, $local = false)
808808
{
809-
if (!$this->getRequest()) {
809+
if (!$this->request) {
810810
return Router::url($default, !$local);
811811
}
812812

813-
$referer = $this->getRequest()->referer($local);
813+
$referer = $this->request->referer($local);
814814
if ($referer === '/' && $default && $default !== $referer) {
815815
$url = Router::url($default, !$local);
816-
$base = $this->getRequest()->getAttribute('base');
816+
$base = $this->request->getAttribute('base');
817817
if ($local && $base && strpos($url, $base) === 0) {
818818
$url = substr($url, strlen($base));
819819
if ($url[0] !== '/') {

0 commit comments

Comments
 (0)