Skip to content

Commit

Permalink
Added language support to Row::__isset()
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Jul 1, 2016
1 parent 952f7ad commit 24097b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Row.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ public function __set($name, $value)
*/
public function __isset($name)
{
$language = $this->getDatabase()->getAttribute(SimpleCrud::ATTR_LOCALE);

if (!is_null($language) && isset($this->values["{$name}_{$language}"])) {
return true;
}

return isset($this->values[$name]) || isset($this->relations[$name]);
}

Expand Down
4 changes: 4 additions & 0 deletions tests/LocaleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,9 @@ public function testRow()

$post->title_es = 'Español';
$this->assertNotSame($post->title_gl, $post->title_es);

$this->assertTrue(isset($post->title_es));
$this->assertTrue(isset($post->title));
$this->assertFalse(isset($post->title_en));
}
}

0 comments on commit 24097b9

Please sign in to comment.