Skip to content

Commit

Permalink
get dynamic properties first, otherwise get the attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
mjauvin committed Jan 31, 2024
1 parent 8faea4a commit abc4de2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Halcyon/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,7 @@ public static function cacheMutatedAttributes($class)
*/
public function __get($key)
{
return $this->getAttribute($key);
return $this->extendableGet($key) ?? $this->getAttribute($key);
}

/**
Expand Down
11 changes: 11 additions & 0 deletions tests/Halcyon/HalcyonModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,17 @@ public function testPageQueryListFileName()
$this->assertEquals(['about.htm', 'home.htm'], $files);
}

public function testAddDynamicPoperty()
{
$page = HalcyonTestPage::find('home');

$page->addDynamicProperty('myDynamicProperty', 'myDynamicPropertyValue');
$this->assertEquals('myDynamicPropertyValue', $page->myDynamicProperty);

// Dynamic properties should not be saved to DB layer
$this->assertArrayNotHasKey('myDynamicProperty', $page->attributes);
}

//
// House keeping
//
Expand Down

0 comments on commit abc4de2

Please sign in to comment.