Skip to content

Commit

Permalink
quietSet support with field setters
Browse files Browse the repository at this point in the history
  • Loading branch information
esokullu committed Jul 26, 2017
1 parent 275b691 commit 28c5c0d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/Pho/Framework/Handlers/Set.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static function handle(
) /*: \Pho\Lib\Graph\EntityInterface*/
{
if( Utils::fieldExists($pack["fields"], substr($name, 3)) ) {
return static::field($particle, $pack["fields"], substr($name, 3), $args[0]);
return static::field($particle, $pack["fields"], substr($name, 3), $args);
}
$check = false;
foreach($pack["out"]->setter_label_settable_pairs[$name] as $settable) {
Expand All @@ -56,7 +56,7 @@ public static function handle(
* @param ParticleInterface $particle
* @param FieldsCargo $cargo
* @param string $name Field name
* @param array $args Field argument
* @param array $args Field argument; [0] mixed, the argument. [1] ?bool defer_persist
*
* @return void
*
Expand All @@ -66,14 +66,22 @@ protected static function field(
ParticleInterface $particle,
FieldsCargo $cargo,
string $name,
/*mixed*/ $value
array $value
): void
{
$defer_persist = false;
if( isset($value[1]) && $value[1] )
$defer_persist = true;
$value = $value[0];
$name = Utils::findFieldName($cargo, $name);
if(isset($cargo->fields[$name]["constraints"])) {
static::probeField($cargo->fields[$name]["constraints"], $value);
}
$particle->attributes()->$name = static::applyDirectives($value, $cargo->fields[$name]);
$value = static::applyDirectives($value, $cargo->fields[$name]);
if($defer_persist) {
$particle->attributes()->$name = $value;
}
$particle->attributes()->quietSet($name, $value);
}

/**
Expand Down

0 comments on commit 28c5c0d

Please sign in to comment.