Skip to content
Permalink
Browse files

Don't use deprecated APIs internally.

Don't use deprecated properties and methods internally.
  • Loading branch information...
markstory committed Oct 1, 2016
1 parent bf923a8 commit 41017955146903b337df00c509a12a1c804e0fbb
Showing with 19 additions and 23 deletions.
  1. +19 −23 src/Controller/Controller.php
@@ -235,8 +235,8 @@ public function __construct(Request $request = null, Response $response = null,
$this->name = $name;
}
if ($this->name === null && isset($request->params['controller'])) {
$this->name = $request->params['controller'];
if ($this->name === null && $request && $request->param('controller')) {
$this->name = $request->param('controller');
}
if ($this->name === null) {
@@ -401,10 +401,10 @@ public function __set($name, $value)
public function setRequest(Request $request)
{
$this->request = $request;
$this->plugin = isset($request->params['plugin']) ? $request->params['plugin'] : null;
$this->plugin = $request->param('plugin') ?: null;
if (isset($request->params['pass'])) {
$this->passedArgs = $request->params['pass'];
if ($request->param('pass')) {
$this->passedArgs = $request->param('pass');
}
}
@@ -422,17 +422,17 @@ public function invokeAction()
if (!isset($request)) {
throw new LogicException('No Request object configured. Cannot invoke action');
}
if (!$this->isAction($request->params['action'])) {
if (!$this->isAction($request->param('action'))) {
throw new MissingActionException([
'controller' => $this->name . "Controller",
'action' => $request->params['action'],
'prefix' => isset($request->params['prefix']) ? $request->params['prefix'] : '',
'plugin' => $request->params['plugin'],
'action' => $request->param('action'),
'prefix' => $request->param('prefix') ?: '',
'plugin' => $request->param('plugin'),
]);
}
$callable = [$this, $request->params['action']];
$callable = [$this, $request->param('action')];
return call_user_func_array($callable, $request->params['pass']);
return call_user_func_array($callable, $request->param('pass'));
}
/**
@@ -574,7 +574,7 @@ public function redirect($url, $status = 302)
*/
public function setAction($action)
{
$this->request->params['action'] = $action;
$this->request = $this->request->withParam('action', $action);
$args = func_get_args();
unset($args[0]);
@@ -611,10 +611,8 @@ public function render($view = null, $layout = null)
return $this->response;
}
if ($builder->template() === null &&
isset($this->request->params['action'])
) {
$builder->template($this->request->params['action']);
if ($builder->template() === null && $this->request->param('action')) {
$builder->template($this->request->param('action'));
}
$this->View = $this->createView();
@@ -631,10 +629,10 @@ public function render($view = null, $layout = null)
protected function _viewPath()
{
$viewPath = $this->name;
if (!empty($this->request->params['prefix'])) {
if ($this->request->param('prefix')) {
$prefixes = array_map(
'Cake\Utility\Inflector::camelize',
explode('/', $this->request->params['prefix'])
explode('/', $this->request->param('prefix'))
);
$viewPath = implode(DIRECTORY_SEPARATOR, $prefixes) . DIRECTORY_SEPARATOR . $viewPath;
}
@@ -658,11 +656,9 @@ public function referer($default = null, $local = false)
$referer = $this->request->referer($local);
if ($referer === '/' && $default && $default !== $referer) {
$url = Router::url($default, !$local);
if ($local
&& $this->request->base
&& strpos($url, $this->request->base) === 0
) {
$url = substr($url, strlen($this->request->base));
$base = $this->request->getAttribute('base');
if ($local && $base && strpos($url, $base) === 0) {
$url = substr($url, strlen($base));
if ($url[0] !== '/') {
$url = '/' . $url;
}

0 comments on commit 4101795

Please sign in to comment.
You can’t perform that action at this time.