Skip to content

Commit

Permalink
fix transformable to support callbacks within callbacks (nesting 10 t…
Browse files Browse the repository at this point in the history
…imes)
  • Loading branch information
jturbide committed Aug 15, 2023
1 parent 0592a5c commit c47e503
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Mvc/Model/Behavior/Transformable.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ public function notify(string $type, ModelInterface $model): ?bool

foreach ($options as $field => $value) {
$value = is_callable($value) ? $value($model, $field) : $value;

// allow up to 10 callbacks
$limit = 10;
while (is_callable($value) && --$limit) {
$value = $value();
}

$model->writeAttribute($field, $value);
// $model->assign([$field => $value]);
}
Expand Down

0 comments on commit c47e503

Please sign in to comment.