While working on flag import/export #335453: Import/Export Support I have problem:

Flag's definition are in two tables. The first is {flags} and the other is {flag_types}. I'd like features module to be able to export the flag object properly. Is there a way in CTools to do it? Or should it be some custom code in features?

CommentFileSizeAuthor
#3 ctools-export-additions-1.patch831 bytesamitaibu

Comments

sdboyer’s picture

As far as I'm aware, export.inc doesn't support objects that are constituted across multiple tables; atm, it's very tied to the idea of defining objects per-table. I could see a route whereby we define a primary table and then have secondary join tables that get built off of it - panels displays/panes would be a good example of where this could be useful - but we don't have that support right now. But it's something I'd like to see support for.

Unless I'm missing something, merlin?

merlinofchaos’s picture

Status: Active » Closed (won't fix)

Export can't do exports from multiple tables automatically, but the use of its hooks allows more complicated objects to figure out how to do it. This is how panel displays export (they use panels_display and panels_pane) tables. It takes more work but it is doable.

There is a pending @todo item for subrecords but I've never felt the need to act on it. This might qualify as that, but the complexities of subrecords are such that I'm not keen on tackling it without some very solid use cases to try it with.

amitaibu’s picture

Status: Closed (won't fix) » Needs review
StatusFileSize
new831 bytes

Maybe we can let other modules add additions? So in the case of flag, the code will be:

/**
 * Implementation of hook_ctools_export_additions_alter().
 *
 * Add flag types to CTools export, as the they reside in a different table.
 */
function flag_ctools_export_additions_alter(&$additions, $object, $identifier) {
  if ($identifier == 'flag') {
    $flag = flag_get_flag($object->name);
    $additions['types'] = $flag->types;
  }
}
amitaibu’s picture

btw, changing your won't fix to needs review, is just so it will be visible in the issue queue, not trying to argue with you guys ;)

amitaibu’s picture

Title: Export from several tables » Allow modules to add additional data in ctools_export_object()

Better title. Maybe we should have a similar drupal_alter() in ctools_load_object() ?

amitaibu’s picture

Status: Needs review » Closed (won't fix)

As I understood from sdboyer via IRC this is not the correct way + As the flag import/ export patch no longer needs it => back to won't fix.