class D7FieldablePanelsPaneDeriver in Fieldable Panels Panes (FPP) 1.0.x
Deriver for Drupal 7 fieldable panel panes based on pane types.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\fieldable_panels_panes\Plugin\migrate\D7FieldablePanelsPaneDeriver implements ContainerDeriverInterface uses StringTranslationTrait, MigrationDeriverTrait
Expanded class hierarchy of D7FieldablePanelsPaneDeriver
3 string references to 'D7FieldablePanelsPaneDeriver'
- d7_fieldable_panels_pane.yml in migrations/
d7_fieldable_panels_pane.yml - migrations/d7_fieldable_panels_pane.yml
- d7_fieldable_panels_pane_entity_translation.yml in migrations/
d7_fieldable_panels_pane_entity_translation.yml - migrations/d7_fieldable_panels_pane_entity_translation.yml
- d7_fieldable_panels_pane_revision.yml in migrations/
d7_fieldable_panels_pane_revision.yml - migrations/d7_fieldable_panels_pane_revision.yml
File
- src/
Plugin/ migrate/ D7FieldablePanelsPaneDeriver.php, line 17
Namespace
Drupal\fieldable_panels_panes\Plugin\migrateView source
class D7FieldablePanelsPaneDeriver extends DeriverBase implements ContainerDeriverInterface {
use MigrationDeriverTrait;
use StringTranslationTrait;
/**
* The base plugin ID this derivative is for.
*
* @var string
*/
protected $basePluginId;
/**
* Whether or not to include translations.
*
* @var bool
*/
protected $includeTranslations;
/**
* The migration field discovery service.
*
* @var \Drupal\migrate_drupal\FieldDiscoveryInterface
*/
protected $fieldDiscovery;
/**
* D7NodeDeriver constructor.
*
* @param string $base_plugin_id
* The base plugin ID for the plugin ID.
* @param bool $translations
* Whether or not to include translations.
* @param \Drupal\migrate_drupal\FieldDiscoveryInterface $field_discovery
* The migration field discovery service.
*/
public function __construct($base_plugin_id, $translations, FieldDiscoveryInterface $field_discovery) {
$this->basePluginId = $base_plugin_id;
$this->includeTranslations = $translations;
$this->fieldDiscovery = $field_discovery;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
// Translations don't make sense unless we have content_translation.
return new static($base_plugin_id, $container
->get('module_handler')
->moduleExists('content_translation'), $container
->get('migrate_drupal.field_discovery'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
if (in_array('translation', $base_plugin_definition['migration_tags']) && !$this->includeTranslations) {
// Refuse to generate anything.
return $this->derivatives;
}
$types = static::getSourcePlugin('d7_fieldable_panels_pane_type');
try {
$types
->checkRequirements();
} catch (RequirementsException $e) {
// If the d7_node_type requirements failed, that means we do not have a
// Drupal source database configured - there is nothing to generate.
return $this->derivatives;
}
try {
foreach ($types as $row) {
$bundle = $row
->getSourceProperty('name');
$values = $base_plugin_definition;
$values['label'] = $this
->t('@label (@type)', [
'@label' => $values['label'],
'@type' => $row
->getSourceProperty('name'),
]);
$values['source']['bundle'] = $bundle;
$values['destination']['default_bundle'] = $bundle;
// If this migration is based on the d7_fieldable_panels_pane_revision
// migration or is for translations of fieldable panel panes, it should
// explicitly depend on the corresponding d7_fieldable_panels_pane
// variant.
if ($base_plugin_definition['id'] == [
'd7_fieldable_panels_pane_revision',
] || in_array('translation', $base_plugin_definition['migration_tags'])) {
$values['migration_dependencies']['required'][] = 'd7_fieldable_panels_pane:' . $bundle;
}
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
$migration = \Drupal::service('plugin.manager.migration')
->createStubMigration($values);
$this->fieldDiscovery
->addBundleFieldProcesses($migration, 'fieldable_panels_pane', $bundle);
$this->derivatives[$bundle] = $migration
->getPluginDefinition();
}
} catch (DatabaseExceptionWrapper $e) {
// Once we begin iterating the source plugin it is possible that the
// source tables will not exist. This can happen when the
// MigrationPluginManager gathers up the migration definitions but we do
// not actually have a Drupal 7 source database.
}
return $this->derivatives;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
D7FieldablePanelsPaneDeriver:: |
protected | property | The base plugin ID this derivative is for. | |
D7FieldablePanelsPaneDeriver:: |
protected | property | The migration field discovery service. | |
D7FieldablePanelsPaneDeriver:: |
protected | property | Whether or not to include translations. | |
D7FieldablePanelsPaneDeriver:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
D7FieldablePanelsPaneDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
D7FieldablePanelsPaneDeriver:: |
public | function | D7NodeDeriver constructor. | |
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
MigrationDeriverTrait:: |
public static | function | Returns a fully initialized instance of a source plugin. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |