Simplified framing default option handling.

This commit is contained in:
Dave Longley 2011-07-29 15:34:43 -04:00
parent 6810f94673
commit 25c62ddac1

View file

@ -2636,12 +2636,12 @@ function _frame($subjects, $input, $frame, $embeds, $options)
} }
else else
{ {
// add null property to value // add empty array/null property to value
$value->$key = null; $value->$key = is_array($f) ? array() : null;
} }
// handle setting default value(s) // handle setting default value
if(property_exists($value, $key)) if($value->$key === null)
{ {
// use first subframe if frame is an array // use first subframe if frame is an array
if(is_array($f)) if(is_array($f))
@ -2653,9 +2653,6 @@ function _frame($subjects, $input, $frame, $embeds, $options)
$omitOn = property_exists($f, '@omitDefault') ? $omitOn = property_exists($f, '@omitDefault') ?
$f->{'@omitDefault'} : $f->{'@omitDefault'} :
$options->defaults->omitDefaultOn; $options->defaults->omitDefaultOn;
if($value->$key === null)
{
if($omitOn) if($omitOn)
{ {
unset($value->$key); unset($value->$key);
@ -2665,27 +2662,6 @@ function _frame($subjects, $input, $frame, $embeds, $options)
$value->$key = $f->{'@default'}; $value->$key = $f->{'@default'};
} }
} }
else if(is_array($value->$key))
{
$tmp = array();
foreach($value->$key as $v)
{
if($v === null)
{
// do not auto-include null in arrays
if(!$omitOn and property_exists($f, '$default'))
{
$tmp[] = $f->{'$default'};
}
}
else
{
$tmp[] = $v;
}
}
$value->$key = $tmp;
}
}
} }
} }
} }