RdfMapping.php in Drupal 10
File
core/modules/rdf/src/Plugin/migrate/source/d7/RdfMapping.php
View source
<?php
namespace Drupal\rdf\Plugin\migrate\source\d7;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
class RdfMapping extends DrupalSqlBase {
public function query() {
return $this
->select('rdf_mapping', 'r')
->fields('r');
}
public function prepareRow(Row $row) {
$field_mappings = [];
foreach (unserialize($row
->getSourceProperty('mapping')) as $field => $mapping) {
if ($field === 'rdftype') {
$row
->setSourceProperty('types', $mapping);
}
else {
$field_mappings[$field] = $mapping;
}
}
$row
->setSourceProperty('fieldMappings', $field_mappings);
return parent::prepareRow($row);
}
public function fields() {
return [
'type' => $this
->t('The name of the entity type a mapping applies to (node, user, comment, etc.)'),
'bundle' => $this
->t('The name of the bundle a mapping applies to.'),
'mapping' => $this
->t('The serialized mapping of the bundle type and fields to RDF terms.'),
'types' => $this
->t('RDF types.'),
'fieldMappings' => $this
->t('RDF field mappings.'),
];
}
public function getIds() {
return [
'type' => [
'type' => 'string',
],
'bundle' => [
'type' => 'string',
],
];
}
}