Drupal 8迁移插件-需要解释
我想将数据从自定义表迁移到图书内容类型,但我不知道如何实现这一点。 这是我的config\install\migrate.migration.book\u content.yml文件:Drupal 8迁移插件-需要解释,drupal,drupal-modules,drupal-8,Drupal,Drupal Modules,Drupal 8,我想将数据从自定义表迁移到图书内容类型,但我不知道如何实现这一点。 这是我的config\install\migrate.migration.book\u content.yml文件: id: book_content label: Book content migration_group: example source: plugin: book_content target: db_migration destination: plugin: entity:node proces
id: book_content
label: Book content
migration_group: example
source:
plugin: book_content
target: db_migration
destination:
plugin: entity:node
process:
type:
plugin: default_value
default_value: article
title: title
uid:
plugin: default_value
default_value: 1
sticky:
plugin: default_value
default_value: 0
status:
plugin: default_value
default_value: 1
'body/value': content
'body/summary': excerpt
'body/format':
plugin: default_value
default_value: full_html
# Use of the migration process plugin.
# That will use the id map of the specified migration
# to retrieve the corresponding id ('source' parameter) in the destination database.
field_description:
plugin: migration
source: body
src\Plugin\migrate\source\BookContent.php
<?php
/**
* @file
* Contains \Drupal\docapi_migrate\Plugin\migrate\source\BookContent.
*/
namespace Drupal\example_migrate\Plugin\migrate\source;
use Drupal\migrate\Plugin\migrate\source\SqlBase;
use Drupal\migrate\Row;
/**
* Drupal 8 node from database.
*
* @MigrateSource(
* id = "book_content"
* )
*/
class BookContent extends SqlBase {
/**
* {@inheritdoc}
*/
public function query() {
$query = $this->select('docapi_migrate', 'dm')
->fields('dm', array('url', 'depth', 'body', 'meta'));
return $query;
}
/**
* {@inheritdoc}
*/
public function fields() {
$fields = array(
'url' => $this->t('Content url'),
'depth' => $this->t('Depth of the content'),
'body' => $this->t('Full text of the content'),
'meta' => $this->t('yaml data'),
);
return $fields;
}
我得到:
The drush command 'migrate-import book_content' could not be found.
我不明白BookContent.php中的函数是如何工作的。
应该有带有is taxonomy reference的tags_字段,但是我不知道我应该在哪里处理meta,所以例如,我得到了一个标签列表。
当我有标签时,我应该如何组合它,以便迁移工作。
我通过谷歌搜索信息,但没有什么真正有意义的。我如何理解这一点?您的命名空间设置为
示例\u migrate
。它需要设置为模块的名称,因此除非模块名为“example\u migrate”,否则无法找到该类
更改名称空间以匹配您的\u模块\u名称
namespace Drupal\YOUR_MODULE_NAME\Plugin\migrate\source;
有关名称空间的更多信息可以在谷歌搜索时找到
namespace Drupal\YOUR_MODULE_NAME\Plugin\migrate\source;