Skip to content

Commit

Permalink
Update OneDriveAdapter.php
Browse files Browse the repository at this point in the history
  • Loading branch information
hevelius authored Oct 24, 2019
1 parent 7afdc49 commit 1153b32
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/OneDriveAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1153b32

Please sign in to comment.