Skip to content

Commit

Permalink
Add missing attribute setter events
Browse files Browse the repository at this point in the history
  • Loading branch information
daftspunk committed Oct 22, 2016
1 parent 5790fec commit a6b7e73
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/Halcyon/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,11 @@ protected function mutateAttributeForArray($key, $value)
*/
public function setAttribute($key, $value)
{
// Before Event
if (($_value = $this->fireEvent('model.beforeSetAttribute', [$key, $value], true)) !== null) {
$value = $_value;
}

// First we will check for the presence of a mutator for the set operation
// which simply lets the developers tweak the attribute as it is set on
// the model, such as "json_encoding" an listing of data for storage.
Expand All @@ -751,6 +756,9 @@ public function setAttribute($key, $value)

$this->attributes[$key] = $value;

// After Event
$this->fireEvent('model.setAttribute', [$key, $value]);

return $this;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Halcyon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Here is an example of registering a datasource called `theme1`, then binding the
use October\Rain\Halcyon\Datasource\Resolver;

$datasource = new FileDatasource('/path/to/theme', new Filesystem);
$resolver = new DatasourceResolver(['theme1' => $datasource]);
$resolver = new Resolver(['theme1' => $datasource]);
$resolver->setDefaultDatasource('theme1');
Model::setDatasourceResolver($resolver);

Expand Down

0 comments on commit a6b7e73

Please sign in to comment.