7.x comment.module comment_entity_info()

Implements hook_entity_info().

File

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

Code

function comment_entity_info() {
  $return = array(
    'comment' => array(
      'label' => t('Comment'),
      'base table' => 'comment',
      'uri callback' => 'comment_uri',
      'fieldable' => TRUE,
      'controller class' => 'CommentController',
      'entity keys' => array(
        'id' => 'cid',
        'bundle' => 'node_type',
        'label' => 'subject',
        'language' => 'language',
      ),
      'bundles' => array(),
      'view modes' => array(
        'full' => array(
          'label' => t('Full comment'),
          'custom settings' => FALSE,
        ),
      ),
      'static cache' => FALSE,
    ),
  );
  foreach (node_type_get_names() as $type => $name) {
    $return['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_node_type_load() and comment_menu_alter().
        'path' => 'admin/structure/types/manage/%comment_node_type/comment',
        'bundle argument' => 4,
        'real path' => 'admin/structure/types/manage/' . str_replace('_', '-', $type) . '/comment',
        'access arguments' => array(
          'administer content types',
        ),
      ),
    );
  }
  return $return;
}

Comments

roach2015’s picture

I was trying to load a node by calling 'node_load' function when I encountered this fatal error.
Fatal error: Call to undefined function node_type_get_names() in C:\wamp\www\drupal754\modules\comment\comment.module on line 119
Call Stack
# Time Memory Function Location
1 0.0005 243376 {main}( ) ..\index.php:0
2 0.0055 752480 drupal_bootstrap( ) ..\index.php:20
3 0.0656 5839384 _drupal_bootstrap_full( ) ..\bootstrap.inc:2533
4 0.0864 8882248 module_load_all( ) ..\common.inc:5274
5 0.1287 13388272 drupal_load( ) ..\module.inc:24
6 0.1297 13401560 include_once( 'C:\wamp\www\drupal754\sites\all\modules\custom\jlcarousel\jlcarousel.module' ) ..\bootstrap.inc:1369
7 0.1314 13436976 carousel_get_body_pics( ) ..\jlcarousel.module:81
8 0.1314 13437040 universal_retrieve_fieldimages( ) ..\jlcarousel.module:66
9 0.1314 13437696 universal_query_load_entities( ) ..\universal_funcs.inc:48
10 0.1314 13437760 entity_load( ) ..\universal_funcs.inc:11
11 0.1314 13437968 entity_get_controller( ) ..\common.inc:8012
12 0.1314 13438544 entity_get_info( ) ..\common.inc:8046
13 0.1317 13439744 module_invoke_all( ) ..\common.inc:7843
14 0.1326 13448520 call_user_func_array:{C:\wamp\www\drupal754\includes\module.inc:957} ( ) ..\module.inc:957
15 0.1326 13448736 comment_entity_info( ) ..\module.inc:957

I also tried to call this comment_entity_info func alone for testing and I got this “call to undefined function node_type_get_names()” error again.
when I put all my codes into a template file ,for example, the page--front.tpl.php they work ok.I got really stunned .if I can't load an entity within my module, I probably won't be able to do anything in it...
this error occurs for sure after clearing the system cache...
Someone please help ,thanks.
P.S I have some modules such as IMCE & CKEditor installed.