RedBeanPHP\Repository\Fluid::processAdditions PHP Метод

processAdditions() защищенный Метод

Handles all new additions after the bean has been saved. Stores addition bean in own-list, extracts the id and adds a foreign key. Also adds a constraint in case the type is in the dependent list. Note that this method raises a custom exception if the bean is not an instance of OODBBean. Therefore it does not use a type hint. This allows the user to take action in case invalid objects are passed in the list.
protected processAdditions ( RedBeanPHP\OODBBean $bean, array $ownAdditions ) : void
$bean RedBeanPHP\OODBBean bean to process
$ownAdditions array list of addition beans in own-list
Результат void
    protected function processAdditions($bean, $ownAdditions)
    {
        $beanType = $bean->getMeta('type');
        foreach ($ownAdditions as $addition) {
            if ($addition instanceof OODBBean) {
                $myFieldLink = $beanType . '_id';
                $alias = $bean->getMeta('sys.alias.' . $addition->getMeta('type'));
                if ($alias) {
                    $myFieldLink = $alias . '_id';
                }
                $addition->{$myFieldLink} = $bean->id;
                $addition->setMeta('cast.' . $myFieldLink, 'id');
                if ($alias) {
                    $addition->setMeta("sys.typeof.{$alias}", $beanType);
                } else {
                    $addition->setMeta("sys.typeof.{$beanType}", $beanType);
                }
                $this->store($addition);
            } else {
                throw new RedException('Array may only contain OODBBeans');
            }
        }
    }