Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass DimensionContentCollection to DataMapper services #182

Merged
merged 15 commits into from
Jan 20, 2021

Conversation

niklasnatter
Copy link
Contributor

@niklasnatter niklasnatter commented Jan 18, 2021

This PR aadjust the ContentDataMapper service and the DataMapper services to accept a DimensionContentCollection parameter instead of a unlocalizedObject and an optional localizedObject parameter.

This makes the interfaces more flexible and consistent to other parts of the bundle.

Copy link
Member

@alexander-schranz alexander-schranz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally not so happy with the Preview Handling, but it was also not good before. I would atleast simulate the count: 2 and mark the PreviewCollection as internal so we can change it the way we need it in future.

/**
* @implements \IteratorAggregate<DimensionContentInterface>
*/
class PreviewDimensionContentCollection implements \IteratorAggregate, DimensionContentCollectionInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this class. Can we mark it as @internal at current state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


public function getDimensionAttributes(): array
{
return ['locale' => $this->previewLocale];
Copy link
Member

@alexander-schranz alexander-schranz Jan 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A DimensionCollection should always return all its DimensionAttributes so we should array_merge() them here with the getDefaultDimensionAttributes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +63 to +66
public function count(): int
{
return 1;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really happy with this :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we should return here 2 to simulate that we have a unlocalized and localizedObject.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think i would not return 2 because that is misleading

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i could adjust the DimensionContentCollectionInterface to not extend Countable as described in #178 to get rid of the method 😇

@niklasnatter niklasnatter force-pushed the enhancement/mapper-collection-parameter branch from ee772bc to 75419a7 Compare January 18, 2021 17:36
@niklasnatter
Copy link
Contributor Author

@alexander-schranz Not really happy about the preview handling too, but I dont have a better idea at the moment. Do you see a better alternative?

@niklasnatter niklasnatter marked this pull request as ready for review January 19, 2021 08:36
@alexander-schranz alexander-schranz merged commit 8f26491 into 0.x Jan 20, 2021
@alexander-schranz alexander-schranz deleted the enhancement/mapper-collection-parameter branch February 19, 2021 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants