You are here

public function FeedType::getTargetPlugin in Feeds 8.3

@todo Use plugin bag.

Overrides FeedTypeInterface::getTargetPlugin

2 calls to FeedType::getTargetPlugin()
FeedType::calculateDependencies in src/Entity/FeedType.php
Calculates dependencies and stores them in the dependency property.
FeedType::onDependencyRemoval in src/Entity/FeedType.php
Informs the entity that entities it depends on will be deleted.

File

src/Entity/FeedType.php, line 459

Class

FeedType
Defines the Feeds feed type entity.

Namespace

Drupal\feeds\Entity

Code

public function getTargetPlugin($delta) {
  if (isset($this->targetPlugins[$delta])) {
    return $this->targetPlugins[$delta];
  }
  $targets = $this
    ->getMappingTargets();
  $target = $this->mappings[$delta]['target'];

  // Make sure that the target exists.
  if (!isset($targets[$target])) {

    // The target is missing!
    throw new MissingTargetException(sprintf('The Feeds target "%s" does not exist.', $target));
  }

  // The target is a plugin.
  $id = $targets[$target]
    ->getPluginId();
  $configuration = [];
  $configuration['feed_type'] = $this;
  $configuration['target_definition'] = $targets[$target];
  if (isset($this->mappings[$delta]['settings'])) {
    $configuration += $this->mappings[$delta]['settings'];
  }
  $this->targetPlugins[$delta] = \Drupal::service('plugin.manager.feeds.target')
    ->createInstance($id, $configuration);
  return $this->targetPlugins[$delta];
}