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
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.
-
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_mcCommented Oct 11, 2013 at 13:10