本文整理汇总了PHP中Drupal\migrate\Entity\Migration::getSourcePlugin方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::getSourcePlugin方法的具体用法?PHP Migration::getSourcePlugin怎么用?PHP Migration::getSourcePlugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\migrate\Entity\Migration
的用法示例。
在下文中一共展示了Migration::getSourcePlugin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSource
/**
* Get the source plugin to test.
*
* @param array $configuration
* The source configuration.
* @param array $migrate_config
* The migration configuration to be used in parent::getMigration().
* @param int $status
* The default status for the new rows to be imported.
*
* @return \Drupal\migrate\Plugin\MigrateSourceInterface
* A mocked source plugin.
*/
protected function getSource($configuration = [], $migrate_config = [], $status = MigrateIdMapInterface::STATUS_NEEDS_UPDATE)
{
$this->migrationConfiguration = $this->defaultMigrationConfiguration + $migrate_config;
$this->migration = parent::getMigration();
$this->executable = $this->getMigrateExecutable($this->migration);
// Update the idMap for Source so the default is that the row has already
// been imported. This allows us to use the highwater mark to decide on the
// outcome of whether we choose to import the row.
$id_map_array = ['original_hash' => '', 'hash' => '', 'source_row_status' => $status];
$this->idMap->expects($this->any())->method('getRowBySource')->willReturn($id_map_array);
$constructor_args = [$configuration, 'd6_action', [], $this->migration];
$methods = ['getModuleHandler', 'fields', 'getIds', '__toString', 'getIterator', 'prepareRow', 'initializeIterator', 'calculateDependencies'];
$source_plugin = $this->getMock('\\Drupal\\migrate\\Plugin\\migrate\\source\\SourcePluginBase', $methods, $constructor_args);
$source_plugin->expects($this->any())->method('fields')->willReturn([]);
$source_plugin->expects($this->any())->method('getIds')->willReturn([]);
$source_plugin->expects($this->any())->method('__toString')->willReturn('');
$source_plugin->expects($this->any())->method('prepareRow')->willReturn(empty($migrate_config['prepare_row_false']));
$source_plugin->expects($this->any())->method('initializeIterator')->willReturn([]);
$iterator = new \ArrayIterator([$this->row]);
$source_plugin->expects($this->any())->method('getIterator')->willReturn($iterator);
$module_handler = $this->getMock('\\Drupal\\Core\\Extension\\ModuleHandlerInterface');
$source_plugin->expects($this->any())->method('getModuleHandler')->willReturn($module_handler);
$this->migration->expects($this->any())->method('getSourcePlugin')->willReturn($source_plugin);
return $this->migration->getSourcePlugin();
}
示例2: getSource
/**
* Returns the source.
*
* Makes sure source is initialized based on migration settings.
*
* @return \Drupal\migrate\Plugin\MigrateSourceInterface
* The source.
*/
protected function getSource()
{
if (!isset($this->source)) {
$this->source = $this->migration->getSourcePlugin();
}
return $this->source;
}
示例3: getSource
/**
* Returns the source.
*
* Makes sure source is initialized based on migration settings.
*
* @return \Drupal\migrate\Plugin\MigrateSourceInterface
* The source.
*/
protected function getSource()
{
if (!isset($this->source)) {
$this->source = $this->migration->getSourcePlugin();
// @TODO, find out how to remove this.
// @see https://www.drupal.org/node/2443617
$this->source->migrateExecutable = $this;
}
return $this->source;
}