class MigrateSource

Same name in this branch
  1. 11.x core/modules/migrate/src/Annotation/MigrateSource.php \Drupal\migrate\Annotation\MigrateSource
Same name and namespace in other branches
  1. 9 core/modules/migrate/src/Annotation/MigrateSource.php \Drupal\migrate\Annotation\MigrateSource
  2. 8.9.x core/modules/migrate/src/Annotation/MigrateSource.php \Drupal\migrate\Annotation\MigrateSource
  3. 10 core/modules/migrate/src/Annotation/MigrateSource.php \Drupal\migrate\Annotation\MigrateSource

Defines a MigrateSource attribute.

Plugin Namespace: Plugin\migrate\source

For a working example, see \Drupal\migrate\Plugin\migrate\source\EmptySource

Attributes

#[\Attribute(\Attribute::TARGET_CLASS)]

Hierarchy

Expanded class hierarchy of MigrateSource

See also

\Drupal\migrate\Plugin\MigratePluginManager

\Drupal\migrate\Plugin\MigrateSourceInterface

\Drupal\migrate\Plugin\migrate\source\SourcePluginBase

\Drupal\migrate\Attribute\MigrateDestination

\Drupal\migrate\Attribute\MigrateProcess

Plugin API

Related topics

14 files declare their use of MigrateSource
CacheableEmbeddedDataSource.php in core/modules/migrate/tests/modules/migrate_cache_counts_test/src/Plugin/migrate/source/CacheableEmbeddedDataSource.php
ConfigEntity.php in core/modules/migrate/src/Plugin/migrate/source/ConfigEntity.php
ContentEntity.php in core/modules/migrate/src/Plugin/migrate/source/ContentEntity.php
EmbeddedDataSource.php in core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php
EmptySource.php in core/modules/migrate/src/Plugin/migrate/source/EmptySource.php

... See full list

File

core/modules/migrate/src/Attribute/MigrateSource.php, line 26

Namespace

Drupal\migrate\Attribute
View source
class MigrateSource extends Plugin implements MultipleProviderAttributeInterface {
  
  /**
   * The providers of the source plugin.
   */
  protected array $providers = [];
  
  /**
   * Constructs a migrate source plugin attribute object.
   *
   * @param string $id
   *   A unique identifier for the source plugin.
   * @param bool $requirements_met
   *   (optional) Whether requirements are met. Defaults to true. The source
   *   plugin itself determines how the value is used. For example, Migrate
   *   Drupal's source plugins expect source_module to be the name of a module
   *   that must be installed and enabled in the source database.
   * @param mixed $minimum_version
   *   (optional) Specifies the minimum version of the source provider. This can
   *   be any type, and the source plugin itself determines how it is used. For
   *   example, Migrate Drupal's source plugins expect this to be an integer
   *   representing the minimum installed database schema version of the module
   *   specified by source_module.
   * @param class-string|null $deriver
   *   (optional) The deriver class.
   *
   * @see \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase::checkRequirements
   */
  public function __construct(public readonly string $id, public bool $requirements_met = TRUE, public readonly mixed $minimum_version = NULL, public readonly ?string $deriver = NULL) {
  }
  
  /**
   * {@inheritdoc}
   */
  public function setProvider(string $provider) : void {
    $this->setProviders([
      $provider,
    ]);
  }
  
  /**
   * {@inheritdoc}
   */
  public function getProviders() : array {
    return $this->providers;
  }
  
  /**
   * {@inheritdoc}
   */
  public function setProviders(array $providers) : void {
    if ($providers) {
      parent::setProvider(reset($providers));
    }
    else {
      $this->provider = NULL;
    }
    $this->providers = $providers;
  }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
AttributeBase::$class protected property The class used for this attribute class.
AttributeBase::$provider protected property The provider of the attribute class.
AttributeBase::get public function Gets the value of an attribute. Overrides AttributeInterface::get 7
AttributeBase::getClass public function Gets the class of the attribute class. Overrides AttributeInterface::getClass 1
AttributeBase::getId public function Gets the unique ID for this attribute class. Overrides AttributeInterface::getId
AttributeBase::getProvider public function Gets the name of the provider of the attribute class. Overrides AttributeInterface::getProvider
AttributeBase::setClass public function Sets the class of the attributed class. Overrides AttributeInterface::setClass 1
MigrateSource::$providers protected property The providers of the source plugin.
MigrateSource::getProviders public function Gets the provider names of the attribute class. Overrides MultipleProviderAttributeInterface::getProviders
MigrateSource::setProvider public function Sets the name of the provider of the attribute class. Overrides AttributeBase::setProvider
MigrateSource::setProviders public function Sets the provider names of the attribute class. Overrides MultipleProviderAttributeInterface::setProviders
MigrateSource::__construct public function Constructs a migrate source plugin attribute object. Overrides Plugin::__construct

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.