6
6
use Drupal \Core \Database \Driver \mysql \Connection ;
7
7
use Drupal \Core \Entity \EntityTypeManagerInterface ;
8
8
use Drupal \Console \Core \Style \DrupalStyle ;
9
+ use Drupal \node \NodeInterface ;
9
10
use Drush \Commands \DrushCommands ;
10
11
11
12
/**
@@ -123,9 +124,11 @@ public function processNodeStatus(int $nid, string $status) {
123
124
// Make the revision current and publish if necessary.
124
125
$ revision = $ this ->nodeStorage ->loadRevision ($ vid );
125
126
if (!empty ($ revision )) {
127
+ /** @var \Drupal\Core\Entity\EditorialContentEntityBase $revision */
126
128
$ revision ->isDefaultRevision (TRUE );
129
+
127
130
if ($ status == 1 ) {
128
- $ revision ->setpublished ();
131
+ $ revision ->setPublished ();
129
132
}
130
133
$ revision ->save ();
131
134
}
@@ -134,7 +137,7 @@ public function processNodeStatus(int $nid, string $status) {
134
137
if ($ status == 1 ) {
135
138
// If node was published on D7, make sure that it is published on D8.
136
139
$ node = $ this ->nodeStorage ->load ($ nid );
137
- if (! empty ( $ node) ) {
140
+ if ($ node instanceof NodeInterface ) {
138
141
$ node ->status = 1 ;
139
142
$ node ->set ('moderation_state ' , 'published ' );
140
143
$ node ->save ();
@@ -146,9 +149,11 @@ public function processNodeStatus(int $nid, string $status) {
146
149
select state from {workbench_moderation_node_history}
147
150
where hid = (select max(hid) from {workbench_moderation_node_history} where nid = :nid)
148
151
" , [':nid ' => $ nid ])->fetchField ();
152
+
149
153
if ($ moderation_status == 'needs_review ' ) {
150
154
// Make sure state is 'needs review' on D8.
151
155
$ node = $ this ->nodeStorage ->load ($ nid );
156
+ /** @var \Drupal\node\NodeInterface $node */
152
157
$ node ->set ('moderation_state ' , 'needs_review ' );
153
158
$ node ->save ();
154
159
}
0 commit comments