RedBeanPHP\Repository::processTrashcan PHP Method

processTrashcan() protected method

A trash can bean is a bean in an own-list that has been removed (when checked with the shadow). This method checks if the bean is also in the dependency list. If it is the bean will be removed. If not, the connection between the bean and the owner bean will be broken by setting the ID to NULL.
protected processTrashcan ( redbeanphp\OODBBean $bean, array $ownTrashcan ) : void
$bean redbeanphp\OODBBean bean to process
$ownTrashcan array list to process
return void
    protected function processTrashcan($bean, $ownTrashcan)
    {
        foreach ($ownTrashcan as $trash) {
            $myFieldLink = $bean->getMeta('type') . '_id';
            $alias = $bean->getMeta('sys.alias.' . $trash->getMeta('type'));
            if ($alias) {
                $myFieldLink = $alias . '_id';
            }
            if ($trash->getMeta('sys.garbage') === true) {
                $this->trash($trash);
            } else {
                $trash->{$myFieldLink} = NULL;
                $this->store($trash);
            }
        }
    }