public function D7Webform::postRollback in Webform: Migrate 8.2
Same name and namespace in other branches
- 8 src/Plugin/migrate/source/d7/D7Webform.php \Drupal\webform_migrate\Plugin\migrate\source\d7\D7Webform::postRollback()
Performs post-rollback tasks.
Parameters
\Drupal\migrate\Event\MigrateRollbackEvent $event: The post-rollback event object.
Overrides SourcePluginBase::postRollback
File
- src/
Plugin/ migrate/ source/ d7/ D7Webform.php, line 948
Class
- D7Webform
- Drupal 7 webform source from database.
Namespace
Drupal\webform_migrate\Plugin\migrate\source\d7Code
public function postRollback(MigrateRollbackEvent $event) {
// Remove any Webform from webform if webform no longer exists.
$webforms = $this
->query()
->execute();
foreach ($webforms as $webform) {
$webform_nid = $webform['nid'];
$webform_id = 'webform_' . $webform_nid;
$webform = Webform::load($webform_id);
if (empty($webform)) {
/** @var \Drupal\node\NodeInterface $node */
$node = Node::load($webform_nid);
if (!empty($node) && $node
->getType() == 'webform') {
if (!empty($node->webform->target_id) && $node->webform->target_id == $webform_id) {
$node->webform->target_id = NULL;
$node
->save();
}
}
}
}
}