DeleteObjectVersionsResult.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace OSS\Result;
  3. use OSS\Core\OssUtil;
  4. use OSS\Model\DeletedObjectInfo;
  5. /**
  6. * Class DeleteObjectVersionsResult
  7. * @package OSS\Result
  8. */
  9. class DeleteObjectVersionsResult extends Result
  10. {
  11. /**
  12. * @return DeletedObjectInfo[]
  13. */
  14. protected function parseDataFromResponse()
  15. {
  16. $xml = simplexml_load_string($this->rawResponse->body);
  17. $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : "";
  18. return $this->parseDeletedList($xml, $encodingType);
  19. }
  20. private function parseDeletedList($xml, $encodingType)
  21. {
  22. $retList = array();
  23. if (isset($xml->Deleted)) {
  24. foreach ($xml->Deleted as $content) {
  25. $key = isset($content->Key) ? strval($content->Key) : "";
  26. $key = OssUtil::decodeKey($key, $encodingType);
  27. $versionId = isset($content->VersionId) ? strval($content->VersionId) : "";
  28. $deleteMarker = isset($content->DeleteMarker) ? strval($content->DeleteMarker) : "";
  29. $deleteMarkerVersionId = isset($content->DeleteMarkerVersionId) ? strval($content->DeleteMarkerVersionId) : "";
  30. $retList[] = new DeletedObjectInfo($key, $versionId, $deleteMarker, $deleteMarkerVersionId);
  31. }
  32. }
  33. return $retList;
  34. }
  35. }