use of com.day.cq.wcm.api.Page in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ContainerImplTest method setUp.
@Before
public void setUp() {
Page page = context.currentPage(CONTAINING_PAGE);
slingBindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName());
slingBindings.put(WCMBindings.CURRENT_PAGE, page);
context.registerService(FormStructureHelperFactory.class, formStructureHelperFactory);
FormsHelperStubber.createStub();
}
use of com.day.cq.wcm.api.Page in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class BreadcrumbImpl method addNavigationItems.
private void addNavigationItems(int currentLevel) {
while (startLevel < currentLevel) {
Page page = currentPage.getAbsoluteParent(startLevel);
if (page != null) {
boolean isActivePage = page.equals(currentPage);
if (isActivePage && hideCurrent) {
break;
}
if (checkIfNotHidden(page)) {
NavigationItem navigationItem = new NavigationItemImpl(page, isActivePage);
items.add(navigationItem);
}
}
startLevel++;
}
}
use of com.day.cq.wcm.api.Page in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class WCMUsePojoBaseTest method getResourceBackedBindings.
/**
* <p>
* Creates a {@link Bindings} map initialised with the following default bindings available to Sightly use objects based on {@link
* WCMUsePojo}:
* </p>
* <ul>
* <li>{@link SlingBindings#RESOURCE}</li>
* <li>{@link SlingBindings#REQUEST}</li>
* <li>{@link SlingBindings#RESPONSE}</li>
* <li>{@link WCMBindings#PROPERTIES}</li>
* <li>{@link WCMBindings#WCM_MODE}</li>
* <li>{@link WCMBindings#PAGE_MANAGER}</li>
* <li>{@link WCMBindings#RESOURCE_PAGE}</li>
* <li>{@link WCMBindings#CURRENT_PAGE}</li>
* <li>{@link WCMBindings#PAGE_PROPERTIES}</li>
* </ul>
*
* @param resourcePath the path to a resource already loaded in the testing context
* @return the bindings map
*/
protected Bindings getResourceBackedBindings(String resourcePath) {
Bindings bindings = getDefaultSlingBindings();
Resource resource = context.resourceResolver().getResource(resourcePath);
if (resource != null) {
ValueMap properties = resource.adaptTo(ValueMap.class);
bindings.put(SlingBindings.RESOURCE, resource);
bindings.put(WCMBindings.PROPERTIES, properties);
bindings.put(WCMBindings.WCM_MODE, new SightlyWCMMode(context.request()));
PageManager pageManager = context.pageManager();
bindings.put(WCMBindings.PAGE_MANAGER, pageManager);
context.request().setResource(resource);
Page resourcePage = pageManager.getContainingPage(resource);
if (resourcePage != null) {
bindings.put(WCMBindings.RESOURCE_PAGE, resourcePage);
bindings.put(WCMBindings.CURRENT_PAGE, resourcePage);
bindings.put(WCMBindings.PAGE_PROPERTIES, properties);
}
} else {
throw new IllegalArgumentException("Cannot find a resource at " + resourcePath);
}
return bindings;
}
use of com.day.cq.wcm.api.Page in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ListImpl method populateChildListItems.
private void populateChildListItems() {
listItems = new ArrayList<>();
Page rootPage = getRootPage(PN_PARENT_PAGE);
if (rootPage != null) {
collectChildren(rootPage.getDepth(), rootPage);
}
}
use of com.day.cq.wcm.api.Page in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ListImpl method collectChildren.
private void collectChildren(int startLevel, Page parent) {
Iterator<Page> childIterator = parent.listChildren();
while (childIterator.hasNext()) {
Page child = childIterator.next();
listItems.add(child);
if (child.getDepth() - startLevel < childDepth) {
collectChildren(startLevel, child);
}
}
}
Aggregations