You are here

public function SourcePluginBase::__construct in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php \Drupal\migrate\Plugin\migrate\source\SourcePluginBase::__construct()

Constructs a \Drupal\Component\Plugin\PluginBase object.

Parameters

array $configuration: A configuration array containing information about the plugin instance.

string $plugin_id: The plugin_id for the plugin instance.

mixed $plugin_definition: The plugin implementation definition.

Overrides PluginBase::__construct

4 calls to SourcePluginBase::__construct()
ContentEntity::__construct in core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php
Constructs a \Drupal\Component\Plugin\PluginBase object.
EmbeddedDataSource::__construct in core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php
Constructs a \Drupal\Component\Plugin\PluginBase object.
EmptySource::__construct in core/modules/migrate_drupal/src/Plugin/migrate/source/EmptySource.php
Constructs a \Drupal\Component\Plugin\PluginBase object.
SqlBase::__construct in core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
Constructs a \Drupal\Component\Plugin\PluginBase object.
4 methods override SourcePluginBase::__construct()
ContentEntity::__construct in core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php
Constructs a \Drupal\Component\Plugin\PluginBase object.
EmbeddedDataSource::__construct in core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php
Constructs a \Drupal\Component\Plugin\PluginBase object.
EmptySource::__construct in core/modules/migrate_drupal/src/Plugin/migrate/source/EmptySource.php
Constructs a \Drupal\Component\Plugin\PluginBase object.
SqlBase::__construct in core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
Constructs a \Drupal\Component\Plugin\PluginBase object.

File

core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php, line 192

Class

SourcePluginBase
The base class for source plugins.

Namespace

Drupal\migrate\Plugin\migrate\source

Code

public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration) {
  parent::__construct($configuration, $plugin_id, $plugin_definition);
  $this->migration = $migration;

  // Set up some defaults based on the source configuration.
  foreach ([
    'cacheCounts' => 'cache_counts',
    'skipCount' => 'skip_count',
    'trackChanges' => 'track_changes',
  ] as $property => $config_key) {
    if (isset($configuration[$config_key])) {
      $this->{$property} = (bool) $configuration[$config_key];
    }
  }
  $this->cacheKey = !empty($configuration['cache_key']) ? $configuration['cache_key'] : NULL;
  $this->idMap = $this->migration
    ->getIdMap();
  $this->highWaterProperty = !empty($configuration['high_water_property']) ? $configuration['high_water_property'] : FALSE;

  // Pull out the current highwater mark if we have a highwater property.
  if ($this->highWaterProperty) {
    $this->originalHighWater = $this
      ->getHighWater();
  }

  // Don't allow the use of both highwater and track changes together.
  if ($this->highWaterProperty && $this->trackChanges) {
    throw new MigrateException('You should either use a highwater mark or track changes not both. They are both designed to solve the same problem');
  }
}