Skip to content

Commit

Permalink
Merge branch 'release/1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jnovermars committed Oct 5, 2023
2 parents 2c9e528 + e88a27e commit 4191ec1
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions src/Drive/FolderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,33 +117,6 @@ public function requestFolderItems(?string $folder = '/', ?string $itemId = null
return $this->requestAllItems($url);
}

/**
* Get all items from a url
*
* @param string $url
* @return array
* @throws Exception
*/
public function requestAllItems(string $url): ?array
{
$response = $this->apiConnector->request('GET', $url);

if ( ! isset($response['value'])) {
throw new \Exception('Microsoft SP Drive Request: Cannot parse the body of the sharepoint drive request. ' . __FUNCTION__, 2321);
}

$results = $response['value'];

if (isset($response['@odata.nextLink'])) {
$results = [
...$response['value'],
...$this->requestAllItems($response['@odata.nextLink'])
];
}

return $results;
}

/**
* Read the folder metadata and so check if it exists
*
Expand Down Expand Up @@ -283,4 +256,32 @@ public function deleteFolder(?string $folder = null, ?string $itemId = null): bo
return false;
}
}

/**
* Get all items from a url
*
* @param string $url
* @return array
* @throws Exception
*/
private function requestAllItems(string $url): ?array
{
$response = $this->apiConnector->request('GET', $url);

if ( ! isset($response['value'])) {
throw new \Exception('Microsoft SP Drive Request: Cannot parse the body of the sharepoint drive request. ' . __FUNCTION__, 2321);
}

$results = $response['value'];

if (isset($response['@odata.nextLink'])) {
$results = [
...$response['value'],
...$this->requestAllItems($response['@odata.nextLink'])
];
}

return $results;
}

}

0 comments on commit 4191ec1

Please sign in to comment.