You are here

function entity_metadata_book_get_properties in Entity API 7

Callback for getting book node properties.

See also

entity_metadata_book_entity_info_alter()

1 string reference to 'entity_metadata_book_get_properties'
entity_metadata_book_entity_property_info_alter in modules/book.info.inc
Implements hook_entity_property_info_alter() on top of book module.

File

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

Code

function entity_metadata_book_get_properties($node, array $options, $name, $entity_type) {
  switch ($name) {
    case 'book':
      if (isset($node->book['bid'])) {
        return $node->book['bid'];
      }
      return NULL;
    case 'book_ancestors':
      $ancestors = array();
      while (!empty($node->book['plid']) && $node->book['plid'] != -1) {
        $link = book_link_load($node->book['plid']);
        array_unshift($ancestors, $link['nid']);
        $node = node_load($link['nid']);
      }
      return $ancestors;
  }
}