You are here

function hosting_package_sync in Hosting 5

Same name and namespace in other branches
  1. 6.2 package/hosting_package.module \hosting_package_sync()
  2. 7.4 package/hosting_package.module \hosting_package_sync()
  3. 7.3 package/hosting_package.module \hosting_package_sync()

Synch the package and package release nodes with the information retrieved from the verify task

@todo Make this prettier.

3 calls to hosting_package_sync()
hosting_platform_post_hosting_verify_task in platform/hosting_platform.drush.inc
Implementation hook_post_verify
hosting_site_post_hosting_install_task in site/hosting_site.drush.inc
implementation of the hosting_post_install hook
hosting_site_post_hosting_verify_task in site/hosting_site.drush.inc

File

package/hosting_package.module, line 288

Code

function hosting_package_sync(&$data) {
  foreach ($data as $plural => $packages) {
    $type = _hosting_package_plural_map($plural);
    foreach ($packages as $short_name => $file) {
      $name = $file['name'] ? $file['name'] : $short_name;
      if (!($package = hosting_get_package($short_name))) {

        // Create a new package.
        $package = new stdClass();
        $package->type = 'package';
        $package->title = $name;
        $package->package_type = $type;
        $package->short_name = $short_name;
        $package->description = $file['description'];

        // Kludge to hide the hostmaster and hostslave profiles
        if ($type == 'profile' && in_array($short_name, array(
          'hostslave',
          'hostmaster',
        ))) {
          $package->status = 0;
        }
        else {
          $package->status = 1;
        }
        node_save($package);
      }
      $data[$plural][$short_name]['package_id'] = $package->nid;
    }
  }
}