You are here

function sarnia_entity_info in Sarnia 7

Implements hook_entity_info().

Provide entity types to represent data from Solr, based on Search API servers. Because of the way Search API indexes work, data from each Search API server needs to be represented as an independent entity type, rather than as a bundle on a single Sarnia entity type.

In other parts of this module, entity types provided here are referred to as "Sarnia entity types".

File

./sarnia.module, line 417

Code

function sarnia_entity_info() {
  $entities = array();

  // Load entity type configuration information from the database.
  module_load_include('inc', 'sarnia', 'sarnia.entities');
  foreach (_sarnia_entity_types() as $machine_name => $type) {
    $entities[$machine_name] = array(
      'label' => $type['label'],
      'controller class' => 'SarniaController',
      'fieldable' => TRUE,
      'static cache' => TRUE,
      'uri callback' => 'sarnia_uri',
      'view callback' => 'sarnia_view_multiple',
      'base table' => NULL,
      // Prevent undefined array index errors from Views.
      'entity keys' => array(
        'id' => 'id',
        'revision' => FALSE,
        'bundle' => FALSE,
      ),
      'bundles' => array(
        $machine_name => array_merge($type, array(
          'admin' => array(
            'path' => "admin/config/search/search_api/server/{$type['search_api_server']}/sarnia",
          ),
        )),
      ),
      'view modes' => array(),
    );
  }
  return $entities;
}