You are here

public static function BasicFieldSource::sources in Feeds 8.3

Adds sources to the $source array for this field.

Parameters

array $sources: The list of sources to modify.

\Drupal\feeds\FeedTypeInterface $feed_type: The feed type being added to.

array $definition: The plugin definition.

Overrides SourceInterface::sources

File

src/Feeds/Source/BasicFieldSource.php, line 22

Class

BasicFieldSource
A source plugin that provides feed type fields as mapping sources.

Namespace

Drupal\feeds\Feeds\Source

Code

public static function sources(array &$sources, FeedTypeInterface $feed_type, array $definition) {
  $field_definitions = \Drupal::service('entity_field.manager')
    ->getFieldDefinitions('feeds_feed', $feed_type
    ->id());
  foreach ($field_definitions as $field => $field_definition) {
    if (!$field_definition
      ->getFieldStorageDefinition()
      ->getMainPropertyName()) {

      // No main property known. Skip this field.
      continue;
    }
    $sources['parent:' . $field] = [
      'label' => t('Feed: @label', [
        '@label' => $field_definition
          ->getLabel(),
      ]),
      'description' => $field_definition
        ->getDescription(),
      'id' => $definition['id'],
    ];
  }
}