public function RelationFeedsProcessor::getMappingTargets in Relation 7
File
- relation_feeds/
RelationFeedsProcessor.inc, line 279 - Class definition of RelationFeedsProcessor.
Class
- RelationFeedsProcessor
- Creates relations from feed items.
Code
public function getMappingTargets() {
$targets = parent::getMappingTargets();
$targets['rid'] = array(
'name' => t('Relation ID'),
'description' => t('The rid of the relation. NOTE: use this feature with care, relation ids are usually assigned by Drupal.'),
'optional_unique' => TRUE,
);
$targets['uid'] = array(
'name' => t('User ID'),
'description' => t('The Drupal user ID of the relation author.'),
);
$targets['created'] = array(
'name' => t('Published date'),
'description' => t('The UNIX time when a relation has been published.'),
);
$type = $this
->getTypeInfo();
if ($type->directional) {
$endpoint_types = array(
'source_bundles' => t('Source'),
'target_bundles' => t('Target'),
);
}
else {
$endpoint_types = array(
'source_bundles' => t('Endpoint'),
);
}
foreach ($endpoint_types as $endpoint_type => $endpoint_label) {
foreach ($type->{$endpoint_type} as $endpoint) {
$endpoint = explode(':', $endpoint);
$entity = entity_get_info($endpoint[0]);
$bundle_label = $endpoint[1] == '*' ? t('any type') : $entity['bundles'][$endpoint[1]]['label'];
$targets[$endpoint_type . ':' . $endpoint[0] . ':' . $endpoint[1] . ':guid'] = array(
'name' => t('@type @entity of @bundle: Feeds GUID', array(
'@type' => $endpoint_label,
'@entity' => $entity['label'],
'@bundle' => $bundle_label,
)),
'description' => t('The GUID of the entity if it was already imported via feeds.'),
);
$targets[$endpoint_type . ':' . $endpoint[0] . ':' . $endpoint[1] . ':entity_id'] = array(
'name' => t('@type @entity of @bundle: Entity ID', array(
'@type' => $endpoint_label,
'@entity' => $entity['label'],
'@bundle' => $bundle_label,
)),
'description' => t('The ID of the entity as it exists in Drupal.'),
);
}
}
// If the target content type is a Feed relation, expose its source field.
if ($id = feeds_get_importer_id($this->config['bundle'])) {
$name = feeds_importer($id)->config['name'];
$targets['feeds_source'] = array(
'name' => t('Feed source'),
'description' => t('The content type created by this processor is a Feed relation, it represents a source itself. Depending on the fetcher selected on the importer "@importer", this field is expected to be for example a URL or a path to a file.', array(
'@importer' => $name,
)),
'optional_unique' => TRUE,
);
}
// Let other modules expose mapping targets.
self::loadMappers();
$entity_type = $this
->entityType();
$bundle = $this
->bundle();
drupal_alter('feeds_processor_targets', $targets, $entity_type, $bundle);
return $targets;
}