Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@ services:
class: Drupal\ncids_html_transformer\Services\NcidsDisallowedStylesTransformer
tags:
- { name: ncids_html_transformer.ncids_html_transform, priority: 10 }
ncids_html_transformer.unwrap_transformer:
class: Drupal\ncids_html_transformer\Services\NcidsUnwrapTransformer
arguments: ['@logger.channel.ncids_migration']
tags:
- { name: ncids_html_transformer.ncids_html_transform, priority: 0 }
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public static function processArticle($nid, &$context): void {
}

try {
\Drupal::logger('ncids_migration')->notice('Starting processing for nid: {nid}', ['nid' => $nid]);

$node = Node::load($nid);

if (!$node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,31 @@ private function getNewPullquoteHtml(
if (!empty($pullquote_text)) {
$text_el = $dom->createElement('p');
$text_el->setAttribute('class', 'cgdp-pullquote__body');
$this->insertChildHtml($dom, $text_el, $pullquote_text);

// Parse the transformed text.
$tmp_dom = Html::load($pullquote_text);
$body = $tmp_dom->getElementsByTagName('body')->item(0);

if ($body && $body->hasChildNodes()) {
// Check if we have a single paragraph element.
if ($body->childNodes->length === 1 &&
$body->firstChild instanceof \DOMElement &&
$body->firstChild->tagName === 'p') {
// Extract content from inside the paragraph.
foreach ($body->firstChild->childNodes as $child) {
$imported_node = $dom->importNode($child, TRUE);
$text_el->appendChild($imported_node);
}
}
else {
// Use content as-is.
foreach ($body->childNodes as $node) {
$imported_node = $dom->importNode($node, TRUE);
$text_el->appendChild($imported_node);
}
}
}

$pullquote_container->appendChild($text_el);
}

Expand Down
Loading