function CommentVariable::getCommentVariables

Retrieves the values of the comment variables grouped by node type.

Return value

array

3 calls to CommentVariable::getCommentVariables()
CommentVariable::count in core/modules/comment/src/Plugin/migrate/source/d6/CommentVariable.php
Gets the source count.
CommentVariable::initializeIterator in core/modules/comment/src/Plugin/migrate/source/d6/CommentVariable.php
Initializes the iterator with the source data.
CommentVariablePerCommentType::getCommentVariables in core/modules/comment/src/Plugin/migrate/source/d6/CommentVariablePerCommentType.php
Retrieves the values of the comment variables grouped by comment type.
1 method overrides CommentVariable::getCommentVariables()
CommentVariablePerCommentType::getCommentVariables in core/modules/comment/src/Plugin/migrate/source/d6/CommentVariablePerCommentType.php
Retrieves the values of the comment variables grouped by comment type.

File

core/modules/comment/src/Plugin/migrate/source/d6/CommentVariable.php, line 42

Class

CommentVariable
Plugin annotation @MigrateSource( id = "d6_comment_variable", source_module = "comment" )

Namespace

Drupal\comment\Plugin\migrate\source\d6

Code

protected function getCommentVariables() {
    $comment_prefixes = array_keys($this->commentPrefixes());
    $variables = [];
    $node_types = $this->select('node_type', 'nt')
        ->fields('nt', [
        'type',
    ])
        ->execute()
        ->fetchCol();
    foreach ($node_types as $node_type) {
        foreach ($comment_prefixes as $prefix) {
            $variables[] = $prefix . '_' . $node_type;
        }
    }
    $return = [];
    $values = $this->select('variable', 'v')
        ->fields('v', [
        'name',
        'value',
    ])
        ->condition('name', $variables, 'IN')
        ->execute()
        ->fetchAllKeyed();
    foreach ($node_types as $node_type) {
        foreach ($comment_prefixes as $prefix) {
            $name = $prefix . '_' . $node_type;
            if (isset($values[$name])) {
                $return[$node_type][$prefix] = unserialize($values[$name]);
            }
        }
    }
    // The return key will not be used so move it inside the row. This could
    // not be done sooner because otherwise empty rows would be created with
    // just the node type in it.
    foreach ($return as $node_type => $data) {
        $return[$node_type]['node_type'] = $node_type;
        $return[$node_type]['comment_type'] = empty($data['comment_subject_field']) ? 'comment_no_subject' : 'comment';
    }
    return $return;
}

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