Skip to content

Instantly share code, notes, and snippets.

@mficzel
Last active February 25, 2019 08:04
Show Gist options
  • Save mficzel/d807533b8c96c03dabfb49f5b9941fce to your computer and use it in GitHub Desktop.
Save mficzel/d807533b8c96c03dabfb49f5b9941fce to your computer and use it in GitHub Desktop.
SKETCH :: Extract Neos.Neos:MenuData from Neos.Neos:Menu
//
// The prototype Menu is now based on template, like he already is
// the calulation of the menu items is passed over to MenuData
//
prototype (Neos.Neos:Menu) < prototype(Neos.Neos:Template) {
templatePath = 'resource://Neos.Neos/Private/Templates/FusionObjects/Menu.html'
node = ${node}
items = ${this.items}
entryLevel = ${this.startingPoint ? 0 : 1}
maximumLevels = 2
filter = 'Neos.Neos:Document'
attributes = Neos.Fusion:Attributes
active.attributes = Neos.Fusion:Attributes {
class = 'active'
}
current.attributes = Neos.Fusion:Attributes {
class = 'current'
}
normal.attributes = Neos.Fusion:Attributes {
class = 'normal'
}
@exceptionHandler = 'Neos\\Fusion\\Core\\ExceptionHandlers\\ContextDependentHandler'
@cache {
mode = 'cached'
entryIdentifier {
documentNode = ${documentNode}
}
entryTags {
1 = ${Neos.Caching.nodeTypeTag('Neos.Neos:Document', documentNode)}
}
}
//
// Pass all relevant attributes to Neos.Neos:MenuData and calculate items
//
@context.node = ${this.node}
@context.itemCollection = ${this.itemCollection}
@context.startingPoint = ${this.startingPoint}
@context.entryLevel = ${this.entryLevel}
@context.maximumLevels = ${this.maximumLevels}
@context.renderHiddenInIndex = ${this.renderHiddenInIndex}
items = Neos.Neos:MenuData {
node = ${node}
itemCollection = ${itemCollection}
startingPoint = ${startingPoint}
entryLevel = ${entryLevel}
maximumLevels = ${maximumLevels}
renderHiddenInIndex = ${renderHiddenInIndex}
}
}
//
// The prototype menuData uses the MenuDataImplementation that contains
// the extracted itemCalculation from the old MenuImplementation
//
prototype (Neos.Neos:MenuData) {
@class = 'Neos\\Neos\\Fusion\\MenuDataImplementation'
node = null
itemCollection = null
startingPoint = ${node}
entryLevel = ${this.startingPoint ? 0 : 1}
maximumLevels = 2
renderHiddenInIndex = false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment