public function Dom::export in Migrate Plus 8.4
Same name and namespace in other branches
- 8.5 src/Plugin/migrate/process/Dom.php \Drupal\migrate_plus\Plugin\migrate\process\Dom::export()
Converts a DOMDocument into a HTML string.
Parameters
mixed $value: The document to be exported.
\Drupal\migrate\MigrateExecutableInterface $migrate_executable: The migration in which this process is being executed.
\Drupal\migrate\Row $row: The row from the source to process. Normally, just transforming the value is adequate but very rarely you might need to change two columns at the same time or something like that.
string $destination_property: The destination property currently worked on. This is only used together with the $row above.
Return value
string The HTML string corresponding to the provided document object.
Throws
\Drupal\migrate\MigrateException When the received $value is not a \DOMDocument.
File
- src/
Plugin/ migrate/ process/ Dom.php, line 196
Class
- Dom
- Handles string to DOM and back conversions.
Namespace
Drupal\migrate_plus\Plugin\migrate\processCode
public function export($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if (!$value instanceof \DOMDocument) {
$value_description = gettype($value) == 'object' ? get_class($value) : gettype($value);
throw new MigrateException(sprintf('Cannot export a "%s".', $value_description));
}
if ($this->nonRoot) {
return Html::serialize($value);
}
return $value
->saveHTML();
}