I have define the following in my module, as per the documentation. How ever the post install callback is never called -> sac_chapter_affiliation_app_post_install.

/**
 * Implements hook_apps_app_info().
 */
function sac_chapter_affiliation_apps_app_info() {
  return array('post install callback' => 'sac_chapter_affiliation_app_post_install');
}

/**
 * Helper function to run post app installation configuration.
 */
function sac_chapter_affiliation_app_post_install() {
  dsm('sac_chapter_affiliation_app_post_install');
  // We do this here and not in the install hook as when the install hook runs
  // the vocabulary sac_affiliation_types does not yet exist.
  $vocabulary_name = 'sac_affiliation_types';
  $vocabulary = taxonomy_vocabulary_machine_name_load($vocabulary_name);

  // Add default vocabulary term
  $term = new stdClass();
  $term->name = 'individual affiliations';
  $term->vid = $vocabulary->vid;
  $term->vocabulary_machine_name = $vocabulary->machine_name;
  $term->parent = array(0);
  taxonomy_term_save($term);

  // Add default vocabulary term
  $term = new stdClass();
  $term->name = 'corporate affiliations';
  $term->vid = $vocabulary->vid;
  $term->vocabulary_machine_name = $vocabulary->machine_name;
  $term->parent = array(0);
  taxonomy_term_save($term);
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lathan’s picture

Title: hook_apps_app_info never called. » hook_apps_app_info post install callback never called.

update title better description.

lathan’s picture

Here is a patch, not the callback on the disable was missing.

according to the API this should be called there as well. 'post install callback' => 'appname_app_post_install', // This will be called after the app is enabled intialy or of the app has been uninstalled

lathan’s picture

Status: Active » Needs review
FileSize
1.02 KB
lathan’s picture

Status: Needs review » Needs work

the call to the 'post install callback' is firing for the disable function however the enable it is still not i have looked up and found that the clear cache all usage before these callbacks are called should also change to use the system_rebuild_module_data() function.

lathan’s picture

Status: Needs work » Needs review
FileSize
1.99 KB

Right this now correctly gets the callback firing on module enable / disable.

lathan’s picture

Had the callback firing on the wrong hook, according to the api wording, also fixed white space. "// This will be called after the app is enabled intialy or of the app has been uninstalled"

lathan’s picture

We needed more hooks on the app enable / disable / uninstall process.

I have gone a head and added two new ones and documented them in the API as well.

mrfelton’s picture

Patch slightly updated for latest apps version.

hefox’s picture

+ // Else try load this module (happens when module is not enabled)
+ if (isset($app['machine_name']) && !empty($key)) {
+ module_load_include("module", $app['machine_name']);
+ $info = module_invoke($app['machine_name'], 'apps_app_info');
+ if (isset($info[$key]) && function_exists($info[$key])) {
+ return $info[$key];
+ }
+ }

(dreditor not working for me atm!)

So, I can't reproduce needing to recall apps_app_info -- the way it gets the info works fine for disabled apps.

hefox’s picture

Status: Needs review » Needs work
amuhebwa’s picture

I hadn't seen this issue, i shouldn't have replicated it. but here is the link with a patch https://www.drupal.org/node/2376519#comment-9370591

berdyshev’s picture

@hefox, @mrfelton, The app info is not loaded during distribution installation process because drupal is not fully bootstrapped. But, I think instead of this invocation of hook_apps_app_info() in apps_app_callback() it is better to do this when it should be done in apps_add_app_info(). See the issue #2753413: app_manifest() could not call hook_apps_app_info()