Pimcore\Model\Element\Recyclebin\Item::restoreChilds PHP Method

restoreChilds() public method

public restoreChilds ( Pimcore\Model\Element\ElementInterface $element )
$element Pimcore\Model\Element\ElementInterface
    public function restoreChilds(Element\ElementInterface $element)
    {
        $restoreBinaryData = function ($element, $scope) {
            // assets are kinda special because they can contain massive amount of binary data which isn't serialized, we create separate files for them
            if ($element instanceof Asset) {
                $binFile = $scope->getStorageFileBinary($element);
                if (file_exists($binFile)) {
                    $binaryHandle = fopen($binFile, "r", false, File::getContext());
                    $element->setStream($binaryHandle);
                }
            }
        };
        $restoreBinaryData($element, $this);
        $element->save();
        if (method_exists($element, "getChilds")) {
            if ($element instanceof Object\AbstractObject) {
                // don't use the getter because this will return an empty array (variants are excluded by default)
                $childs = $element->o_childs;
            } else {
                $childs = $element->getChilds();
            }
            foreach ($childs as $child) {
                $this->restoreChilds($child);
            }
        }
    }