Commit 7a57fcec authored by Reena Raghavan's avatar Reena Raghavan

Source Plugin added

parent 987eb2fa
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "456538b7dab8bb60b93688c534ed34b7", "content-hash": "f26dfb2782bddb8f9bd1a658e1785794",
"packages": [ "packages": [
{ {
"name": "asm89/stack-cors", "name": "asm89/stack-cors",
...@@ -1557,6 +1557,142 @@ ...@@ -1557,6 +1557,142 @@
}, },
"time": "2022-10-06T15:57:08+00:00" "time": "2022-10-06T15:57:08+00:00"
}, },
{
"name": "drupal/migrate_plus",
"version": "6.0.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/migrate_plus.git",
"reference": "6.0.0"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/migrate_plus-6.0.0.zip",
"reference": "6.0.0",
"shasum": "cbdda92ef6c4d096a673ff391bc061e012433ecf"
},
"require": {
"drupal/core": ">=9.1",
"php": ">=7.4"
},
"require-dev": {
"drupal/migrate_example_advanced_setup": "*",
"drupal/migrate_example_setup": "*"
},
"suggest": {
"ext-soap": "*",
"sainsburys/guzzle-oauth2-plugin": "3.0 required for the OAuth2 authentication plugin"
},
"type": "drupal-module",
"extra": {
"drupal": {
"version": "6.0.0",
"datestamp": "1650983140",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0-or-later"
],
"authors": [
{
"name": "Mike Ryan",
"homepage": "https://www.drupal.org/u/mikeryan",
"role": "Maintainer"
},
{
"name": "Lucas Hedding",
"homepage": "https://www.drupal.org/u/heddn",
"role": "Maintainer"
},
{
"name": "mikeryan",
"homepage": "https://www.drupal.org/user/4420"
}
],
"description": "Enhancements to core migration support.",
"homepage": "https://www.drupal.org/project/migrate_plus",
"support": {
"source": "https://git.drupalcode.org/project/migrate_plus",
"issues": "https://www.drupal.org/project/issues/migrate_plus",
"slack": "#migrate"
}
},
{
"name": "drupal/migrate_tools",
"version": "6.0.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/migrate_tools.git",
"reference": "6.0.0"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/migrate_tools-6.0.0.zip",
"reference": "6.0.0",
"shasum": "bec5a0e4fbb6ec0face6780c2ab98ffe6096188b"
},
"require": {
"drupal/core": ">=9.1",
"php": ">=7.4"
},
"require-dev": {
"drupal/migrate_plus": ">=5",
"drupal/migrate_source_csv": ">=3",
"drush/drush": ">=11"
},
"suggest": {
"drupal/migrate_plus": ">=5",
"drush/drush": ">=11"
},
"type": "drupal-module",
"extra": {
"drupal": {
"version": "6.0.0",
"datestamp": "1651240616",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
},
"drush": {
"services": {
"drush.services.yml": ">=9"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0-or-later"
],
"authors": [
{
"name": "Mike Ryan",
"homepage": "https://www.drupal.org/u/mikeryan",
"role": "Maintainer"
},
{
"name": "Lucas Hedding",
"homepage": "https://www.drupal.org/u/heddn",
"role": "Maintainer"
},
{
"name": "mikeryan",
"homepage": "https://www.drupal.org/user/4420"
}
],
"description": "Tools to assist in developing and running migrations.",
"homepage": "http://drupal.org/project/migrate_tools",
"support": {
"source": "https://git.drupalcode.org/project/migrate_tools",
"issues": "https://www.drupal.org/project/issues/migrate_tools",
"slack": "#migrate"
}
},
{ {
"name": "drush/drush", "name": "drush/drush",
"version": "11.3.2", "version": "11.3.2",
......
id: article
label: Migrate Article
migration_group: my_custom_migrate
source:
plugin: article
key: migrate
destination:
plugin: entity:node
process:
nid: nid
title: title
body: body
field_publish_date: field_publish_date
migration_dependencies:
required: {}
dependencies: {}
\ No newline at end of file
<?php
/**
* @file
* Migration src file for Article.
*
* This module migrates data of Article type.
*/
namespace Drupal\custom_migrate\Plugin\migrate\source;
use Drupal\migrate\Plugin\migrate\source\SqlBase;
use Drupal\migrate\Row;
/**
* Source plugin for the article.
*
* @MigrateSource(
* id = "article"
* )
*/
class Article extends SqlBase
{
/**
* {@inheritdoc}
*/
public function query()
{
$query = $this->select('custom_news', 'cn')
->fields('cn', ['nid','title','body','field_publish_date']);
return $query;
}
/**
* {@inheritdoc}
*/
public function fields()
{
$fields = [
'nid' => $this->t('nid'),
'title' => $this->t('title'),
'body' => $this->t('body'),
'field_publish_date' => $this->t('field_publish_date')
];
return $fields;
}
/**
* {@inheritdoc}
*/
public function getIds()
{
return [
'nid' => [
'type' => 'integer',
'alias' => 'cn',
],
];
}
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row)
{
$publish_date = $row->getSourceProperty('publish_date');
$new_date = date('Y-m-d\Th:i:s', strtotime($publish_date));
$row->setSourceProperty('publish_date', $new_date);
return parent::prepareRow($row);
}
}
...@@ -4,3 +4,6 @@ description: 'UVF Module for importing contents from old site' ...@@ -4,3 +4,6 @@ description: 'UVF Module for importing contents from old site'
package: Custom package: Custom
version: 1.0 version: 1.0
core_version_requirement: ^8 || ^9 core_version_requirement: ^8 || ^9
dependencies:
- drupal:migrate
- migrate_plus:migrate_plus
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment