I have a custom feeds processor, which implements sourceForm() to provide options on how the file will be imported. Unfortunately, the options entered by the user on the import form do not end up in $this->source_config inside of the custom entitySave override.

What I have to do is call $source = feeds_source($this->id); and then I can reference the options under $source->config['MyCustomProcessor']['someoption']

I did this in D6 but this doesn't seem to be working in D7 unless I am doing something wrong. I would think $this->source_config would be populated, but it only contains the defaults that were in sourceDefaults(). So it does know that the processor options and defaults are there, but the user value isn't loaded.

It is however stored correctly in the {feeds_source} table.

class CustomProcessor extends FeedsProcessor {
...

  function sourceForm($source_config) {
    $form = array();

    $form['target'] = array(
      '#title' => 'Target ID',
      '#type' => 'textfield',
    );

    return $form;
  }
...
  protected function entitySave($entity) {
    // Filled
    $source = feeds_source($this->id);
    $source->config['CustomProcessor']['target'];

   // Empty
   $this->source_config['target']
 }
...
}

Comments

djdevin’s picture

Version: 7.x-2.0-alpha8 » 7.x-2.x-dev
twistor’s picture

Category: Bug report » Support request
Status: Active » Fixed

$this->source_config does not exist.

Source configuration is stored per-source. Processor configuration is stored in $this->config and is per-importer, not per source.

$source = feeds_source($this->id); is incorrect as well, since that will only get the configuration for the standalone form.

So, either you want to implement this as part of the importer configuration, or you can access source configuration like so:
$source_config = $source->getConfigFor($this);

djdevin’s picture

I was able to do it by loading the source and getting the configuration.

However in the processor $this->source_config *does* actually exist. It has all the keys defined in sourceForm(), but they are blank.


abstract class FeedsPlugin extends FeedsConfigurable implements FeedsSourceInterface {


  protected function __construct($id) {
    parent::__construct($id);
    $this->source_config = $this->sourceDefaults();
  }


twistor’s picture

Title: custom processor, $this->source_config not populated » Remove the population of $this->source_config from FeedsPlugin.
Category: Support request » Bug report
Status: Fixed » Active

Oy! Looks like you're right. I have no idea why that's there.

twistor’s picture

Status: Active » Needs review
StatusFileSize
new556 bytes

  • twistor committed 00a35fe on 7.x-2.x
    Issue #2248009 by twistor | djdevin: Fixed Remove the population of ->...
twistor’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.