/** * Deletes folder and all descendants objects. * @param int $deletedBy Id of user (or SystemUser::SYSTEM_USER_ID). * @throws \Bitrix\Main\ArgumentException * @throws \Bitrix\Main\ArgumentNullException * @return bool */ public function deleteTree($deletedBy) { $this->errorCollection->clear(); foreach ($this->getDescendants(Storage::getFakeSecurityContext(), array('filter' => array('MIXED_SHOW_DELETED' => true)), SORT_DESC) as $object) { /** @var Folder|File */ if ($object instanceof Folder) { $object->deleteNonRecursive($deletedBy); } elseif ($object instanceof File) { $object->delete($deletedBy); } } unset($object); return $this->deleteNonRecursive($deletedBy); }
protected function recalculateDeletedTypeAfterRestore($restoredBy) { $fakeContext = Storage::getFakeSecurityContext(); foreach ($this->getParents($fakeContext, array('filter' => array('MIXED_SHOW_DELETED' => true)), SORT_ASC) as $parent) { if (!$parent instanceof Folder || !$parent->isDeleted()) { continue; } foreach ($parent->getChildren($fakeContext, array('filter' => array('!DELETED_TYPE' => ObjectTable::DELETED_TYPE_NONE))) as $childPotentialRoot) { if ($childPotentialRoot instanceof Folder && $childPotentialRoot->getId() != $this->getId()) { $childPotentialRoot->markDeletedNonRecursiveInternal($childPotentialRoot->getDeletedBy()); } elseif ($childPotentialRoot instanceof File) { $childPotentialRoot->markDeletedInternal($childPotentialRoot->getDeletedBy()); } } unset($childPotentialRoot); $parent->restoreNonRecursive($restoredBy); } unset($parent); return; }