class RdfMapping

Same name in this branch
  1. 9 core/modules/rdf/src/Entity/RdfMapping.php \Drupal\rdf\Entity\RdfMapping
Same name and namespace in other branches
  1. 8.9.x core/modules/rdf/src/Entity/RdfMapping.php \Drupal\rdf\Entity\RdfMapping
  2. 8.9.x core/modules/rdf/src/Plugin/migrate/source/d7/RdfMapping.php \Drupal\rdf\Plugin\migrate\source\d7\RdfMapping

Drupal 7 rdf source from database.

For available configuration keys, refer to the parent classes.

Plugin annotation


@MigrateSource(
  id = "d7_rdf_mapping",
  source_module = "rdf"
)

Hierarchy

Expanded class hierarchy of RdfMapping

See also

\Drupal\migrate\Plugin\migrate\source\SqlBase

\Drupal\migrate\Plugin\migrate\source\SourcePluginBase

File

core/modules/rdf/src/Plugin/migrate/source/d7/RdfMapping.php, line 23

Namespace

Drupal\rdf\Plugin\migrate\source\d7
View source
class RdfMapping extends DrupalSqlBase {
  
  /**
   * {@inheritdoc}
   */
  public function query() {
    return $this->select('rdf_mapping', 'r')
      ->fields('r');
  }
  
  /**
   * {@inheritdoc}
   */
  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);
  }
  
  /**
   * {@inheritdoc}
   */
  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.'),
    ];
  }
  
  /**
   * {@inheritdoc}
   */
  public function getIds() {
    return [
      'type' => [
        'type' => 'string',
      ],
      'bundle' => [
        'type' => 'string',
      ],
    ];
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.