/** * @SuppressWarnings(PHPMD.StaticAccess) * * @param string $path * * @return ErrorResponse|SuccessResponse */ protected function getSearchResponse($path) { $extendedRequest = new ExtendedRequest(); $extendedRequest->addQueryField('content_types', 'name'); $extendedRequest->addQueryField('limit', 20); $command = new SearchContent(basename($path), $extendedRequest); return ResponseFactory::getResponse($this->contentClient, $command); }
public function deleteFile($file) { $contentClient = new ContentClient(new ApiClient($this->access_token), new UploadClient($this->access_token)); if ($file != null) { $list_file = explode("/", $file); $file = end($list_file); } if (strpos($file, 'folder') !== false) { $file = substr($file, 7); $er = new ExtendedRequest(); $er->addQueryField('recursive', true); $command = new Content\Folder\DeleteFolder($file, $er); $response = ResponseFactory::getResponse($contentClient, $command); if ($response instanceof SuccessResponse) { // echo (string)$response->getStatusCode(); // echo "<br>"; // echo (string)$response->getReasonPhrase(); return true; } elseif ($response instanceof ErrorResponse) { $data = (string) $response->getBody(); return $data; } } elseif (strpos($file, 'file') !== false) { $file = substr($file, 5); $command = new Content\File\DeleteFile($file); $response = ResponseFactory::getResponse($contentClient, $command); if ($response instanceof SuccessResponse) { // echo (string)$response->getStatusCode(); // echo "<br>"; // echo (string)$response->getReasonPhrase(); return true; } elseif ($response instanceof ErrorResponse) { return false; } } else { echo "LOL"; } }