method apply documentation in bbn\Appui\Option
Applies a function to children of an option and updates the database
Example
function(callable $f, $id, $deep = false, bool $force = false)
{
if ($this->check()) {
$originals = \is_array($id) ? $id : ( $deep ? $this->fullTree($id) : $this->fullOptions($id) );
if (isset($originals['items'])) {
$originals = $originals['items'];
}
$opts = $this->map($f, $originals, $deep);
if (\is_array($opts)) {
$changes = 0;
foreach ($opts as $i => $o){
if ($force || $originals[$i] !== $o) {
$changes += (int)$this->set($o[$this->fields['id']], $o);
}
if ($deep && !empty($o['num_children']) && !empty($o['items'])) {
$changes += (int)$this->apply($f, $o, 1, true);
}
}
return $changes;
}
}
return null;
}
Applies a function to children of an option and updates the database 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