Skip to content

Commit

Permalink
Removing some validation logic out of the Table object
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Nov 16, 2014
1 parent 6953d13 commit 604b336
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 583 deletions.
10 changes: 2 additions & 8 deletions src/ORM/Table.php
Expand Up @@ -1178,7 +1178,6 @@ public function exists($conditions) {
public function save(EntityInterface $entity, $options = []) {
$options = new \ArrayObject($options + [
'atomic' => true,
'validate' => true,
'associated' => true
]);

Expand Down Expand Up @@ -1223,11 +1222,6 @@ protected function _processSave($entity, $options) {
}

$options['associated'] = $this->_associations->normalizeKeys($options['associated']);
$validate = $options['validate'];

if ($validate && !$this->validate($entity, $options)) {
return false;
}
$event = $this->dispatchEvent('Model.beforeSave', compact('entity', 'options'));

if ($event->isStopped()) {
Expand All @@ -1238,7 +1232,7 @@ protected function _processSave($entity, $options) {
$this,
$entity,
$options['associated'],
['validate' => false] + $options->getArrayCopy()
$options->getArrayCopy()
);

if (!$saved && $options['atomic']) {
Expand All @@ -1259,7 +1253,7 @@ protected function _processSave($entity, $options) {
$this,
$entity,
$options['associated'],
['validate' => (bool)$validate] + $options->getArrayCopy()
$options->getArrayCopy()
);
if ($success || !$options['atomic']) {
$entity->clean();
Expand Down
1 change: 1 addition & 0 deletions tests/TestCase/ORM/MarshallerTest.php
Expand Up @@ -1491,4 +1491,5 @@ public function testMergeJoinDataWithFieldList() {
$this->assertTrue($entity->tags[1]->dirty('_joinData'));
}


}

0 comments on commit 604b336

Please sign in to comment.