From d745bbf8c2b6d0e0d4cb1d73192bea603c84c333 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Wed, 25 Dec 2013 11:43:34 +0100 Subject: [PATCH] Fixed some issues fiund in code review --- Cake/ORM/Entity.php | 4 ---- Cake/ORM/Table.php | 18 ++++++++---------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/Cake/ORM/Entity.php b/Cake/ORM/Entity.php index 80458327f42..e105d60d862 100644 --- a/Cake/ORM/Entity.php +++ b/Cake/ORM/Entity.php @@ -650,10 +650,6 @@ protected function _nestedErrors($field) { return $errors; } - if (is_scalar($value) || !($value instanceof self)) { - return []; - } - if ($value instanceof self) { return $value->errors(); } diff --git a/Cake/ORM/Table.php b/Cake/ORM/Table.php index 221dd556b1b..7b67ece1472 100644 --- a/Cake/ORM/Table.php +++ b/Cake/ORM/Table.php @@ -918,15 +918,13 @@ public function validator($name = 'default', Validator $instance = null) { return $this->_validators[$name]; } - if ($instance !== null) { - $instance->provider('table', $this); - return $this->_validators[$name] = $instance; + if ($instance === null) { + $instance = new Validator(); + $instance = $this->{'validation' . ucfirst($name)}($instance); } - $validator = new Validator; - $validator = $this->{'validation' . ucfirst($name)}($validator); - $validator->provider('table', $this); - return $this->_validators[$name] = $validator; + $instance->provider('table', $this); + return $this->_validators[$name] = $instance; } /** @@ -1632,13 +1630,13 @@ public function validate($entity, $options = []) { * saved. * * {{{ - * $articles->validate([$article1, $article2]); + * $articles->validateMany([$article1, $article2]); * }}} * * You can specify which validation set to use using the options array: * * {{{ - * $users->validate([$user1, $user2], ['validate' => 'forSignup']); + * $users->validateMany([$user1, $user2], ['validate' => 'forSignup']); * }}} * * By default all the associations on this table will be validated if they can @@ -1646,7 +1644,7 @@ public function validate($entity, $options = []) { * or include deeper associations using the options parameter * * {{{ - * $articles->validate([$article1, $article2], [ + * $articles->validateMany([$article1, $article2], [ * 'associated' => [ * 'Tags', * 'Comments' => [