public function listAllMyBuckets()
{
$result = null;
$options = array();
$response = $this->client->call('GET', $options, '/');
if ($response->getError() === false) {
//Success
$sxml = simplexml_load_string($response->getRawContent());
$result = new BucketList();
$result->setS3($this->s3);
$em = $this->getEntityManager();
if (isset($sxml->Owner->ID)) {
$ownerid = (string) $sxml->Owner->ID;
//Tries to get an owner object from an entity storage.
$owner = $em->getRepository('S3:Owner')->find($ownerid);
if ($owner === null) {
$owner = new OwnerData();
$owner->ownerid = $ownerid;
$owner->displayName = (string) $sxml->Owner->DisplayName;
$em->attach($owner);
}
$result->setOwner($owner);
}
if (!empty($sxml->Buckets->Bucket)) {
foreach ($sxml->Buckets->Bucket as $v) {
$bucket = new BucketData();
$bucket->bucketName = (string) $v->Name;
$bucket->creationDate = new \DateTime((string) $v->CreationDate, new \DateTimeZone('UTC'));
$result->append($bucket);
$em->attach($bucket);
unset($bucket);
}
}
}
return $result;
}