function path_feeds_set_target in Feeds 7.2
Same name and namespace in other branches
- 8.2 mappers/path.inc \path_feeds_set_target()
Callback for mapping path aliases.
1 string reference to 'path_feeds_set_target'
- path_feeds_processor_targets in mappers/
path.inc - Implements hook_feeds_processor_targets().
File
- mappers/
path.inc, line 34 - On behalf implementation of Feeds mapping API for path.module.
Code
function path_feeds_set_target(FeedsSource $source, $entity, $target, array $values, array $mapping) {
$alias = FALSE;
// Path alias cannot be multi-valued, so use the first non-empty value.
foreach ($values as $value) {
$value = ltrim(trim($value), '/');
if (strlen($value)) {
$alias = $value;
break;
}
}
$entity->path = array();
$entity_type = $source->importer->processor
->entityType();
list($id, , ) = entity_extract_ids($entity_type, $entity);
if ($id) {
$uri = entity_uri($entity_type, $entity);
// Check for existing aliases.
if ($path = path_load($uri['path'])) {
$entity->path = $path;
}
}
// Allow pathauto to set the path alias if the option is set, and the value is
// empty.
$entity->path['pathauto'] = !empty($mapping['pathauto_override']) && $alias === FALSE;
$entity->path['alias'] = (string) $alias;
}