{% set currentLevelConfig = levelConfig[0] %}
{% import '@FoxHabbitBasis/Macro/wrap.html.twig' as wrap_macro %}
{{ wrap_macro.wrapperOpen( currentLevelConfig.type.wrapper, _context) }}
{% for page in navigation %}
{% if nav_page_check_permissions(page, app.getUser()) %}
{{ wrap_macro.wrapperOpen( currentLevelConfig.type.page_wrapper|default(null), _context) }}
{% set hasChildren = false %}
{% if page.hasChildren() %}
{% for subpage in page %}
{% if subpage.visible %}
{% set hasChildren = true %}
{% endif %}
{% endfor %}
{% endif %}
{% if hasChildren and currentLevelConfig.with_children|default(false) and currentLevelConfig.with_children.template and levelConfig[1] is defined %}
{% set template = currentLevelConfig.with_children.template %}
{% if not ( template starts with 'AppBundle' or template starts with '@App') %}
{% set template = '@FoxHabbitBasis/Areas/basisbundle-topnav/level-entries/' ~ template ~ '.html.twig' %}
{% endif %}
{% include template with {
page: page, entryConfig: currentLevelConfig.with_children, childLevelConfig: levelConfig|slice(1) } %}
{% elseif currentLevelConfig.entry.template %}
{% set template = currentLevelConfig.entry.template %}
{% if not ( template starts with 'AppBundle' or template starts with '@App') %}
{% set template = '@FoxHabbitBasis/Areas/basisbundle-topnav/level-entries/' ~ template ~ '.html.twig' %}
{% endif %}
{% include template with {
page: page, entryConfig: currentLevelConfig.entry, childLevelConfig: levelConfig|slice(1) } %}
{% endif %}
{{ wrap_macro.wrapperClose( currentLevelConfig.type.page_wrapper|default(null)) }}
{% endif %}
{% endfor %}
{% if currentLevelConfig.languageSelector|default(false) %}
{% include '@FoxHabbitBasis/Areas/basisbundle-topnav/language-selectors/' ~ currentLevelConfig.languageSelector.template ~ '.html.twig' with {
navigation: mainNavigation, levelConfig: currentLevelConfig.languageSelector, pageDocument: pageDocument, navRootProperty: currentLevelConfig.languageSelector.nav_root_property} %}
{% endif %}
{{ wrap_macro.wrapperClose( currentLevelConfig.type.wrapper) }}