Skip to content

Commit

Permalink
Adding a default scope
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Nov 20, 2013
1 parent c4e0c52 commit 0a3960d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cake/ORM/Validator.php
Expand Up @@ -109,6 +109,9 @@ public function scope($name, $object = null) {
if (isset($this->_scopes[$name])) {
return $this->_scopes[$name];
}
if ($name === 'default') {
return $this->_scopes[$name] = '\Cake\Utility\Validation';
}
return null;
}
$this->_scopes[$name] = $object;
Expand Down
2 changes: 2 additions & 0 deletions Cake/Test/TestCase/ORM/ValidatorTest.php
Expand Up @@ -221,6 +221,8 @@ public function testScope() {
$another = new \stdClass;
$this->assertSame($validator, $validator->scope('bar', $another));
$this->assertSame($another, $validator->scope('bar'));

$this->assertEquals('\Cake\Utility\Validation', $validator->scope('default'));
}

}

0 comments on commit 0a3960d

Please sign in to comment.