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
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ final class AttributesResourceMetadataCollectionFactory implements ResourceMetad

public function __construct(ResourceMetadataCollectionFactoryInterface $decorated = null, LoggerInterface $logger = null, array $defaults = [], bool $graphQlEnabled = false)
{
$this->defaults = $defaults + ['attributes' => []];
$this->defaults = $defaults;
$this->decorated = $decorated;
$this->logger = $logger ?? new NullLogger();
$this->graphQlEnabled = $graphQlEnabled;
Expand Down Expand Up @@ -235,7 +235,7 @@ private function getOperationWithDefaults(ApiResource $resource, Operation $oper
private function addGlobalDefaults($operation)
{
$extraProperties = $operation->getExtraProperties();
foreach ($this->defaults['attributes'] as $key => $value) {
foreach ($this->defaults as $key => $value) {
[$newKey, $value] = $this->getKeyValue($key, $value);
$upperKey = ucfirst($newKey);
$getter = 'get'.$upperKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class: AttributeResources::class,

public function testCreateWithDefaults(): void
{
$attributeResourceMetadataCollectionFactory = new AttributesResourceMetadataCollectionFactory(null, null, ['attributes' => ['cache_headers' => ['max_age' => 60], 'non_existing_attribute' => 'foo']]);
$attributeResourceMetadataCollectionFactory = new AttributesResourceMetadataCollectionFactory(null, null, ['cache_headers' => ['max_age' => 60], 'non_existing_attribute' => 'foo']);

$operation = new HttpOperation(shortName: 'AttributeDefaultOperations', class: AttributeDefaultOperations::class, cacheHeaders: ['max_age' => 60], paginationItemsPerPage: 10, extraProperties: ['non_existing_attribute' => 'foo']);

Expand Down Expand Up @@ -165,9 +165,7 @@ public function testCreateShouldNotOverrideWithDefault(): void
{
$attributeResourceMetadataCollectionFactory = new AttributesResourceMetadataCollectionFactory(
null, null, [
'attributes' => [
'pagination_items_per_page' => 3,
],
'pagination_items_per_page' => 3,
]
);

Expand Down