function hosting_package_sync in Hosting 7.4
Same name and namespace in other branches
- 5 package/hosting_package.module \hosting_package_sync()
- 6.2 package/hosting_package.module \hosting_package_sync()
- 7.3 package/hosting_package.module \hosting_package_sync()
Sync the package and package release nodes with the information retrieved from the verify task
@todo Make this prettier.
5 calls to hosting_package_sync()
- hosting_migrate_post_hosting_migrate_task in migrate/
hosting_migrate.drush.inc - @todo Please document this function.
- hosting_platform_post_hosting_verify_task in platform/
hosting_platform.drush.inc - Implements hook_post_hosting_TASK_TYPE_task().
- hosting_site_post_hosting_import_task in site/
hosting_site.drush.inc - Implements hook_post_hosting_import_task().
- hosting_site_post_hosting_install_task in site/
hosting_site.drush.inc - Implements hook_post_hosting_TASK_TYPE_task()
- hosting_site_post_hosting_verify_task in site/
hosting_site.drush.inc - Implements hook_post_hosting_verify_task().
File
- package/
hosting_package.module, line 426 - Defines package node types
Code
function hosting_package_sync(&$data) {
// Ensure we have data to parse.
if (!is_array($data)) {
return;
}
foreach ($data as $plural => $packages) {
$type = _hosting_package_plural_map($plural);
if (!is_array($packages)) {
continue;
}
foreach ($packages as $short_name => $file) {
$name = isset($file['info']['name']) ? $file['info']['name'] : $short_name;
if (!($package = hosting_get_package($short_name, $type))) {
// Create a new package.
$package = new stdClass();
$package->type = 'package';
$package->uid = 1;
$package->package_type = $type;
$package->short_name = $short_name;
$package->old_short_name = isset($file['info']['old_short_name']) ? $file['info']['old_short_name'] : '';
$package->status = 1;
}
// we only call node save when the title, description changes
// or when it's a new package.
if (!isset($package->nid) || isset($package->title) && $package->title != $name || isset($file['info']['description']) && $package->description != $file['info']['description'] || isset($file['info']['old_short_name']) && $package->old_short_name != $file['info']['old_short_name']) {
$package->title = $name;
$package->description = isset($file['info']['description']) ? $file['info']['description'] : '';
$package->old_short_name = isset($file['info']['old_short_name']) ? $file['info']['old_short_name'] : '';
node_save($package);
}
if (is_array($data[$plural][$short_name])) {
$data[$plural][$short_name]['package_id'] = $package->nid;
}
}
}
}