-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#29 Taxonomy support and improved tests
- Loading branch information
1 parent
392a16a
commit 3da4bc3
Showing
4 changed files
with
256 additions
and
44 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
modules/integration_migrate/src/Plugin/migrate/process/TagToId.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Drupal\integration_migrate\Plugin\migrate\process; | ||
|
||
use Drupal\migrate\MigrateExecutableInterface; | ||
use Drupal\migrate\ProcessPluginBase; | ||
use Drupal\migrate\Row; | ||
|
||
/** | ||
* This plugin generates entities within the process plugin. | ||
* | ||
* @MigrateProcessPlugin( | ||
* id = "tag_to_id" | ||
* ) | ||
* | ||
* @Todo: Normally we should use EntityLookup for this.. | ||
*/ | ||
class TagToId extends ProcessPluginBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { | ||
if ($terms = taxonomy_term_load_multiple_by_name($value)) { | ||
/** @var \Drupal\taxonomy\Entity\Term $term */ | ||
$term = reset($terms); | ||
return $term->id(); | ||
} | ||
return NULL; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
modules/integration_migrate/tests/modules/integration_migrate_entity/data/10931.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"_id": "10931", | ||
"default_language": "en", | ||
"languages": [ | ||
"en" | ||
], | ||
"fields": { | ||
"title": { | ||
"en": [ | ||
"Test simple document title" | ||
] | ||
}, | ||
"tags": { | ||
"en": [ | ||
"Tag 1", | ||
"Tag 2" | ||
] | ||
}, | ||
"multi_data": { | ||
"en": [ | ||
"List item 1", | ||
"List item 2" | ||
] | ||
} | ||
}, | ||
"type": "integration_document_entity_test", | ||
"created": "1235583913", | ||
"changed": "1329926433", | ||
"status": "0", | ||
"sticky": "0" | ||
} |
Oops, something went wrong.