Skip to content
Permalink
Browse files

Update call sites of request in Helpers.

Don't use deprecated request methods in the helpers.
  • Loading branch information...
markstory committed Oct 6, 2016
1 parent 958b544 commit 420508b88d0f2541851c46590164dd9f2a21df79
Showing with 24 additions and 26 deletions.
  1. +10 −12 src/View/Helper/FormHelper.php
  2. +10 −10 src/View/Helper/PaginatorHelper.php
  3. +4 −4 src/View/Helper/UrlHelper.php
@@ -480,8 +480,8 @@ protected function _formUrl($context, $options)
$actionDefaults = [
'plugin' => $this->plugin,
'controller' => $this->request->params['controller'],
'action' => $this->request->params['action'],
'controller' => $this->request->param('controller'),
'action' => $this->request->param('action'),
];
$action = (array)$options['url'] + $actionDefaults;
@@ -520,17 +520,17 @@ protected function _lastAction($url)
*/
protected function _csrfField()
{
if (!empty($this->request['_Token']['unlockedFields'])) {
foreach ((array)$this->request['_Token']['unlockedFields'] as $unlocked) {
if ($this->request->param('_Token.unlockedFields')) {
foreach ((array)$this->request->param('_Token.unlockedFields') as $unlocked) {
$this->_unlockedFields[] = $unlocked;
}
}
if (empty($this->request->params['_csrfToken'])) {
if (!$this->request->param('_csrfToken')) {
return '';
}
return $this->hidden('_csrfToken', [
'value' => $this->request->params['_csrfToken'],
'value' => $this->request->param('_csrfToken'),
'secure' => static::SECURE_SKIP
]);
}
@@ -550,9 +550,7 @@ public function end(array $secureAttributes = [])
{
$out = '';
if ($this->requestType !== 'get' &&
!empty($this->request['_Token'])
) {
if ($this->requestType !== 'get' && $this->request->param('_Token')) {
$out .= $this->secure($this->fields, $secureAttributes);
$this->fields = [];
$this->_unlockedFields = [];
@@ -585,7 +583,7 @@ public function end(array $secureAttributes = [])
*/
public function secure(array $fields = [], array $secureAttributes = [])
{
if (empty($this->request['_Token'])) {
if (!$this->request->param('_Token')) {
return '';
}
$debugSecurity = Configure::read('debug');
@@ -982,7 +980,7 @@ public function fieldset($fields = '', array $options = [])
if (!$isCreate) {
$actionName = __d('cake', 'Edit %s');
}
$modelName = Inflector::humanize(Inflector::singularize($this->request->params['controller']));
$modelName = Inflector::humanize(Inflector::singularize($this->request->param('controller')));
$legend = sprintf($actionName, $modelName);
}
@@ -2461,7 +2459,7 @@ public function date($fieldName, array $options = [])
protected function _initInputField($field, $options = [])
{
if (!isset($options['secure'])) {
$options['secure'] = !empty($this->request->params['_Token']);
$options['secure'] = (bool)$this->request->param('_Token');
}
$context = $this->_getContext();
@@ -99,11 +99,11 @@ public function __construct(View $View, array $config = [])
{
parent::__construct($View, $config);
$query = $this->request->query;
$query = $this->request->getQueryParams();
unset($query['page'], $query['limit'], $query['sort'], $query['direction']);
$this->config(
'options.url',
array_merge($this->request->params['pass'], ['?' => $query])
array_merge($this->request->param('pass'), ['?' => $query])
);
}
@@ -118,11 +118,11 @@ public function params($model = null)
if (empty($model)) {
$model = $this->defaultModel();
}
if (!isset($this->request->params['paging']) || empty($this->request->params['paging'][$model])) {
if (!$this->request->param('paging') || !$this->request->param('paging.' . $model)) {
return [];
}
return $this->request->params['paging'][$model];
return $this->request->param('paging.' . $model);
}
/**
@@ -152,19 +152,19 @@ public function param($key, $model = null)
public function options(array $options = [])
{
if (!empty($options['paging'])) {
if (!isset($this->request->params['paging'])) {
if (!$this->request->param('paging')) {
$this->request->params['paging'] = [];
}
$this->request->params['paging'] = $options['paging'] + $this->request->params['paging'];
$this->request->params['paging'] = $options['paging'] + $this->request->param('paging');
unset($options['paging']);
}
$model = $this->defaultModel();
if (!empty($options[$model])) {
if (!isset($this->request->params['paging'][$model])) {
if (!$this->request->param('paging.' . $model)) {
$this->request->params['paging'][$model] = [];
}
$this->request->params['paging'][$model] = $options[$model] + $this->request->params['paging'][$model];
$this->request->params['paging'][$model] = $options[$model] + $this->request->param('paging.' . $model);
unset($options[$model]);
}
$this->_config['options'] = array_filter($options + $this->_config['options']);
@@ -595,10 +595,10 @@ public function defaultModel($model = null)
if ($this->_defaultModel) {
return $this->_defaultModel;
}
if (empty($this->request->params['paging'])) {
if (!$this->request->param('paging')) {
return null;
}
list($this->_defaultModel) = array_keys($this->request->params['paging']);
list($this->_defaultModel) = array_keys($this->request->param('paging'));
return $this->_defaultModel;
}
@@ -203,7 +203,7 @@ public function assetTimestamp($path)
$timestampEnabled = $stamp === 'force' || ($stamp === true && Configure::read('debug'));
if ($timestampEnabled && strpos($path, '?') === false) {
$filepath = preg_replace(
'/^' . preg_quote($this->request->webroot, '/') . '/',
'/^' . preg_quote($this->request->getAttribute('webroot'), '/') . '/',
'',
urldecode($path)
);
@@ -237,7 +237,7 @@ public function webroot($file)
{
$asset = explode('?', $file);
$asset[1] = isset($asset[1]) ? '?' . $asset[1] : null;
$webPath = $this->request->webroot . $asset[0];
$webPath = $this->request->getAttribute('webroot') . $asset[0];
$file = $asset[0];
if (!empty($this->theme)) {
@@ -249,12 +249,12 @@ public function webroot($file)
}
if (file_exists(Configure::read('App.wwwRoot') . $theme . $file)) {
$webPath = $this->request->webroot . $theme . $asset[0];
$webPath = $this->request->getAttribute('webroot') . $theme . $asset[0];
} else {
$themePath = Plugin::path($this->theme);
$path = $themePath . 'webroot/' . $file;
if (file_exists($path)) {
$webPath = $this->request->webroot . $theme . $asset[0];
$webPath = $this->request->getAttribute('webroot') . $theme . $asset[0];
}
}
}

0 comments on commit 420508b

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