adobe / aem-core-wcm-components

Standardized components to build websites with AEM.
https://docs.adobe.com/content/help/en/experience-manager-core-components/using/introduction.html
Apache License 2.0
747 stars 753 forks source link

Cannot extend data layer to include a generic asset info for non-image #2883

Open HitmanInWis opened 1 month ago

HitmanInWis commented 1 month ago

If extending the Download component, it doesnt seem possible to effectively add the asset data for the linked file into the data layer.

There is a AssetDataBuilder in WCM Core, but it is only ever used from the ImageComponentDataBuilder. This requires the data layer to be rendered .asImageComponent() labeling the asset as "image" in the data layer output.

I considered making a new AssetComponentDataBuilder in my project, but to appropriately hook into and reuse the WCM Core data layer supplier capabilities I'd need to reference internal classes like com.adobe.cq.wcm.core.components.internal.models.v1.datalayer.builder.DataLayerSupplierImpl

That said, maybe I'm looking at the issue incorrectly - admittedly the data layer builder framework in WCM Core is very confusing to me - it seems extremely abstract with a lot of loose coupling that would appear to be in support of extension by client code, but then some of the most critical classes are buried in internal packages preventing them from being used in client extensions. The data layer works well enough for anything already supported in the WCM Core data layer implementation, it just seems very hard to expand upon it in a client project.