14
14
use Flowpack \DecoupledContentStore \PrepareContentRelease \Infrastructure \RedisContentReleaseService ;
15
15
use Flowpack \DecoupledContentStore \Utility \GeneratorUtility ;
16
16
use Neos \ContentRepository \Domain \Model \NodeInterface ;
17
- use Neos \ContentRepository \Domain \NodeType \NodeTypeConstraintFactory ;
18
- use Neos \ContentRepository \Domain \NodeType \NodeTypeName ;
19
- use Neos \ContentRepository \Domain \Utility \NodePaths ;
20
17
use Neos \Eel \FlowQuery \FlowQuery ;
21
18
use Neos \Flow \Annotations as Flow ;
22
19
use Neos \Neos \Domain \Model \Site ;
23
20
24
21
class NodeEnumerator
25
22
{
26
- /**
27
- * @Flow\Inject
28
- * @var NodeTypeConstraintFactory
29
- */
30
- protected $ nodeTypeConstraintFactory ;
31
23
32
24
/**
33
25
* @Flow\Inject
@@ -79,9 +71,16 @@ private function enumerateAll(?Site $site, ContentReleaseLogger $contentReleaseL
79
71
{
80
72
$ combinator = new NodeContextCombinator ();
81
73
82
- $ nodeTypeWhitelist = $ this ->nodeTypeConstraintFactory ->parseFilterString ($ this ->nodeTypeWhitelist );
74
+ // Build filter from white listed nodetypes
75
+ $ nodeTypeWhitelist = explode (', ' , $ this ->nodeTypeWhitelist ?: 'Neos.Neos:Document ' );
76
+ $ nodeTypeFilter = implode (', ' , array_map (static function ($ nodeType ) {
77
+ if ($ nodeType [0 ] === '! ' ) {
78
+ return '[!instanceof ' . substr ($ nodeType , 1 ) . '] ' ;
79
+ }
80
+ return '[instanceof ' . $ nodeType . '] ' ;
81
+ }, $ nodeTypeWhitelist ));
83
82
84
- $ queueSite = function (Site $ site ) use ($ combinator , $ nodeTypeWhitelist , $ contentReleaseLogger , $ workspaceName ) {
83
+ $ queueSite = static function (Site $ site ) use ($ combinator , $ nodeTypeFilter , $ contentReleaseLogger , $ workspaceName ) {
85
84
$ contentReleaseLogger ->debug ('Publishing site ' , [
86
85
'name ' => $ site ->getName (),
87
86
'domain ' => $ site ->getFirstActiveDomain ()
@@ -94,24 +93,15 @@ private function enumerateAll(?Site $site, ContentReleaseLogger $contentReleaseL
94
93
'dimensionValues ' => $ dimensionValues
95
94
]);
96
95
97
- // Build filter from white listed nodetypes
98
- $ nodeTypeWhitelist = explode (', ' , $ this ->nodeTypeWhitelist ?: 'Neos.Neos:Document ' );
99
- $ nodeTypeFilter = implode (', ' , array_map (static function ($ nodeType ) {
100
- if ($ nodeType [0 ] === '! ' ) {
101
- return '[!instanceof ' . substr ($ nodeType , 1 ) . '] ' ;
102
- }
103
- return '[instanceof ' . $ nodeType . '] ' ;
104
- }, $ nodeTypeWhitelist ));
105
-
106
- $ documentQuery = new FlowQuery ([$ siteNode ]);
107
- /** @var NodeInterface[] $documents */
108
- $ documents = $ documentQuery ->find ($ nodeTypeFilter )->add ($ siteNode )->get ();
96
+ $ nodeQuery = new FlowQuery ([$ siteNode ]);
97
+ /** @var NodeInterface[] $matchingNodes */
98
+ $ matchingNodes = $ nodeQuery ->find ($ nodeTypeFilter )->add ($ siteNode )->get ();
109
99
110
- foreach ($ documents as $ documentNode ) {
111
- $ contextPath = $ documentNode ->getContextPath ();
100
+ foreach ($ matchingNodes as $ nodeToEnumerate ) {
101
+ $ contextPath = $ nodeToEnumerate ->getContextPath ();
112
102
113
103
// Verify that the node is not orphaned
114
- $ parentNode = $ documentNode ->getParent ();
104
+ $ parentNode = $ nodeToEnumerate ->getParent ();
115
105
while ($ parentNode !== $ siteNode ) {
116
106
if ($ parentNode === null ) {
117
107
$ contentReleaseLogger ->debug ('Skipping node from publishing, because it is orphaned ' , [
@@ -123,28 +113,24 @@ private function enumerateAll(?Site $site, ContentReleaseLogger $contentReleaseL
123
113
$ parentNode = $ parentNode ->getParent ();
124
114
}
125
115
126
- if (!$ documentNode ->getParent ()) {
127
- $ contentReleaseLogger ->debug ('Skipping node from publishing, because it is orphaned ' , [
128
- 'node ' => $ contextPath ,
129
- ]);
130
- } else if ($ documentNode ->isHidden ()) {
116
+ if ($ nodeToEnumerate ->isHidden ()) {
131
117
$ contentReleaseLogger ->debug ('Skipping node from publishing, because it is hidden ' , [
132
118
'node ' => $ contextPath ,
133
119
]);
134
120
} else {
135
121
$ contentReleaseLogger ->debug ('Registering node for publishing ' , [
136
122
'node ' => $ contextPath
137
123
]);
138
- yield EnumeratedNode::fromNode ($ documentNode );
124
+ yield EnumeratedNode::fromNode ($ nodeToEnumerate );
139
125
}
140
126
}
141
127
}
142
128
$ contentReleaseLogger ->debug (sprintf ('Finished enumerating site %s in %dms ' , $ site ->getName (), (microtime (true ) - $ startTime ) * 1000 ));
143
129
};
144
130
145
131
if ($ site === null ) {
146
- foreach ($ combinator ->sites () as $ site ) {
147
- yield from $ queueSite ($ site );
132
+ foreach ($ combinator ->sites () as $ siteInList ) {
133
+ yield from $ queueSite ($ siteInList );
148
134
}
149
135
} else {
150
136
yield from $ queueSite ($ site );
0 commit comments