phpSPO icon indicating copy to clipboard operation
phpSPO copied to clipboard

Sharepoint: move folder with subfolders (new feature)

Open Pedrolo opened this issue 2 years ago • 0 comments

After trying to make it work for hours, I have finally been able to move an entire folder (with subfolders and files).

It is a method that shall be added to src/Sharepoint/MoveCopyUtil.php:

function moveFolder($context, $srcUrl, $destUrl, $options){
        $util = new MoveCopyUtil($context);
        $qry = new InvokePostMethodQuery($util, "MoveFolderByPath", null, null,
            array("srcPath" => new ResourcePath($srcUrl), "destPath" => new ResourcePath($destUrl), "options" => $options));
        $qry->IsStatic = true;
        $context->addQuery($qry);
        return $util;
    }

It needs a new class extending SPResourcePath to make it work, as using SPResuorcePath sends a metadata SP.SPResourcePath instead of SP.ResourcePath:

use Office365\SharePoint\SPResourcePath;

class ResourcePath extends SPResourcePath{}

Please consider including it.

Pedrolo avatar May 10 '22 16:05 Pedrolo