You are here

function filefield_node_deploy in Deploy - Content Staging 6

Implementation of hook_node_deploy(),

Parameters

$node: The node we're deploying.

Return value

The results of our xmlrpc call.

File

modules/filefield_deploy/filefield_deploy.module, line 134
Deployment API which enables modules to deploy items between servers.

Code

function filefield_node_deploy(&$node) {
  $filefields = filefield_deploy_get_file_fields($node->type);

  // We keep a list of all the files in this node, so we can rsync them
  // later.
  $node_files = array();
  if ($filefields) {
    foreach ($filefields as $field) {

      // A node object from a node load just returns the file field as empty.
      // However our node object pulled out of the form api gives every file object
      // at least one entry, even though this entry may well be filled with empty
      // data when the file doesn't exist. This is why we need to check that the field's
      // fid is not 0.
      if ($node->{$field}) {
        foreach ($node->{$field} as $key => $file) {
          if ($file['fid'] != 0) {
            $remote_key = deploy_get_remote_key($file['uuid'], 'files');
            $node->{$field}[$key]['fid'] = $remote_key['fid'];
          }
        }
      }
    }
  }
}