From 7678f94a23d3f29446999fa696c6efac7fc10163 Mon Sep 17 00:00:00 2001 From: Anthony GRASSIOT Date: Tue, 10 Jan 2017 14:20:45 +0100 Subject: [PATCH] Remove deprecated calls in Cake\Validator and Cake\View --- src/Validation/Validator.php | 6 +++--- src/Validation/ValidatorAwareTrait.php | 2 +- src/View/Cell.php | 10 +++++----- src/View/CellTrait.php | 12 ++++++------ src/View/Helper/FormHelper.php | 4 ++-- src/View/JsonView.php | 4 ++-- src/View/ViewVarsTrait.php | 8 ++++---- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Validation/Validator.php b/src/Validation/Validator.php index 282df3868f9..2f85ef65cc7 100644 --- a/src/Validation/Validator.php +++ b/src/Validation/Validator.php @@ -379,7 +379,7 @@ public function addNested($field, Validator $validator) return false; } foreach ($this->providers() as $provider) { - $validator->provider($provider, $this->provider($provider)); + $validator->setProvider($provider, $this->getProvider($provider)); } $errors = $validator->errors($value, $context['newRecord']); @@ -414,7 +414,7 @@ public function addNestedMany($field, Validator $validator) return false; } foreach ($this->providers() as $provider) { - $validator->provider($provider, $this->provider($provider)); + $validator->setProvider($provider, $this->getProvider($provider)); } $errors = []; foreach ($value as $i => $row) { @@ -1775,7 +1775,7 @@ protected function _processRules($field, ValidationSet $rules, $data, $newRecord { $errors = []; // Loading default provider in case there is none - $this->provider('default'); + $this->getProvider('default'); $message = 'The provided value is invalid'; if ($this->_useI18n) { diff --git a/src/Validation/ValidatorAwareTrait.php b/src/Validation/ValidatorAwareTrait.php index 9b604d3d0a2..9570d58bf0c 100644 --- a/src/Validation/ValidatorAwareTrait.php +++ b/src/Validation/ValidatorAwareTrait.php @@ -115,7 +115,7 @@ public function validator($name = null, Validator $validator = null) } } - $validator->provider(self::VALIDATOR_PROVIDER_NAME, $this); + $validator->setProvider(self::VALIDATOR_PROVIDER_NAME, $this); return $this->_validators[$name] = $validator; } diff --git a/src/View/Cell.php b/src/View/Cell.php index 73be8d88784..4fc0f9a838e 100644 --- a/src/View/Cell.php +++ b/src/View/Cell.php @@ -196,17 +196,17 @@ public function render($template = null) $template = Inflector::underscore($template); } if ($template === null) { - $template = $builder->template() ?: $this->template; + $template = $builder->getTemplate() ?: $this->template; } - $builder->layout(false) - ->template($template); + $builder->setLayout(false) + ->setTemplate($template); $className = get_class($this); $namePrefix = '\View\Cell\\'; $name = substr($className, strpos($className, $namePrefix) + strlen($namePrefix)); $name = substr($name, 0, -4); - if (!$builder->templatePath()) { - $builder->templatePath('Cell' . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $name)); + if (!$builder->getTemplatePath()) { + $builder->setTemplatePath('Cell' . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $name)); } $this->View = $this->createView(); diff --git a/src/View/CellTrait.php b/src/View/CellTrait.php index f31815a72fb..85b2b0af872 100644 --- a/src/View/CellTrait.php +++ b/src/View/CellTrait.php @@ -98,31 +98,31 @@ protected function _createCell($className, $action, $plugin, $options) $builder = $instance->viewBuilder(); if (!empty($plugin)) { - $builder->plugin($plugin); + $builder->setPlugin($plugin); } if (!empty($this->helpers)) { - $builder->helpers($this->helpers); + $builder->setHelpers($this->helpers); $instance->helpers = $this->helpers; } if ($this instanceof View) { if (!empty($this->theme)) { - $builder->theme($this->theme); + $builder->setTheme($this->theme); } $class = get_class($this); - $builder->className($class); + $builder->setClassName($class); $instance->viewClass = $class; return $instance; } if (method_exists($this, 'viewBuilder')) { - $builder->theme($this->viewBuilder()->theme()); + $builder->setTheme($this->viewBuilder()->theme()); } if (isset($this->viewClass)) { - $builder->className($this->viewClass); + $builder->getClassName($this->viewClass); $instance->viewClass = $this->viewClass; } diff --git a/src/View/Helper/FormHelper.php b/src/View/Helper/FormHelper.php index aefcd4205bf..40adede00aa 100644 --- a/src/View/Helper/FormHelper.php +++ b/src/View/Helper/FormHelper.php @@ -953,7 +953,7 @@ public function controls(array $fields, array $options = []) continue; } - $out .= $this->input($name, (array)$opts); + $out .= $this->control($name, (array)$opts); } return $this->fieldset($out, $options); @@ -2731,7 +2731,7 @@ public function widget($name, array $data = []) */ public function resetTemplates() { - $this->templates($this->_defaultConfig['templates']); + $this->setTemplates($this->_defaultConfig['templates']); } /** diff --git a/src/View/JsonView.php b/src/View/JsonView.php index b55310611f3..c4a8bd629de 100644 --- a/src/View/JsonView.php +++ b/src/View/JsonView.php @@ -111,8 +111,8 @@ public function render($view = null, $layout = null) if ($this->viewVars['_jsonp'] === true) { $jsonpParam = 'callback'; } - if ($this->request->query($jsonpParam)) { - $return = sprintf('%s(%s)', h($this->request->query($jsonpParam)), $return); + if ($this->request->getQuery($jsonpParam)) { + $return = sprintf('%s(%s)', h($this->request->getQuery($jsonpParam)), $return); $this->response->type('js'); } } diff --git a/src/View/ViewVarsTrait.php b/src/View/ViewVarsTrait.php index 4450d1ed184..aa3bf18d188 100644 --- a/src/View/ViewVarsTrait.php +++ b/src/View/ViewVarsTrait.php @@ -70,11 +70,11 @@ public function viewBuilder() public function createView($viewClass = null) { $builder = $this->viewBuilder(); - if ($viewClass === null && $builder->className() === null) { - $builder->className($this->viewClass); + if ($viewClass === null && $builder->getClassName() === null) { + $builder->setClassName($this->viewClass); } if ($viewClass) { - $builder->className($viewClass); + $builder->setClassName($viewClass); } $validViewOptions = $this->viewOptions(); @@ -109,7 +109,7 @@ public function createView($viewClass = null) $builder->{$prop}($this->{$prop}); } } - $builder->options($viewOptions); + $builder->setOptions($viewOptions); return $builder->build( $this->viewVars,