From 1153b32e57255f57347bffde6c0a1768d4f5b4e7 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 24 Oct 2019 08:38:19 +0200 Subject: [PATCH] Update OneDriveAdapter.php --- src/OneDriveAdapter.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/OneDriveAdapter.php b/src/OneDriveAdapter.php index a9ea58c..e47841c 100644 --- a/src/OneDriveAdapter.php +++ b/src/OneDriveAdapter.php @@ -18,7 +18,7 @@ class OneDriveAdapter extends AbstractAdapter private $usePath; - public function __construct(Graph $graph, $prefix = 'root', $base = '/me/drive/', $usePath = true) + public function __construct(Graph $graph, $prefix = 'root', $base = '/drive/', $usePath = true) { $this->graph = $graph; $this->usePath = $usePath; @@ -73,12 +73,24 @@ public function rename($path, $newPath): bool ->attachBody([ 'name' => end($patch), 'parentReference' => [ - 'path' => substr($this->getPathPrefix(), 3).(empty($sliced) ? '' : rtrim($sliced, '/').'/'), + 'path' => $this->getPathPrefix().(empty($sliced) ? '' : rtrim($sliced, '/').'/'), ] ]) ->execute(); } catch (\Exception $e) { - return false; + try { + $this->graph->createRequest('PATCH', $endpoint) + ->attachBody([ + 'name' => end($patch), + 'parentReference' => [ + 'path' => substr($this->getPathPrefix(), 3).(empty($sliced) ? '' : rtrim($sliced, '/').'/'), + ] + ]) + ->execute(); + + } catch (\Exception $e){ + return false; + } } return true;