You are here

function entity_metadata_node_get_properties in Entity API 7

Callback for getting node properties.

See also

entity_metadata_node_entity_info_alter()

1 string reference to 'entity_metadata_node_get_properties'
entity_metadata_node_entity_property_info in modules/node.info.inc
Implements hook_entity_property_info() on top of node module.

File

modules/callbacks.inc, line 137
Provides various callbacks for the whole core module integration.

Code

function entity_metadata_node_get_properties($node, array $options, $name, $entity_type) {
  switch ($name) {
    case 'is_new':
      return empty($node->nid) || !empty($node->is_new);
    case 'source':
      if (!empty($node->tnid) && ($source = node_load($node->tnid))) {
        return $source;
      }
      return NULL;
    case 'edit_url':
      return url('node/' . $node->nid . '/edit', $options);
    case 'author':
      return !empty($node->uid) ? $node->uid : drupal_anonymous_user();
  }
}