You are here

public function FieldTargetBase::onDependencyRemoval in Feeds 8.3

Allows a plugin to define whether it should be removed.

If this method returns TRUE then the plugin should be removed.

Parameters

array $dependencies: An array of dependencies that will be deleted, keyed by dependency type. Dependency types are, for example, entity, module and theme.

Return value

bool TRUE if the plugin instance should be removed.

Overrides TargetBase::onDependencyRemoval

See also

\Drupal\Core\Config\Entity\ConfigDependencyManager

\Drupal\Core\Config\ConfigEntityBase::preDelete()

\Drupal\Core\Config\ConfigManager::uninstall()

\Drupal\Core\Entity\EntityDisplayBase::onDependencyRemoval()

File

src/Plugin/Type/Target/FieldTargetBase.php, line 284

Class

FieldTargetBase
Helper class for field mappers.

Namespace

Drupal\feeds\Plugin\Type\Target

Code

public function onDependencyRemoval(array $dependencies) {

  // See if this target is responsible for any of the dependencies being
  // removed. If this is the case, indicate that the mapping that uses this
  // target needs to be removed from the feed type.
  $remove = FALSE;

  // Get all the current dependencies for this target.
  $current_dependencies = $this
    ->calculateDependencies();
  foreach ($current_dependencies as $group => $dependency_list) {

    // Check if any of the target dependencies match the dependencies being
    // removed.
    foreach ($dependency_list as $config_key) {
      if (isset($dependencies[$group]) && array_key_exists($config_key, $dependencies[$group])) {

        // This targets dependency matches a dependency being removed,
        // indicate that mapping using this target needs to be removed.
        $remove = TRUE;
        break 2;
      }
    }
  }
  return $remove;
}