protected function InstallHelper::processPage in Drupal 10
Same name and namespace in other branches
- 8 core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php \Drupal\demo_umami_content\InstallHelper::processPage()
- 9 core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php \Drupal\demo_umami_content\InstallHelper::processPage()
Process pages data into page node structure.
Parameters
array $data: Data of line that was read from the file.
string $langcode: Current language code.
Return value
array Data structured as a page node.
File
- core/
profiles/ demo_umami/ modules/ demo_umami_content/ src/ InstallHelper.php, line 386
Class
- InstallHelper
- Defines a helper class for importing default content.
Namespace
Drupal\demo_umami_contentCode
protected function processPage(array $data, $langcode) {
// Prepare content.
$values = [
'type' => 'page',
'title' => $data['title'],
'moderation_state' => 'published',
'langcode' => 'en',
];
// Fields mapping starts.
// Set body field.
if (!empty($data['body'])) {
$values['body'] = [
[
'value' => $data['body'],
'format' => 'basic_html',
],
];
}
// Set node alias if exists.
if (!empty($data['slug'])) {
$values['path'] = [
[
'alias' => '/' . $data['slug'],
],
];
}
// Save node alias
$this
->saveNodePath($langcode, 'page', $data['id'], $data['slug']);
// Set article author.
if (!empty($data['author'])) {
$values['uid'] = $this
->getUser($data['author']);
}
return $values;
}