use of com.day.cq.wcm.api.PageManager in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class PWAImpl method initModel.
@PostConstruct
protected void initModel() {
PageManager pageManager = resource.getResourceResolver().adaptTo(PageManager.class);
if (pageManager == null) {
return;
}
Page page = pageManager.getContainingPage(resource);
while (page != null) {
Resource contentResource = page.getContentResource();
if (contentResource != null) {
ValueMap valueMap = contentResource.getValueMap();
Boolean isPWAEnabled = valueMap.get(PN_PWA_ENABLED, Boolean.class);
if (isPWAEnabled != null && isPWAEnabled) {
this.isEnabled = true;
this.themeColor = colorToHex(valueMap.get(PN_PWA_THEME_COLOR, ""));
this.iconPath = valueMap.get(PN_PWA_ICON_PATH, "");
String startURL = valueMap.get(PN_PWA_START_URL, "");
this.manifestPath = replaceSuffix(startURL, MANIFEST_NAME);
String mappingName = page.getPath().replace(CONTENT_PATH, "").replace("/", ".");
this.serviceWorkerPath = "/" + mappingName + "sw.js";
break;
}
}
page = page.getParent();
}
}
Aggregations