You are here

function entityform_block_get_entity in Entityform block 7

Using entity field query to retrieve the entity object.

Parameters

$type: Entityform type.

Return value

Returns entityform type entity object if true, FALSE if it doesn't exist.

1 call to entityform_block_get_entity()
entityform_block_block_view in ./entityform_block.module
Implements hook_block_view().

File

./entityform_block.module, line 175
Render any entity form into a block.

Code

function entityform_block_get_entity($type) {
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', 'entityform_type')
    ->propertyCondition('type', $type);
  $result = $query
    ->execute();
  if (!empty($result)) {
    $id = key($result['entityform_type']);
    $entity_form = entity_load('entityform_type', array(
      $id,
    ));
    return $entity_form[$id];
  }
  else {
    return FALSE;
  }
}