Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/ObjectStore/v1/Models/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,15 @@ public function populateFromResponse(ResponseInterface $response): self
public function listObjects(array $options = [], callable $mapFn = null): \Generator
{
$options = array_merge($options, ['name' => $this->name, 'format' => 'json']);
return $this->model(StorageObject::class)->enumerate($this->api->getContainer(), $options, $mapFn);

$appendContainerNameFn = function (StorageObject $resource) use ($mapFn) {
$resource->containerName = $this->name;
if ($mapFn) {
call_user_func_array($mapFn, [&$resource]);
}
};

return $this->model(StorageObject::class)->enumerate($this->api->getContainer(), $options, $appendContainerNameFn);
}

/**
Expand Down
19 changes: 17 additions & 2 deletions src/ObjectStore/v1/Models/StorageObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace OpenStack\ObjectStore\v1\Models;

use GuzzleHttp\Psr7\Uri;
use OpenStack\Common\Resource\Alias;
use OpenStack\Common\Transport\Utils;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
Expand Down Expand Up @@ -32,7 +33,7 @@ class StorageObject extends OperatorResource implements Creatable, Deletable, Ha
/** @var string */
public $contentType;

/** @var int */
/** @var \DateTimeImmutable */
public $contentLength;

/** @var string */
Expand All @@ -42,7 +43,21 @@ class StorageObject extends OperatorResource implements Creatable, Deletable, Ha
public $metadata;

protected $markerKey = 'name';
protected $aliases = ['bytes' => 'contentLength'];

protected $aliases = [
'bytes' => 'contentLength',
'content_type' => 'contentType',
];

/**
* @inheritdoc
*/
protected function getAliases(): array
{
return parent::getAliases() + [
'last_modified' => new Alias('lastModified', \DateTimeImmutable::class),
];
}

/**
* {@inheritdoc}
Expand Down