function InstallHelper::processPage

Same name in other branches
  1. 9 core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php \Drupal\demo_umami_content\InstallHelper::processPage()
  2. 10 core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php \Drupal\demo_umami_content\InstallHelper::processPage()
  3. 11.x 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.

1 call to InstallHelper::processPage()
InstallHelper::processContent in core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php
Process content into a structure that can be saved into Drupal.

File

core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php, line 398

Class

InstallHelper
Defines a helper class for importing default content.

Namespace

Drupal\demo_umami_content

Code

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.