2

What would be 'the best' hook function to use in the custom module installation to import entity data? This is supposed to be a one-time activity during the module installation only, after entity schema is built in the database and entities are initialized (to be able to use Entity API in the data import).

2 Answers 2

1

For one time import of data, when installing a module, use hook_install. This can be used to populate the database just after tables are created, provided your module also implements hook_schema.

You do not want to use hook_enable. If you used this, the database would be re-populated every time the module was re-enabled after being temporary disabled.

1
  • Thank you, hook_install definitely looks more proper, and it seems to run after custom modules are loaded as well, so can use definitions of custom entities with Entity API.
    – al_mc
    Commented Oct 11, 2013 at 13:10
0

... just found, could be hook_enable() if I'm not mistaken about its usage

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.