Skip to content

Commit

Permalink
Starting to make the base entity's properties accessible by default
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Mar 16, 2014
1 parent c380a0a commit a3eb624
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Datasource/EntityTrait.php
Expand Up @@ -95,7 +95,7 @@ trait EntityTrait {
*
* @var array
*/
protected $_accessible = [];
protected $_accessible = ['*' => true];

/**
* Magic getter to access properties that has be set in this entity
Expand Down Expand Up @@ -644,7 +644,11 @@ protected function _nestedErrors($field) {
*/
public function accessible($property, $set = null) {
if ($set === null) {
return !empty($this->_accessible[$property]) || !empty($this->_accessible['*']);
$value = isset($this->_accessible[$property]) ?
$this->_accessible[$property] :
null;

return ($value === null && !empty($this->_accessible['*'])) || $value;
}

if ($property === '*') {
Expand Down
1 change: 1 addition & 0 deletions tests/TestCase/ORM/EntityTest.php
Expand Up @@ -860,6 +860,7 @@ public function testCleanRemovesErrors() {
*/
public function testAccessible() {
$entity = new Entity;
$entity->accessible('*', false);
$this->assertFalse($entity->accessible('foo'));
$this->assertFalse($entity->accessible('bar'));

Expand Down

0 comments on commit a3eb624

Please sign in to comment.