/** * Recursive helper function. * Callers must check DAV_Multistatus::active() afterwards. * @see delete() * @param DAV_Collection $resource * @param DAV_Resource $memberResource The resource to delete * @throws DAV_Status */ private static function delete_member($resource, $memberResource) { if ($memberResource instanceof DAV_Collection) { $failure = false; foreach ($memberResource as $child) { try { $childResource = DAV::$REGISTRY->resource($memberResource->path . $child); if (!$childResource) { throw new DAV_Status(DAV::HTTP_INTERNAL_SERVER_ERROR, "Registry didn't generate resource for path " . $memberResource->path . $child); } self::delete_member($memberResource, $childResource); } catch (DAV_Status $e) { $failure = true; DAV_Multistatus::inst()->addStatus($childResource->path, $e); } } if ($failure) { return; } } $resource->method_DELETE(substr($memberResource->path, strlen($resource->path))); DAV::$REGISTRY->forget($memberResource->path); }
/** * Copy the resource and all its children * * @param DAV_Collection $resource * @param string $destination * @param string $dr destinationRoot */ private function copy_recursively($resource, $destination, $dr = null) { if (!$dr) { $dr = $destination; } elseif ($dr === $resource->path) { return; } $resource->method_COPY($destination); if (!$resource instanceof DAV_Collection || DAV::DEPTH_INF !== $this->depth()) { return; } foreach ($resource as $member) { $memberResource = DAV::$REGISTRY->resource($resource->path . $member); try { $this->copy_recursively($memberResource, $destination . $member, $dr); } catch (DAV_Status $e) { DAV_Multistatus::inst()->addStatus($resource->path . $member, $e); } } }