updated migration to add workflow state and also skipe notice pages, added favicon, improved admin views

This commit is contained in:
Bachir Soussi Chiadmi
2018-02-09 19:50:13 +01:00
parent 9990dbd604
commit 4dca28199c
104 changed files with 8539 additions and 345 deletions
@@ -156,15 +156,21 @@ process:
# workflow
# status:
# plugin: static_map
# source: workflow
# map:
# 1: 0
# 2: 0
# 3: 1
# 4: 1
status:
plugin: static_map
source: workflow
map:
1: 0
2: 0
3: 1
4: 1
plugin: default_value
default_value: 1
field_workflow:
plugin: default_value
default_value: "corpus_documents_publie"
destination:
@@ -54,15 +54,34 @@ process:
plugin: default_value
default_value: wysiwyg
# workflow
status:
plugin: default_value
default_value: 1
# status:
# plugin: static_map
# source: workflow
# map:
# 1: 0
# 2: 0
# 3: 1
# 4: 1
# workflow
# field_workflow_generic:
# plugin: default_value
# default_value: "generique_publie"
field_workflow_generic:
plugin: static_map
source: workflow
map:
1: 0
2: 0
3: 1
4: 1
1: "generique_masque"
2: "generique_masque"
3: "generique_publie"
4: "generique_publie"
field_date/value: date
field_date/end_value: date
@@ -1,5 +1,5 @@
id: d6_edlp_page
label: Edlp Drupal 6 page
id: d6_edlp_pages
label: Edlp Drupal 6 pages
migration_tags:
- Drupal 6
deriver: Drupal\node\Plugin\migrate\D6NodeDeriver
@@ -62,10 +62,20 @@ process:
# taxo term -> entity ref terms
# use this one for fetchCol in plugin
# field_page_type:
# plugin: migration_lookup
# migration: d6_edlp_pagetype
# source: page_type
field_page_type:
plugin: migration_lookup
migration: d6_edlp_pagetype
source: page_type
-
plugin: skip_on_empty
method: row
message: 'Page type is missing, skiping row'
source: page_type
-
plugin: migration_lookup
migration: d6_edlp_pagetype
# TODO: exclude pages of type notice (will be incorporated directly into the entree taxo term)
@@ -83,15 +93,32 @@ process:
migration: d6_edlp_allfiles
source: visuels_fid
# workflow
status:
plugin: default_value
default_value: 1
# status:
# plugin: static_map
# source: workflow
# map:
# 1: 0
# 2: 0
# 3: 1
# 4: 1
# workflow
# field_workflow_generic:
# plugin: default_value
# default_value: "generique_publie"
field_workflow_generic:
plugin: static_map
source: workflow
map:
1: 0
2: 0
3: 1
4: 1
1: "generique_masque"
2: "generique_masque"
3: "generique_publie"
4: "generique_publie"
# fichiers attachés ??
@@ -122,7 +122,7 @@ class D6EdlpCorpus extends D6Node {
// drush_print_r($row->getSourceProperty('field_article'));
$article_nid = $row->getSourceProperty('field_article')[0]['nid'];
if($article_nid){
drush_print($article_nid);
// drush_print($article_nid);
$query = $this->select('content_type_episode', 'ctp');
// // $query->fields('cte', ['field_entree_value']);
$query->condition('ctp.nid', $article_nid);
@@ -216,10 +216,10 @@ class D6EdlpCorpus extends D6Node {
$query->condition('wn.nid', $row_nid);
$results = $query->execute()->fetchField();
drush_print('workflow query results : ', 0, null, false);
drush_print_r($results);
// drush_print('workflow query results : ', 0, null, false);
// drush_print_r($results);
$row->setSourceProperty('workflow', $results);
// $row->setSourceProperty('workflow', $results);
$row = parent::prepareRow($row);
@@ -2,6 +2,7 @@
namespace Drupal\edlp_migrate\Plugin\migrate\source;
use Drupal\Core\Database\Database;
use Drupal\migrate\Row;
use Drupal\node\Plugin\migrate\source\d6\Node as D6Node;
@@ -144,9 +145,20 @@ class D6EdlpPages extends D6Node {
$results = $query->execute()->fetchAll();
$pagetype = [];
foreach ($results as $key => $value) {
$pagetype[] = array($value['tid']);
// avoid notice type (tid 8)
// row will be skiped if empty
if($value['tid'] !== "8"){
drush_print('page type : '.$value['tid']);
$pagetype[] = array($value['tid']);
}else{
drush_print('----- NOTICE -----');
}
}
$row->setSourceProperty('page_type', $pagetype);
drush_print('pagetype empty : '.empty($pagetype));
// if(count($pagetype) < 1){
// $pagetype = FALSE;
// }
$row->setSourceProperty('page_type', !empty($pagetype) ? $pagetype : 0);
// son
// TODO: pour les pieces sonores les fichiers ne sont pas enregistrés dans le champ car trop lourd. Ils sont sous forme de lien dans le corps du texte. Comment normaliser ça ??
@@ -158,21 +170,21 @@ class D6EdlpPages extends D6Node {
$body = $row->getSourceProperty('body');
preg_match_all('/href="(\/?sons\/[^"]+)"/', $body, $links);
if(isset($links[1][0])){
drush_print('links : ', 0, null, false);
drush_print_r($links);
// drush_print('links : ', 0, null, false);
// drush_print_r($links);
$path = preg_replace('/^\//', '', $links[1][0]);
// find the source path
$query = $this->select('url_alias', 'ua');
$query->condition('dst', $path);
$query->addField('ua', 'src');
$src = $query->execute()->fetchField();
drush_print('src : ', 0, null, false);
drush_print_r($src);
// drush_print('src : ', 0, null, false);
// drush_print_r($src);
if($src){
// get the nid
$nid = str_replace('node/', '', $src);
drush_print('nid : ', 0, null, false);
drush_print_r($nid);
// drush_print('nid : ', 0, null, false);
// drush_print_r($nid);
// find the new nid of the enregistrement (corpus item) from migration map
// get the d6_edlp_migration
// TODO: is this working for both corpus and sons elements ??
@@ -188,8 +200,8 @@ class D6EdlpPages extends D6Node {
$body = str_replace($path, "node/".$new_nid, $body);
}
}else{
drush_print('no source for path : ', 0, null, false);
drush_print_r($path);
// drush_print('no source for path : ', 0, null, false);
// drush_print_r($path);
}
}
$row->setSourceProperty('body', $body);