Hi,

In my installation profile (let's call it myprofile) I have a myprofile_install_tasks() defined and profiler is not working in this case.

Reading the code it looks like profiler is designed to define a new myprofile_install_tasks() which calls profiler_install_profile_complete() only when the former is not defined already.

I found a way to make my own myprofile_install_tasks() call profiler_install_profile_complete() with these changes:

diff --git a/myprofile.profile b/myprofile.profile
index aa164a4..e0fe0c8 100644
--- a/myprofile.profile
+++ b/myprofile.profile
@@ -13,17 +13,20 @@
 function myprofile_install_tasks($install_state) {
   // Determine whether translation import tasks will need to be performed.
   $needs_translations = !empty($install_state['parameters']['locale']) &&
     $install_state['parameters']['locale'] != 'en';

+  include_once('libraries/profiler/profiler_api.inc');
+
   return array(
     '_import_translation' => array(
       'display_name' => st('Set up translations'),
       'display' => $needs_translations,
       'run' => $needs_translations ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP,
       'type' => 'batch',
     ),
+    'profiler_install_profile_complete' => array(),
   );
 }

Is this the right way to do that? And if so, is it worth documenting it?

Thanks,
Antonio

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

q0rban’s picture

Yep, that looks right to me. It might be worth documenting it, although I'd rather not murk up README.txt with it. Hmm..

ao2’s picture

Maybe a line in the REAME mentioning hook_install_tasks() and which refers to this issue?
See the attached patch.

Thanks,
Antonio

mattyohe’s picture

I would also recommend including a url or a note referencing this issue as I too am defining my own task for my profile and arrived at the same solution.

q0rban’s picture

Status: Active » Needs work

I'm okay with the README patch, but can you please reference the issue with a footnote that contains the URL? e.g.

Please see Integrate with profiles which define their hook_install_tasks[1].

[1] http://drupal.org/node/1203786

ashooner’s picture

I was having problems getting this to work, and I found this further example, which resolved them:

https://bitbucket.org/samheuck/drupal7_distro_starterkit/src/edddfbc4eee...

Specifically, this implements hook_install_tasks before including Profiler and calling profiler_v2().

rbruhn’s picture

@ashooner - Thanks for posting that link. Helped me out after getting errors about re-declaring myprofile_install_tasks().
As well, I used Profiler Builder so the profiler_v2() call was in the .install file. I moved it into the .profile like the blog post and things are working well.

TheBarnacle’s picture

The link at #5 seems to be broken?

But the initial suggestion works wonderfully! Thanks for sharing!

ashooner’s picture

I don't recall exactly what was on that bitbucket page, but here is the beginning of my .profile file, which I wrote based on it (my profile is based on Panopoly):

/**
 * Implements hook_install_tasks()
 */
function PROFILENAME_install_tasks(&$install_state) {

  // Include Profiler API
   include_once('libraries/profiler/profiler_api.inc');

  // Start it off
  $tasks = array();

  //Include Libraries API
  require_once(drupal_get_path('module', 'libraries') . '/libraries.module');

    // Add our custom CSS file for the installation process
  drupal_add_css(drupal_get_path('profile', 'PROFILENAME') . '/panopoly.css');

  //Run Profiler tasks first
  $tasks['profiler_install_profile_complete'] = array();

  // Add the Panopoly app selection to the installation process
  require_once(drupal_get_path('module', 'apps') . '/apps.profile.inc');
  $tasks = $tasks + apps_profile_install_tasks($install_state, array('machine name' => 'panopoly', 'default apps' => array('')));

  // Add the Panopoly theme selection to the installation process
  require_once(drupal_get_path('module', 'panopoly_theme') . '/panopoly_theme.profile.inc');
  $tasks = $tasks + panopoly_theme_profile_theme_selection_install_task($install_state);

  return $tasks;
}

//Include Profiler
!function_exists('profiler_v2') ? require_once('libraries/profiler/profiler.inc') : FALSE;
profiler_v2('PROFILENAME');

//hook_install_tasks_alter & etc follow....

ao2’s picture

Status: Needs work » Closed (outdated)

Closing as outdated to clean up my issue queue, feel free to reopen if you still need this.