You are here

public function EntityProcessorBase::calculateDependencies in Feeds 8.3

Calculates dependencies for the configured plugin.

Dependencies are saved in the plugin's configuration entity and are used to determine configuration synchronization order. For example, if the plugin integrates with specific user roles, this method should return an array of dependencies listing the specified roles.

Return value

array An array of dependencies grouped by type (config, content, module, theme). For example:

array(
  'config' => array(
    'user.role.anonymous',
    'user.role.authenticated',
  ),
  'content' => array(
    'node:article:f0a189e6-55fb-47fb-8005-5bef81c44d6d',
  ),
  'module' => array(
    'node',
    'user',
  ),
  'theme' => array(
    'seven',
  ),
);

Overrides PluginBase::calculateDependencies

See also

\Drupal\Core\Config\Entity\ConfigDependencyManager

\Drupal\Core\Entity\EntityInterface::getConfigDependencyName()

File

src/Feeds/Processor/EntityProcessorBase.php, line 1162

Class

EntityProcessorBase
Defines a base entity processor.

Namespace

Drupal\feeds\Feeds\Processor

Code

public function calculateDependencies() {

  // Add dependency on entity type.
  $entity_type = $this->entityTypeManager
    ->getDefinition($this
    ->entityType());
  $this
    ->addDependency('module', $entity_type
    ->getProvider());

  // Add dependency on entity bundle.
  if ($this
    ->bundle()) {
    $bundle_dependency = $entity_type
      ->getBundleConfigDependency($this
      ->bundle());
    $this
      ->addDependency($bundle_dependency['type'], $bundle_dependency['name']);
  }

  // For the 'update_non_existent' setting, add dependency on selected action.
  switch ($this
    ->getConfiguration('update_non_existent')) {
    case static::KEEP_NON_EXISTENT:
    case static::DELETE_NON_EXISTENT:

      // No dependency to add.
      break;
    default:
      try {
        $definition = \Drupal::service('plugin.manager.action')
          ->getDefinition($this
          ->getConfiguration('update_non_existent'));
        if (isset($definition['provider'])) {
          $this
            ->addDependency('module', $definition['provider']);
        }
      } catch (PluginNotFoundException $e) {

        // It's possible that the selected action plugin no longer exists. Log
        // an error about it.
        \Drupal::logger('feeds')
          ->warning('The selected option for the setting "Previously imported items" in the feed type %feed_type_id no longer exists. Please edit the feed type and select a different option for that setting.', [
          '%feed_type_id' => $this->feedType
            ->id(),
        ]);
      }
      break;
  }
  return $this->dependencies;
}