1

If I know the entity type and bundle, I want to load the bundle object with its settings. Drupal core has this for nodes, but is there any way to do it for entities?

See node_type_load() in core: https://api.drupal.org/api/drupal/modules!node!node.module/function/node_type_load/7

EDIT: So to elaborate, I'm asking about a way to load up the data about the entity bundle, not a specific entity.

E.g.

var_dump(node_type_load('page'));

object(stdClass)[628]
  public 'type' => string 'page' (length=4)
  public 'name' => string 'Page' (length=4)
  public 'base' => string 'node_content' (length=12)
  public 'module' => string 'node' (length=4)
  public 'description' => string 'Use <em>pages</em> for your static content.' (length=43)
  public 'help' => string '' (length=0)
  public 'has_title' => string '1' (length=1)
  public 'title_label' => string 'Title' (length=5)
  public 'custom' => string '1' (length=1)
  public 'modified' => string '1' (length=1)
  public 'locked' => string '0' (length=1)
  public 'disabled' => string '0' (length=1)
  public 'orig_type' => string 'page' (length=4)
  public 'disabled_changed' => boolean false
  • have you tried entity_get_property_info() like i suggested below ? – jowan sebastian Dec 13 '14 at 17:54
1

You can use entity_get_property_info() for example

var_dump(entity_get_property_info('node'));

Bundles are a keyed array within the result and they contain a keyed array of the fields and their settings.

Other information about the bundles other than field properties, such as menu callback etc, can be obtained using entity_get_info() where the bundles as keyed array within the result contains other non-field info.

0

I guess I am not 100% sure what you need here. However, as nodes are entities there will be a way to load other entities. You have entity_load for example. If this is not what you need could you elaborate?

  • Have updated question with example output of node_type_load(). – dieuwe Dec 12 '14 at 0:06
  • Ok, are there particular settings from the node_type_load var_dump that you need. You can load up a lot of information with EntityMetadataWrappers. Depending on what you are trying to do with the information EntityFieldQuery might help as well. Let us know which properties, settings etc. you are looking for and we can help you narrow it down. – sareed Dec 12 '14 at 16:38
  • 1
    For example: $wrapper = entity_metadata_wrapper('node', NULL, array('bundle' => 'page')); has a lot of information, possibly way too much for your needs. – sareed Dec 12 '14 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.