1 comment.module comment_entity_info()

Implements hook_entity_info().

File

core/modules/comment/comment.module, line 89
Enables users to comment on published content.

Code

function comment_entity_info() {
  $entity_info = array(
    'comment' => array(
      'label' => t('Comment'),
      'bundle label' => t('Node type'),
      'base table' => 'comment',
      'fieldable' => TRUE,
      'controller class' => 'CommentStorageController',
      'entity class' => 'Comment',
      'entity keys' => array(
        'id' => 'cid',
        'bundle' => 'node_type',
      ),
      'bundles' => array(),
      'view modes' => array(
        'full' => array(
          'label' => t('Full comment'),
          'custom settings' => FALSE,
        ),
        'token' => array(
          'label' => t('Tokens'),
          'custom settings' => FALSE,
        ),
      ),
      'static cache' => FALSE,
    ),
  );

  // If the cache table has been created, then enable entity caching.
  if (db_table_exists('cache_entity_comment')) {
    $entity_info['comment']['entity cache'] = TRUE;
    $entity_info['comment']['field cache'] = FALSE;
  }

  foreach (node_type_get_names() as $type => $name) {
    $entity_info['comment']['bundles']['comment_node_' . $type] = array(
      'label' => t('@node_type comment', array('@node_type' => $name)),
      // Provide the node type/bundle name for other modules, so it does not
      // have to be extracted manually from the bundle name.
      'node bundle' => $type,
      'admin' => array(
        // Place the Field UI paths for comments one level below the
        // corresponding paths for nodes, so that they appear in the same set
        // of local tasks. Note that the paths use a different placeholder name
        // and thus a different menu loader callback, so that Field UI page
        // callbacks get a comment bundle name from the node type in the URL.
        // See comment_menu_node_type_load() and comment_menu_alter().
        'path' => 'admin/structure/types/manage/%comment_menu_node_type/comment',
        'bundle argument' => 4,
        'real path' => 'admin/structure/types/manage/' . str_replace('_', '-', $type) . '/comment',
        'access arguments' => array('administer content types'),
      ),
    );
  }

  return $entity_info;
}