Skip to content

Commit

Permalink
Add interface checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Scherer committed Jan 4, 2016
1 parent 9415d44 commit 51ec884
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Datasource/RulesChecker.php
Expand Up @@ -14,6 +14,7 @@
*/
namespace Cake\Datasource;

use Cake\Datasource\InvalidPropertyInterface;
use InvalidArgumentException;

/**
Expand Down Expand Up @@ -328,7 +329,7 @@ protected function _addError($rule, $name, $options)
}
$entity->errors($options['errorField'], $message);

if (isset($entity->{$options['errorField']})) {
if ($entity instanceof InvalidPropertyInterface && isset($entity->{$options['errorField']})) {
$invalidValue = $entity->{$options['errorField']};
$entity->invalid($options['errorField'], $invalidValue);
}
Expand Down
5 changes: 4 additions & 1 deletion src/ORM/Marshaller.php
Expand Up @@ -19,6 +19,7 @@
use Cake\Database\Expression\TupleComparison;
use Cake\Database\Type;
use Cake\Datasource\EntityInterface;
use Cake\Datasource\InvalidPropertyInterface;
use RuntimeException;

/**
Expand Down Expand Up @@ -128,7 +129,9 @@ public function one(array $data, array $options = [])
$properties = [];
foreach ($data as $key => $value) {
if (!empty($errors[$key])) {
$entity->invalid($key, $value);
if ($entity instanceof InvalidPropertyInterface) {
$entity->invalid($key, $value);
}
continue;
}
$columnType = $schema->columnType($key);
Expand Down

0 comments on commit 51ec884

Please sign in to comment.