method setProp documentation in bbn\Appui\Option
Updates option's properties derived from the value column
Example
X::dump($opt->setProp(12, 'myProperty', "78%"));
// (int) 1
X::dump($opt->setProp(12, ['myProperty' => "78%"]));
// (int) 0 Already updated, no change done
X::dump($opt->setProp(9654, ['myProperty' => "78%"]));
// (bool) false Option not found
X::dump($opt->setProp(12, ['myProperty' => "78%", 'myProperty2' => "42%"]));
// (int) 1
X::dump($opt->option(12));
/*
Before
array [
'id' => 12,
'id_parent' => 0,
'code' => 'bbn_ide',
'text' => 'BBN's own IDE',
'myOtherProperty' => "Hello",
]
After
array [
'id' => 12,
'id_parent' => 0,
'code' => 'bbn_ide',
'text' => 'BBN's own IDE',
'myProperty' => "78%",
'myProperty2' => "42%",
'myOtherProperty' => "Hello",
]
function($id, $prop)
{
if (!empty($id) && !empty($prop) && ($o = $this->optionNoAlias($id))) {
$args = \func_get_args();
if (\is_string($prop) && isset($args[2])) {
$prop = [$prop => $args[2]];
}
if (\is_array($prop)) {
X::log([$o, $prop], "set_prop");
$change = false;
foreach ($prop as $k => $v){
if (!isset($o[$k]) || ($o[$k] !== $v)) {
$change = true;
$o[$k] = $v;
}
}
if ($change) {
return $this->set($id, $o);
}
}
return 0;
}
return null;
}
Updates option's properties derived from the value column BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2023
BBN Solutions