You are here

public function EntityLoadHelper::categorizeAttributes in YAML Content 8

Group content data attributes by type.

Parameters

$entity_type: The entity type ID.

array $content_data: The import content structure being parsed for properties.

Return value

array An array of entity content keys grouped by attribute type:

  • 'property'
  • 'field'
  • 'other'
1 call to EntityLoadHelper::categorizeAttributes()
EntityLoadHelper::extractContentProperties in src/Service/EntityLoadHelper.php
Identify entity properties from content data.

File

src/Service/EntityLoadHelper.php, line 236

Class

EntityLoadHelper
A helper class to support identification and loading of existing entities.

Namespace

Drupal\yaml_content\Service

Code

public function categorizeAttributes($entity_type, array $content_data) {

  // Parse properties for creation and fields for processing.
  $attributes = [
    'property' => [],
    'field' => [],
    'other' => [],
  ];
  foreach ($content_data as $key => $data) {
    $type = $this
      ->identifyAttributeType($entity_type, $key);

    // Process simple values as properties for initial creation.
    if ($type == 'field' && !is_array($data)) {
      $type = 'property';
    }
    $attributes[$type][$key] = $data;
  }
  return $attributes;
}