You are here

function node_deploy_check in Deploy - Content Staging 6

Implementation of hook_deploy_check().

Used to manage deployment dependencies

Parameters

$nid: Nid of the node we're trying to deploy

File

modules/node_deploy/node_deploy.module, line 70
Deployment API which enables modules to deploy items between servers.

Code

function node_deploy_check($nid) {

  // pid of the plan we're deploying
  $pid = variable_get('deploy_pid', 0);
  $node = node_load($nid);

  // If this node is a translation of another node, and this
  // other node is not already on the remote server, add it
  // to the plan.
  if ($node->tnid && $node->tnid != $node->nid) {
    if (!deploy_item_is_in_plan($pid, 'node', $node->tnid)) {

      // Does this node exist on the remote server?
      $remote_key = deploy_get_remote_key(deploy_uuid_get_node_uuid($node->tnid), 'node');

      // If it doesn't exist or the local version is newer, add it to the deployment plan,
      // with a weight of min(weight) - 1, and then run dependency checking on it
      $plan_node = node_load($node->tnid);
      if (!$remote_key || $remote_key['changed'] < $plan_node->changed) {
        deploy_add_to_plan($pid, 'node', $plan_node->type . ': ' . $plan_node->title, $plan_node->nid, deploy_get_min_weight($pid) - 1, DEPLOY_NODE_GROUP_WEIGHT);
        module_invoke_all('node_deploy_check', $plan_node);
      }
    }
  }
  if ($node) {
    module_invoke_all('node_deploy_check', $node);
  }
}