Skip to content
Snippets Groups Projects
Commit dd9ef226 authored by Alex Barth's avatar Alex Barth
Browse files

Consolidate loadMappers() after latest commit. Update comments.

parent eba294d4
No related branches found
No related tags found
No related merge requests found
......@@ -294,26 +294,6 @@ class FeedsNodeProcessor extends FeedsProcessor {
return 0;
}
/**
* Loads on-behalf implementations from mappers/
*/
protected static function loadMappers() {
static $loaded = FALSE;
if (!$loaded) {
$path = drupal_get_path('module', 'feeds') .'/mappers';
$files = drupal_system_listing('.*\.inc$', $path, 'name', 0);
foreach ($files as $file) {
if (strstr($file->filename, '/mappers/')) {
require_once("./$file->filename");
}
}
// Rebuild cache.
module_implements('', FALSE, TRUE);
}
$loaded = TRUE;
}
/**
* Create MD5 hash of $item array.
* @return Always returns a hash, even with empty, NULL, FALSE:
......
......@@ -62,10 +62,12 @@ abstract class FeedsProcessor extends FeedsPlugin {
}
/**
* Execute mapping on an item. This method encapsulates the central mapping
* functionality. When an item is processed, it is passed through map() where
* the properties of $source_item are mapped onto $target_item following
* the processor's mapping configuration.
* Execute mapping on an item.
*
* This method encapsulates the central mapping functionality. When an item is
* processed, it is passed through map() where the properties of $source_item
* are mapped onto $target_item following the processor's mapping
* configuration.
*
* For each mapping FeedsParser::getSourceElement() is executed to retrieve
* the source element, then FeedsProcessor::setTargetElement() is invoked
......@@ -76,9 +78,10 @@ abstract class FeedsProcessor extends FeedsPlugin {
*
* @ingroup mappingapi
*
* @see hook_feeds_data_processor_targets_alter()
* @see hook_feeds_node_processor_targets_alter()
* @see hook_feeds_term_processor_targets_alter()
* @see hook_feeds_data_processor_targets_alter()
* @see hook_feeds_user_processor_targets_alter()
*/
protected function map($source_item, $target_item = NULL) {
......@@ -245,4 +248,29 @@ abstract class FeedsProcessor extends FeedsPlugin {
}
return $targets;
}
/**
* Loads on-behalf implementations from mappers/ directory.
*
* FeedsProcessor::map() does not load from mappers/ as only node and user
* processor ship with on-behalf implementations.
*
* @see FeedsNodeProcessor::map()
* @see FeedsUserProcessor::map()
*/
protected static function loadMappers() {
static $loaded = FALSE;
if (!$loaded) {
$path = drupal_get_path('module', 'feeds') .'/mappers';
$files = drupal_system_listing('.*\.inc$', $path, 'name', 0);
foreach ($files as $file) {
if (strstr($file->filename, '/mappers/')) {
require_once("./$file->filename");
}
}
// Rebuild cache.
module_implements('', FALSE, TRUE);
}
$loaded = TRUE;
}
}
......@@ -93,26 +93,6 @@ class FeedsUserProcessor extends FeedsProcessor {
throw new Exception(t('User processor does not support deleting users.'));
}
/**
* Loads on-behalf implementations from mappers/
*/
protected static function loadMappers() {
static $loaded = FALSE;
if (!$loaded) {
$path = drupal_get_path('module', 'feeds') .'/mappers';
$files = drupal_system_listing('.*\.inc$', $path, 'name', 0);
foreach ($files as $file) {
if (strstr($file->filename, '/mappers/')) {
require_once("./$file->filename");
}
}
// Rebuild cache.
module_implements('', FALSE, TRUE);
}
$loaded = TRUE;
}
/**
* Execute mapping on an item.
*/
......@@ -124,6 +104,7 @@ class FeedsUserProcessor extends FeedsProcessor {
$target_account->status = $this->config['status'];
// Have parent class do the iterating.
self::loadMappers();
return parent::map($source_item, $target_account);
}
......
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