Open niklasnatter opened 4 years ago
For me this is a little bit related to the options parameters #136.
The document manager provides also options e.g.: ['load_ghost_content' => false]
. I think something similar does make sense.
public function resolve(
ContentRichEntityInterface $contentRichEntity,
array $dimensionAttributes,
array $options = []
): ContentProjectionInterface;
The
ContentResolver
service allows to resolve the effective content for a givenContentRichEntity
and givendimensionAttributes
. In this context, effective content means that the object returned by theContentResolver
is a merged representation/projection of all relevantDimensionContent
s (eg. localizedDimensionContent
and unlocalizedDimensionContent
) for the givendimensionAttributes
.The
ContentResolver
throws anContentNotFoundException
, when there are no relevantDimensionContent
s found. At the moment, no exception is thrown if there is at least one relevantDimensionContent
.This means that the
ContentResolver
does not throw an exception when a developer queries for the published german content with the dimensionAttributes['stage' => 'live', 'locale' => 'de']
if there is at least one published language (even if the german content is not published). Because of this, we need to explicitly check the resolved content with the following code in various places of the bundle and also in our projects:In my opinion, this is not not a great DX. Firstly, as a developer, I do not expect this behaviour and therefore it is really easy to forget about the check. Secondly, the consequences of forgetting about the check are quite big.
As there are still places where the current behaviour is desired, a way for solving this would be adding a
throwIfDimensionAttributesDoNotMatch
flag (hopefully we will find a better name) to theresolve()
method of theContentResolver
. This would lead to the following method signature: