Skip to content

Commit 4b97ac2

Browse files
authored
Merge pull request #21 from CarbonPackages/feature/neos9
Update: Make dual compatible with Neos 9 and 8
2 parents 7f9f8a6 + a458a5a commit 4b97ac2

File tree

7 files changed

+47
-20
lines changed

7 files changed

+47
-20
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ on top. To force a type you can write `(js)`, `(css)`, `(preloadasset)`, `(prelo
196196
| Property | Description |
197197
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
198198
| `file` | (string) The filename. You have to write it in the same way as it would be defined in the Settings.yaml file. Defaults to `null` |
199-
| `assetPackage` | (string) The name of the package. (Example: `Jonnitto.Plyr`) Defaults to `node.context.currentSite.siteResourcesPackageKey` |
199+
| `assetPackage` | (string) The name of the package. (Example: `Jonnitto.Plyr`) Defaults to `Carbon.IncludeAssets:SiteResourcesPackageKey` |
200200
| `cacheBuster` | (boolean) Append a hash value from the content of the file. Defaults to the value set in the [`Settings.Carbon.yaml`](Configuration/Settings.Carbon.yaml#L22) |
201201
| `assetPath` | (string) The path to the file inside the Resources folder. Per default, it is set dynamically |
202202
| `wrapper` | (string) If set, the tag will be wrapped. `{content}` will be replaced with the tag. Example: `'<!--[if lt IE 9]>{content}<![endif]-->'` |

Resources/Private/Fusion/External/File.fusion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ prototype(Carbon.IncludeAssets:File) < prototype(Neos.Fusion:Component) {
1313
}
1414

1515
file = ${null}
16-
assetPackage = ${node.context.currentSite.siteResourcesPackageKey}
16+
assetPackage = Carbon.IncludeAssets:SiteResourcesPackageKey
1717
cacheBuster = ${Configuration.setting('Carbon.IncludeAssets.Default.CacheBuster')}
1818
disableCacheBusterForPreloadAsset = ${Configuration.setting('Carbon.IncludeAssets.Default.DisableCacheBusterForPreloadAsset')}
1919
assetPath = ${null}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
prototype(Carbon.IncludeAssets:InBackend) < prototype(Neos.Fusion:Value) {
2-
node = ${node}
3-
4-
// Neos 9 compatible
5-
//renderingMode = ${renderingMode ? renderingMode.isEdit : null}
6-
7-
// Neos 8 compatible
8-
value = ${this.node.context.inBackend}
9-
// value = ${Type.isBoolean(this.renderingMode) ? this.renderingMode : this.node.context.inBackend}
1+
prototype(Carbon.IncludeAssets:InBackend) < prototype(Neos.Fusion:Case) {
2+
lowerThanNine {
3+
condition = ${Carbon.Version.lowerThanNine()}
4+
renderer = ${node.context.inBackend}
5+
}
6+
nineAndAbove {
7+
condition = true
8+
renderer = ${renderingMode.isEdit}
9+
}
1010
}

Resources/Private/Fusion/External/ResourceHints.fusion

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ prototype(Carbon.IncludeAssets:ResourceHints) < prototype(Neos.Fusion:Component)
1313
preloadNodes = ${PropTypes.anyOf(
1414
PropTypes.instanceOf('Neos\Eel\FlowQuery\FlowQuery'),
1515
PropTypes.arrayOf( PropTypes.instanceOf('Neos\ContentRepository\Domain\Model\Node') ),
16-
PropTypes.instanceOf('Neos\ContentRepository\Domain\Model\Node')
16+
PropTypes.instanceOf('Neos\ContentRepository\Domain\Model\Node'),
17+
PropTypes.arrayOf( PropTypes.instanceOf('Neos\ContentRepository\Core\Projection\ContentGraph\Node') ),
18+
PropTypes.instanceOf('Neos\ContentRepository\Core\Projection\ContentGraph\Node')
1719
)}
1820
prerenderNodes = ${PropTypes.anyOf(
1921
PropTypes.instanceOf('Neos\Eel\FlowQuery\FlowQuery'),
2022
PropTypes.arrayOf( PropTypes.instanceOf('Neos\ContentRepository\Domain\Model\Node') ),
21-
PropTypes.instanceOf('Neos\ContentRepository\Domain\Model\Node')
23+
PropTypes.instanceOf('Neos\ContentRepository\Domain\Model\Node'),
24+
PropTypes.arrayOf( PropTypes.instanceOf('Neos\ContentRepository\Core\Projection\ContentGraph\Node') ),
25+
PropTypes.instanceOf('Neos\ContentRepository\Core\Projection\ContentGraph\Node')
2226
)}
2327
}
2428

@@ -75,7 +79,12 @@ prototype(Carbon.IncludeAssets:ResourceHints.Items) < prototype(Neos.Fusion:Comp
7579

7680
prototype(Carbon.IncludeAssets:ResourceHints.Nodes) < prototype(Neos.Fusion:Component) {
7781
@propTypes {
78-
items = ${PropTypes.arrayOf( PropTypes.instanceOf('Neos\ContentRepository\Domain\Model\Node') )}
82+
items = ${PropTypes.anyOf(
83+
PropTypes.arrayOf( PropTypes.instanceOf('Neos\ContentRepository\Domain\Model\Node') ),
84+
PropTypes.arrayOf( PropTypes.instanceOf('Neos\ContentRepository\Core\Projection\ContentGraph\Node') ),
85+
PropTypes.instanceOf('Neos\ContentRepository\Core\Projection\ContentGraph\Nodes')
86+
)}
87+
7988
rel = ${PropTypes.oneOf(['preload', 'prerender'])}
8089
as = ${PropTypes.string}
8190
}
@@ -87,7 +96,9 @@ prototype(Carbon.IncludeAssets:ResourceHints.Nodes) < prototype(Neos.Fusion:Comp
8796
// Internal
8897
items.@process {
8998
convertFlowQueryToArray = ${Type.instance(value, 'Neos\Eel\FlowQuery\FlowQuery') ? value.get() : value}
90-
convertSingleToArray = ${Type.instance(value, 'Neos\ContentRepository\Domain\Model\Node') ? [value] : value}
99+
convertSingleLegacyNodeToArray = ${Type.instance(value, 'Neos\ContentRepository\Domain\Model\Node') ? [value] : value}
100+
convertSingleNodeToArray = ${Type.instance(value, 'Neos\ContentRepository\Core\Projection\ContentGraph\Node') ? [value] : value}
101+
convertNodesToArray = ${Type.instance(value, 'Neos\ContentRepository\Core\Projection\ContentGraph\Nodes') ? Array.values(value) : value}
91102
}
92103
@if.set = ${this.items && this.rel && Type.isArray(this.items) && Array.length(this.items)}
93104

@@ -97,7 +108,7 @@ prototype(Carbon.IncludeAssets:ResourceHints.Nodes) < prototype(Neos.Fusion:Comp
97108
<link
98109
rel={props.rel}
99110
as={props.as}
100-
@if.isNode={Type.instance(item, 'Neos\ContentRepository\Domain\Model\Node')}
111+
@if.isNode={Type.instance(item, 'Neos\ContentRepository\Domain\Model\Node') || Type.instance(item, 'Neos\ContentRepository\Core\Projection\ContentGraph\Node')}
101112
@if.isNotCurrent={documentNode != item}
102113
@if.isDocument={q(item).is('[instanceof Neos.Neos:Document]')}
103114
>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
prototype(Carbon.IncludeAssets:SiteResourcesPackageKey) < prototype(Neos.Fusion:Case) {
2+
lowerThanNine {
3+
condition = ${Carbon.Version.lowerThanNine()}
4+
renderer = ${node.context.currentSite.siteResourcesPackageKey}
5+
}
6+
nineAndAbove {
7+
condition = true
8+
renderer = ${Neos.Site.findBySiteNode(site).siteResourcesPackageKey}
9+
}
10+
}

Resources/Private/Fusion/Internal/Package.fusion

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@ prototype(Carbon.IncludeAssets:Internal.Package) < prototype(Neos.Fusion:Compone
1313

1414
// Internal property
1515
mergedConfig = ${Array.concat(Configuration.setting('Carbon.IncludeAssets.Default'), this.config)}
16-
sitePackageKey = ${this.monocle ? sitePackageKey : node.context.currentSite.siteResourcesPackageKey}
17-
inBackend = Carbon.IncludeAssets:InBackend
16+
sitePackageKey = ${this.monocle ? sitePackageKey : null}
17+
sitePackageKey.@process.set = Carbon.IncludeAssets:SiteResourcesPackageKey {
18+
@if.noSet = ${!Type.isString(value)}
19+
}
20+
inBackend = ${this.monocle ? false : null}
21+
inBackend.@process.set = Carbon.IncludeAssets:InBackend {
22+
@if.notSet = ${!Type.isBoolean(value)}
23+
}
1824

1925
renderer = Neos.Fusion:Component {
2026
@if.hasCustomCondition = Neos.Fusion:Case {

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"license": "GPL-3.0-or-later",
66
"keywords": ["flow", "neos", "fusion", "helper", "carbon"],
77
"require": {
8-
"neos/neos": "^8.0",
9-
"carbon/eel": "^2.0"
8+
"neos/neos": "^8.0 || ^9.0",
9+
"carbon/eel": "^2.19"
1010
},
1111
"authors": [
1212
{

0 commit comments

Comments
 (0)