|
@@ -95,6 +95,11 @@ class D6EdlpCorpus extends D6Node {
|
|
|
* {@inheritdoc}
|
|
|
*/
|
|
|
public function prepareRow(Row $row) {
|
|
|
+ drush_print(' ');
|
|
|
+ drush_print('- - - - - - - - - - - - - - - - - - - - - - - -');
|
|
|
+ drush_print($row->getSourceProperty('title'));
|
|
|
+
|
|
|
+
|
|
|
// format = 0 can happen when the body field is hidden. Set the format to 1
|
|
|
// to avoid migration map issues (since the body field isn't used anyway).
|
|
|
if ($row->getSourceProperty('format') === '0') {
|
|
@@ -104,17 +109,119 @@ class D6EdlpCorpus extends D6Node {
|
|
|
if ($this->moduleExists('content') && $this->getModuleSchemaVersion('content') >= 6001) {
|
|
|
foreach ($this->getFieldValues($row) as $field => $values) {
|
|
|
$row->setSourceProperty($field, $values);
|
|
|
- // \Drupal::logger('edlp_migrate')->debug(print_r($values));
|
|
|
- // print_r($field);
|
|
|
- // print_r("\n");
|
|
|
- // print_r($values);
|
|
|
}
|
|
|
}
|
|
|
+ $row_nid = $row->getSourceProperty('nid');
|
|
|
+
|
|
|
|
|
|
// Make sure we always have a translation set.
|
|
|
if ($row->getSourceProperty('tnid') == 0) {
|
|
|
- $row->setSourceProperty('tnid', $row->getSourceProperty('nid'));
|
|
|
+ $row->setSourceProperty('tnid', $row_nid);
|
|
|
+ }
|
|
|
+ // get the article content
|
|
|
+ // drush_print_r($row->getSourceProperty('field_article'));
|
|
|
+ $article_nid = $row->getSourceProperty('field_article')[0]['nid'];
|
|
|
+ if($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);
|
|
|
+ $query->join('node_revisions', 'nr', 'nr.vid = ctp.vid');
|
|
|
+ $query->addField('nr', 'body');
|
|
|
+ $article = $query->execute()
|
|
|
+ ->fetchField();
|
|
|
+ // drush_print_r($article);
|
|
|
+ $row->setSourceProperty('article', $article);
|
|
|
+ }
|
|
|
+
|
|
|
+ // get the entree values
|
|
|
+ $query = $this->select('term_node', 'tn');
|
|
|
+ // $query->fields('cte', ['field_entree_value']);
|
|
|
+ $query->condition('tn.nid', $row_nid);
|
|
|
+ $query->join('term_data', 'td', 'td.tid = tn.tid');
|
|
|
+ $query->condition('td.vid', 2); // vid of voc entrees
|
|
|
+ $query->addField('tn', 'tid');
|
|
|
+ $query->distinct();
|
|
|
+ $results = $query->execute()->fetchAll();
|
|
|
+
|
|
|
+ $entrees = [];
|
|
|
+ foreach ($results as $key => $value) {
|
|
|
+ $entrees[] = array($value['tid']);
|
|
|
+ }
|
|
|
+ $row->setSourceProperty('entrees', $entrees);
|
|
|
+
|
|
|
+ // Genres
|
|
|
+ $genres = [];
|
|
|
+ foreach ($row->getSourceProperty('field_genre') as $key => $value) {
|
|
|
+ $genres[] = array($value['value']);
|
|
|
+ }
|
|
|
+ $row->setSourceProperty('genres', $genres);
|
|
|
+
|
|
|
+ $langues = [];
|
|
|
+ foreach ($row->getSourceProperty('field_langue') as $key => $value) {
|
|
|
+ $langues[] = array($value['value']);
|
|
|
}
|
|
|
+ $row->setSourceProperty('langues', $langues);
|
|
|
+
|
|
|
+ // locuteurs
|
|
|
+ $locuteurs = [];
|
|
|
+ foreach ($row->getSourceProperty('field_artiste') as $key => $value) {
|
|
|
+ $term_name = $value['value'];
|
|
|
+ // check if term already exists in configured vocabulary
|
|
|
+ $term = array_shift(taxonomy_term_load_multiple_by_name($term_name, 'locuteurs'));
|
|
|
+ if(!$term){
|
|
|
+ // if not create the term and get the tid
|
|
|
+ $term = \Drupal\taxonomy\Entity\Term::create([
|
|
|
+ 'vid' => 'locuteurs',
|
|
|
+ 'name' => $term_name,
|
|
|
+ ]);
|
|
|
+ $term->save();
|
|
|
+ }
|
|
|
+ // record the tid in array
|
|
|
+ $locuteurs[] = $term->get('tid')->value;
|
|
|
+ }
|
|
|
+ $row->setSourceProperty('locuteurs', $locuteurs);
|
|
|
+
|
|
|
+ // collectionneurs
|
|
|
+ $collectionneurs = [];
|
|
|
+ foreach ($row->getSourceProperty('field_compositeur') as $key => $value) {
|
|
|
+ $term_name = $value['value'];
|
|
|
+ // check if term already exists in configured vocabulary
|
|
|
+ $term = array_shift(taxonomy_term_load_multiple_by_name($term_name, 'collectionneurs'));
|
|
|
+ if(!$term){
|
|
|
+ // if not create the term and get the tid
|
|
|
+ $term = \Drupal\taxonomy\Entity\Term::create([
|
|
|
+ 'vid' => 'collectionneurs',
|
|
|
+ 'name' => $term_name,
|
|
|
+ ]);
|
|
|
+ $term->save();
|
|
|
+ }
|
|
|
+ // record the tid in array
|
|
|
+ $collectionneurs[] = $term->get('tid')->value;
|
|
|
+ }
|
|
|
+ $row->setSourceProperty('collectionneurs', $collectionneurs);
|
|
|
+
|
|
|
+ // son
|
|
|
+ // drush_print('field_mp3 : ', 0, null, false);
|
|
|
+ // drush_print_r($row->getSourceProperty('field_mp3'));
|
|
|
+ $sons = [];
|
|
|
+ foreach ($row->getSourceProperty('field_mp3') as $key => $value) {
|
|
|
+ $sons[] = array($value['fid']);
|
|
|
+ }
|
|
|
+ $row->setSourceProperty('sons_fid', $sons);
|
|
|
+
|
|
|
+ // TODO: get the workflow status
|
|
|
+ // get the entree values
|
|
|
+ $query = $this->select('workflow_node', 'wn');
|
|
|
+ $query->fields('wn', ['sid']);
|
|
|
+ $query->condition('wn.nid', $row_nid);
|
|
|
+ $results = $query->execute()->fetchField();
|
|
|
+
|
|
|
+ drush_print('workflow query results : ', 0, null, false);
|
|
|
+ drush_print_r($results);
|
|
|
+
|
|
|
+ $row->setSourceProperty('workflow', $results);
|
|
|
+
|
|
|
|
|
|
$row = parent::prepareRow($row);
|
|
|
return $row;
|