function entity_example_entity_info

Implements hook_entity_info().

This is the fundamental description of the entity.

It provides a single entity with a single bundle and without revision support.

Related topics

File

entity_example/entity_example.module, line 38

Code

function entity_example_entity_info() {
    $info['entity_example_basic'] = array(
        // A human readable label to identify our entity.
'label' => t('Example Basic Entity'),
        // The controller for our Entity, extending the Drupal core controller.
'controller class' => 'EntityExampleBasicController',
        // The table for this entity defined in hook_schema()
'base table' => 'entity_example_basic',
        // Returns the uri elements of an entity.
'uri callback' => 'entity_example_basic_uri',
        // IF fieldable == FALSE, we can't attach fields.
'fieldable' => TRUE,
        // entity_keys tells the controller what database fields are used for key
        // functions. It is not required if we don't have bundles or revisions.
        // Here we do not support a revision, so that entity key is omitted.
'entity keys' => array(
            // The 'id' (basic_id here) is the unique id.
'id' => 'basic_id',
            // Bundle will be determined by the 'bundle_type' field.
'bundle' => 'bundle_type',
        ),
        'bundle keys' => array(
            'bundle' => 'bundle_type',
        ),
        // FALSE disables caching. Caching functionality is handled by Drupal core.
'static cache' => TRUE,
        // Bundles are alternative groups of fields or configuration
        // associated with a base entity type.
'bundles' => array(
            'first_example_bundle' => array(
                'label' => 'First example bundle',
                // 'admin' key is used by the Field UI to provide field and
                // display UI pages.
'admin' => array(
                    'path' => 'admin/structure/entity_example_basic/manage',
                    'access arguments' => array(
                        'administer entity_example_basic entities',
                    ),
                ),
            ),
        ),
        // View modes allow entities to be displayed differently based on context.
        // As a demonstration we'll support "Tweaky", but we could have and support
        // multiple display modes.
'view modes' => array(
            'tweaky' => array(
                'label' => t('Tweaky'),
                'custom settings' => FALSE,
            ),
        ),
    );
    return $info;
}