You are here

protected function CommentVariable::getCommentVariables in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/comment/src/Plugin/migrate/source/d6/CommentVariable.php \Drupal\comment\Plugin\migrate\source\d6\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
Get the source count.
CommentVariable::initializeIterator in core/modules/comment/src/Plugin/migrate/source/d6/CommentVariable.php
Implementation of MigrateSource::performRewind().
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 41
Contains \Drupal\comment\Plugin\migrate\source\d6\CommentVariable.

Class

CommentVariable
Plugin annotation @MigrateSource( id = "d6_comment_variable" )

Namespace

Drupal\comment\Plugin\migrate\source\d6

Code

protected function getCommentVariables() {
  $comment_prefixes = array_keys($this
    ->commentPrefixes());
  $variables = array();
  $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 = array();
  $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;
}