You are here

protected function Node::getFieldInfo in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/node/src/Plugin/migrate/source/d6/Node.php \Drupal\node\Plugin\migrate\source\d6\Node::getFieldInfo()

Gets CCK field and instance definitions from the database.

Parameters

string $node_type: The node type for which to get field info.

Return value

array Field and instance information for the node type, keyed by field name.

1 call to Node::getFieldInfo()
Node::getFieldValues in core/modules/node/src/Plugin/migrate/source/d6/Node.php
Gets CCK field values for a node.

File

core/modules/node/src/Plugin/migrate/source/d6/Node.php, line 160
Contains \Drupal\node\Plugin\migrate\source\d6\Node.

Class

Node
Drupal 6 node source from database.

Namespace

Drupal\node\Plugin\migrate\source\d6

Code

protected function getFieldInfo($node_type) {
  if (!isset($this->fieldInfo)) {
    $this->fieldInfo = [];

    // Query the database directly for all CCK field info.
    $query = $this
      ->select('content_node_field_instance', 'cnfi');
    $query
      ->join('content_node_field', 'cnf', 'cnf.field_name = cnfi.field_name');
    $query
      ->fields('cnfi');
    $query
      ->fields('cnf');
    foreach ($query
      ->execute() as $field) {
      $this->fieldInfo[$field['type_name']][$field['field_name']] = $field;
    }
    foreach ($this->fieldInfo as $type => $fields) {
      foreach ($fields as $field => $info) {
        foreach ($info as $property => $value) {
          if ($property == 'db_columns' || preg_match('/_settings$/', $property)) {
            $this->fieldInfo[$type][$field][$property] = unserialize($value);
          }
        }
      }
    }
  }
  return isset($this->fieldInfo[$node_type]) ? $this->fieldInfo[$node_type] : [];
}