started custom migration module migrate_leshed
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies:
|
||||
- migrate_google_sheets
|
||||
- migrate_plus
|
||||
id: projet_node
|
||||
label: 'Import des projets depuis Google Sheets'
|
||||
migration_group: le_shed
|
||||
source:
|
||||
plugin: projet_node
|
||||
data_fetcher_plugin: http
|
||||
data_parser_plugin: google_sheets
|
||||
# The feed file for the spreadsheet. The Google Spreadsheet should be either “Public” or set to “Anyone with link can
|
||||
# view” in order for the feed to work.
|
||||
# Template: 'https://sheets.googleapis.com/v4/spreadsheets/<SHEET>/values/<TAB>?key=<KEY>'
|
||||
urls: 'https://sheets.googleapis.com/v4/spreadsheets/1561Gv1C-IlCTmg64Z8HnznvOeLbvwhA_k1l6aq95zFA/values/Projets?key=AIzaSyBOzRmGI0voXH7Ly8eva3PmphdzGuaNKsc'
|
||||
# Under 'fields', we list the data items to be imported. The first level keys
|
||||
# are the source field names we want to populate (the names to be used as
|
||||
# sources in the process configuration below). For each field we're importing,
|
||||
# we provide a label (optional - this is for display in migration tools) and
|
||||
# an selector (xpath) for retrieving that value. It's important to note that this xpath
|
||||
# is relative to the elements retrieved by item_selector.
|
||||
# For Google Spreadsheet XML feeds the actual columns are named with gsx: followed by the cleaned column name (lower,
|
||||
# limited punctuation, etc).destination:
|
||||
fields:
|
||||
-
|
||||
name: id
|
||||
label: 'Unique identifier'
|
||||
selector: 'UID'
|
||||
-
|
||||
name: title
|
||||
label: 'Title'
|
||||
selector: 'Nom du projet'
|
||||
-
|
||||
name: date_start
|
||||
label: 'Date start'
|
||||
selector: 'Date de début de projet'
|
||||
-
|
||||
name: date_end
|
||||
label: 'Date end'
|
||||
selector: 'Date de fin de projet'
|
||||
-
|
||||
name: projet_type
|
||||
label: 'Type de projet'
|
||||
selector: 'Type de projet'
|
||||
# Under 'ids', we identify source fields populated above which will uniquely
|
||||
# identify each imported item. The 'type' makes sure the migration map table
|
||||
# uses the proper schema type for stored the IDs.
|
||||
ids:
|
||||
id:
|
||||
type: integer
|
||||
process:
|
||||
type:
|
||||
plugin: default_value
|
||||
default_value: projet
|
||||
title: title
|
||||
field_dates/value:
|
||||
plugin: format_date
|
||||
source: date_start
|
||||
from_format: 'd/m/Y'
|
||||
to_format: 'Y-m-d'
|
||||
field_dates/end_value:
|
||||
plugin: format_date
|
||||
source: date_end
|
||||
from_format: 'd/m/Y'
|
||||
to_format: 'Y-m-d'
|
||||
field_type_de_projet:
|
||||
|
||||
uid:
|
||||
plugin: default_value
|
||||
default_value: 3
|
||||
migration_dependencies: { }
|
||||
|
||||
destination:
|
||||
plugin: entity:node
|
||||
@@ -0,0 +1,8 @@
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: le_shed
|
||||
label: 'Le shed'
|
||||
description: ''
|
||||
source_type: 'google doc sheets'
|
||||
module: null
|
||||
shared_configuration: null
|
||||
21
web/modules/custom/migrate_leshed/migrate_leshed.info.yml
Normal file
21
web/modules/custom/migrate_leshed/migrate_leshed.info.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
type: module
|
||||
name: Migrate Le Shed
|
||||
description: 'Importing contents from google sheet.'
|
||||
package: Migration
|
||||
core_version_requirement: '^10.5 || ^11'
|
||||
hidden: false
|
||||
dependencies:
|
||||
- migrate_plus:migrate_plus
|
||||
- migrate_tools:migrate_tools
|
||||
- migrate_google_sheets:migrate_google_sheets
|
||||
- drupal:image
|
||||
- drupal:text
|
||||
- drupal:options
|
||||
- drupal:taxonomy
|
||||
|
||||
# Information added by Drupal.org packaging script on 2026-01-23
|
||||
version: '0.0.1'
|
||||
project: 'leshed'
|
||||
|
||||
|
||||
# https://sheets.googleapis.com/v4/spreadsheets/1561Gv1C-IlCTmg64Z8HnznvOeLbvwhA_k1l6aq95zFA/values/Projets/?key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\migrate_leshed\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate\Attribute\MigrateSource;
|
||||
use Drupal\migrate_plus\Plugin\migrate\source\Url;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* @MigrateSource(
|
||||
* id = "projet_node"
|
||||
* )
|
||||
*/
|
||||
#[MigrateSource(id: 'projet_node')]
|
||||
final class ProjetNode extends Url {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields(): array {
|
||||
// theese are source fields
|
||||
return [
|
||||
'id' => $this->t('Project ID'),
|
||||
'title' => $this->t('Project Title'),
|
||||
'date_start' => $this->t('Project date start'),
|
||||
'date_end' => $this->t('Project date end')
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds(): array {
|
||||
return [
|
||||
'id' => [
|
||||
'type' => 'string',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
// $nid = $row->getSourceProperty('entity_id');
|
||||
// $vid = $row->getSourceProperty('revision_id');
|
||||
// $type = $row->getSourceProperty('type');
|
||||
// $language = $row->getSourceProperty('language');
|
||||
// $title = $row->getSourceProperty('title');
|
||||
// // drush_print('-- '.$nid."\t".$title."\t".$language);
|
||||
|
||||
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user