You are here

protected function FeedsDataHandler::__construct in Feeds 6

Constructor, call indirectly through DataHandler::instance();

Overrides DataHandler::__construct

File

includes/FeedsDataHandler.inc, line 37
Data handler used in FeedsDataProcessor.

Class

FeedsDataHandler
Simple multidimensional data handler. Treats tables that join to this handler's table through FeedsDatahandler::key as a cluster. Records in this cluster are regarded as belonging to one multidimensional data set joined by FeedsDatahandler::key.

Code

protected function __construct($table, $key) {
  $this->table = $table;
  $this->key = $key;

  // Find tables joining to this table.
  // @todo DB cache.
  $this->joined_tables = array();
  $tables = data_get_all_tables();
  foreach ($tables as $join_table) {
    if ($join_table
      ->get('name') == $this->table) {

      // don't bother with joins on the same table...
      continue;
    }
    $meta = $join_table
      ->get('meta');
    if (isset($meta['join'][$this->table]) && $meta['join'][$this->table]['left_field'] == $this->key) {

      // table has a field that joins to this table on $this->key
      $this->joined_tables[$join_table
        ->get('name')] = $join_table
        ->get('name');
    }
  }
}