Search in sources :

Example 1 with ComponentPath

use of com.enonic.xp.region.ComponentPath in project xp by enonic.

the class ComponentHandlerWorker method inlineFragments.

private Page inlineFragments(Page page, final ComponentPath componentPath) {
    // traverse page based on componentPath, inline fragments components if found
    final List<ComponentPath.RegionAndComponent> partialComponentPathParts = new ArrayList<>();
    for (ComponentPath.RegionAndComponent pathPart : componentPath) {
        partialComponentPathParts.add(pathPart);
        final ComponentPath path = new ComponentPath(ImmutableList.copyOf(partialComponentPathParts));
        final Component component = page.getRegions().getComponent(path);
        if (component == null) {
            break;
        }
        if (component instanceof FragmentComponent) {
            final FragmentComponent fragment = (FragmentComponent) component;
            final Component fragmentComponent = getFragmentComponent(fragment);
            if (fragmentComponent == null) {
                break;
            }
            page = new FragmentPageResolver().inlineFragmentInPage(page, fragmentComponent, path);
        }
    }
    return page;
}
Also used : ComponentPath(com.enonic.xp.region.ComponentPath) FragmentPageResolver(com.enonic.xp.portal.impl.rendering.FragmentPageResolver) ArrayList(java.util.ArrayList) FragmentComponent(com.enonic.xp.region.FragmentComponent) FragmentComponent(com.enonic.xp.region.FragmentComponent) Component(com.enonic.xp.region.Component) LayoutComponent(com.enonic.xp.region.LayoutComponent)

Aggregations

FragmentPageResolver (com.enonic.xp.portal.impl.rendering.FragmentPageResolver)1 Component (com.enonic.xp.region.Component)1 ComponentPath (com.enonic.xp.region.ComponentPath)1 FragmentComponent (com.enonic.xp.region.FragmentComponent)1 LayoutComponent (com.enonic.xp.region.LayoutComponent)1 ArrayList (java.util.ArrayList)1