I have a project were we need to generate some content for our own module with custom database tables. This has been done so very many times before that I started to wonder if it would make more sense to extend devel generate with few hooks that would let module developers to extend content generation for their own data structures. I know that you can already do this easily if you are extending nodes, but in our case we have a very light weight custom data structure that is no using nodes at all.

What do you think about this idea? I don't think it's very easy to implement on top of devel generate. If we find a reasonable way to do it in 6.x version we might implement it and contribute it as a patch. Any ideas on how to do this are welcome.

Comments

moshe weitzman’s picture

Status: Active » Fixed

I think it is best if you should write own module for this. there is little code you can leverage in devel_generate. for example, votingapi module ships with code to generate votes.

vesapalmu’s picture

Ok... This was our original plan, but it sort of bugs me that there isn't more generic way of doing this. Thanks anyway, devel generate rocks. :-)

Status: Fixed » Closed (fixed)

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

naught101’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Closed (fixed) » Closed (won't fix)

Surely that's a won'tfix, not fixed.

Pity, I wonder if devel could be re-written to provide some kind of API for this stuff? Perhaps a hook like hook_entity_info that provides the data structure, and possible values that each component can accept. We're gonna need to do this for relation.module, and of course that's more complicated than most entities, as it relies on other entities, however I can imagine that this kind of request could become far more frequent with drupal's new entity system...

moshe weitzman’s picture

Category: support » feature
Status: Closed (won't fix) » Active

@naught101 - I'm open to patches for the entity system integration. Thats a little different from "modules that maintain custom tables.". This would be especially desireable once entity_save() is in core. I'm not too familiar with the Contrib Entity module but if most sites are using it, then that can play a role here.

naught101’s picture

Hey Moshe, thanks for the reply. I doubt I will have the time to work on patching devel_generate, and I think my case is more complicated than most, due to relation's entity's involving other entities (see #1167024: Add support for devel to generate relations). On the other hand, it obviously makes sense for me to make this as devel-friendly as possibly, so that if devel_generate+relation does seem doable later, we can hook into the core system.

Maybe something as simple as providing a hook that takes standard arguments to create content? Something like hook_devel_generate_content($number = 10, $bundles = array(), $kill = FALSE, ...), with perhaps a hook_devel_generate_info() or something that provides (form?) information for devel_generate's pages and drush generate functions?

moshe weitzman’s picture

Until we are saving via the Entity API module (patches welcome), custom entity modules are doing this on their own. See http://drupalcode.org/project/redirect.git and http://drupalcode.org/project/commerce_devel.git/tree/refs/heads/7.x-1.x...

bc’s picture

Issue summary: View changes

See https://www.drupal.org/project/devel_contrib and its devel_contrib_generate submodule -- it provides an extensible entity generator.

willzyx’s picture

Status: Active » Closed (outdated)

Closing for lack of activity. Feel free to reopen if the issue still exists