method unsetProp documentation in bbn\Appui\Option
Unset option's properties taken from the value column
Example
X::dump($opt->unsetProp(12, 'myProperty'));
// (int) 1
X::dump($opt->unsetProp(12, ['myProperty']));
// (int) 0 Already updated, no change done
X::dump($opt->unsetProp(9654, ['myProperty']));
// (bool) false Option not found
X::dump($opt->unsetProp(12, ['myProperty', 'myProperty2']));
// (int) 1
X::dump($opt->option(12));
/*
Before
array [
'id' => 12,
'id_parent' => 0,
'code' => 'bbn_ide',
'text' => 'BBN's own IDE',
'myProperty' => "78%",
'myProperty2' => "42%",
'myOtherProperty' => "Hello",
]
After
array [
'id' => 12,
'id_parent' => 0,
'code' => 'bbn_ide',
'text' => 'BBN's own IDE',
'myOtherProperty' => "Hello",
]
function($id, $prop)
{
if (!empty($prop) && bbn\Str::isUid($id) && ($o = $this->optionNoAlias($id))) {
if (\is_string($prop)) {
$prop = [$prop];
}
if (\is_array($prop)) {
$change = false;
foreach ($prop as $k){
if (!\in_array($k, $this->fields, true) && array_key_exists($k, $o)) {
$change = true;
unset($o[$k]);
}
}
if ($change) {
return $this->set($id, $o);
}
}
}
return null;
}
Unset option's properties taken 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-2025
BBN Solutions