Skip to content
Snippets Groups Projects
Commit c2190c91 authored by Chris Leppanen's avatar Chris Leppanen
Browse files

Issue #1001590 by tristanoneil, twistor, Bevan: Path alias mapping target.

parent 014c3053
No related branches found
No related tags found
No related merge requests found
...@@ -219,6 +219,17 @@ class FeedsNodeProcessor extends FeedsProcessor { ...@@ -219,6 +219,17 @@ class FeedsNodeProcessor extends FeedsProcessor {
$target_node->feeds['suppress_import'] = TRUE; $target_node->feeds['suppress_import'] = TRUE;
} }
break; break;
case 'path_alias':
$target_node->path = array();
// Check for existing aliases.
if (!empty($target_node->nid)) {
if ($path = path_load('node/' . $target_node->nid)) {
$target_node->path = $path;
}
}
$target_node->path['alias'] = $value;
break;
default: default:
parent::setTargetElement($source, $target_node, $target_element, $value); parent::setTargetElement($source, $target_node, $target_element, $value);
break; break;
...@@ -280,6 +291,13 @@ class FeedsNodeProcessor extends FeedsProcessor { ...@@ -280,6 +291,13 @@ class FeedsNodeProcessor extends FeedsProcessor {
); );
} }
// If path is enabled expose path alias.
if (module_exists('path')) {
$targets['path_alias'] = array(
'name' => t('Path alias'),
'description' => t('URL path alias of the node.'),
);
}
// If the target content type is a Feed node, expose its source field. // If the target content type is a Feed node, expose its source field.
if ($id = feeds_get_importer_id($this->config['content_type'])) { if ($id = feeds_get_importer_id($this->config['content_type'])) {
......
...@@ -174,6 +174,28 @@ class FeedsTermProcessor extends FeedsProcessor { ...@@ -174,6 +174,28 @@ class FeedsTermProcessor extends FeedsProcessor {
} }
} }
/**
* Override setTargetElement to operate on a target item that is a taxonomy term.
*/
public function setTargetElement(FeedsSource $source, $target_term, $target_element, $value) {
switch ($target_element) {
case 'path_alias':
$target_term->path = array();
// Check for existing aliases.
if (!empty($target_term->tid)) {
if ($path = path_load('taxonomy/term/' . $target_term->tid)) {
$target_term->path = $path;
}
}
$target_term->path['alias'] = $value;
break;
default:
parent::setTargetElement($source, $target_term, $target_element, $value);
break;
}
}
/** /**
* Return available mapping targets. * Return available mapping targets.
*/ */
...@@ -205,6 +227,15 @@ class FeedsTermProcessor extends FeedsProcessor { ...@@ -205,6 +227,15 @@ class FeedsTermProcessor extends FeedsProcessor {
'description' => t('Description of the taxonomy term.'), 'description' => t('Description of the taxonomy term.'),
), ),
); );
// If path is enabled expose path alias.
if (module_exists('path')) {
$targets['path_alias'] = array(
'name' => t('Path alias'),
'description' => t('URL path alias for the taxonomy term.'),
);
}
// Let implementers of hook_feeds_term_processor_targets() add their targets. // Let implementers of hook_feeds_term_processor_targets() add their targets.
try { try {
self::loadMappers(); self::loadMappers();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment