View source
<?php
namespace Drupal\migrate_drupal\Plugin\migrate\destination;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\FieldTypePluginManagerInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Plugin\migrate\destination\EntityFieldStorageConfig as BaseEntityFieldStorageConfig;
class EntityFieldStorageConfig extends BaseEntityFieldStorageConfig {
protected $fieldTypePluginManager;
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, LanguageManagerInterface $language_manager, ConfigFactoryInterface $config_factory, FieldTypePluginManagerInterface $field_type_plugin_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $language_manager, $config_factory, $field_type_plugin_manager);
$this->languageManager = $language_manager;
$this->configFactory = $config_factory;
$this->fieldTypePluginManager = $field_type_plugin_manager;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
$entity_type_id = static::getEntityTypeId($plugin_id);
return new static($configuration, $plugin_id, $plugin_definition, $migration, $container
->get('entity_type.manager')
->getStorage($entity_type_id), array_keys($container
->get('entity_type.bundle.info')
->getBundleInfo($entity_type_id)), $container
->get('language_manager'), $container
->get('config.factory'), $container
->get('plugin.manager.field.field_type'));
}
public function calculateDependencies() {
$this->dependencies = parent::calculateDependencies();
$source_configuration = $this->migration
->getSourceConfiguration();
if (isset($source_configuration['constants']['type'])) {
$field_type = $this->fieldTypePluginManager
->getDefinition($source_configuration['constants']['type']);
$this
->addDependency('module', $field_type['provider']);
}
return $this->dependencies;
}
protected static function getEntityTypeId($plugin_id) {
return 'field_storage_config';
}
}