What Ties a Drupal Hook to a Particular Module?
In Drupal 7, every core module has an "api" file
$ ls modules/*/*.api.php
modules/aggregator/aggregator.api.php modules/openid/openid.api.php
modules/block/block.api.php modules/overlay/overlay.api.php
modules/comment/comment.api.php modules/path/path.api.php
modules/contextual/contextual.api.php modules/rdf/rdf.api.php
modules/dashboard/dashboard.api.php modules/search/search.api.php
modules/field/field.api.php modules/shortcut/shortcut.api.php
modules/field_ui/field_ui.api.php modules/simpletest/simpletest.api.php
modules/file/file.api.php modules/system/system.api.php
modules/filter/filter.api.php modules/system/theme.api.php
modules/help/help.api.php modules/taxonomy/taxonomy.api.php
modules/image/image.api.php modules/trigger/trigger.api.php
modules/locale/locale.api.php modules/update/update.api.php
modules/menu/menu.api.php modules/user/user.api.php
modules/node/node.api.php
Each of these files contains a function that's never (?) called, but documents the existence of a hook that other modules (including 3rd party) can implement.
File: modules/path/path.api.php
function hook_path_delete($path) {
db_delete('mytable')
->condition('pid', $path['pid'])
->execute();
}
My question: What ties a particular hook to a particular module? Why is the path_delete
hook included in the path.api.php
file? Why is the entity_view
hook included in the system.api.php
file? Is this just arbitrary, after the fact organization, or is there something in the Drupal system that ties a particular hook to a particular module? Or something else?