function entity_block_autocomplete_callback in Entity Blocks 7
Callback for the autocompete path.
We make use of entityreference_autocomplete_callback_get_matches from entityreference.module.
Parameters
$entity_type: The entity type.
$bundle: The bundle for the entity.
string $string: The string to match
Return value
array
1 string reference to 'entity_block_autocomplete_callback'
- entity_block_menu in ./
entity_block.module - Implements hook_menu().
File
- ./
entity_block.module, line 173 - Display entities (via view modes) as fieldable blocks.
Code
function entity_block_autocomplete_callback($entity_type, $bundle, $string = '') {
// Shift off the $entity_type and $bundle_name args.
$args = func_get_args();
array_shift($args);
array_shift($args);
$string = implode('/', $args);
// Create a dummy field. Needed by entityreference to get a handler.
$field = array(
'field_name' => 'entity_block_target_entity_id',
'type' => 'text',
'settings' => array(
'target_type' => $entity_type,
'handler' => 'base',
'handler_settings' => array(
'target_bundles' => array(
$bundle => $bundle,
),
),
),
);
// Create an instance of dummy field.
$instance = array(
'field_name' => 'entity_block_target_entity_id',
'entity_type' => 'entity_block',
'bundle' => 'entity_block',
'widget' => array(
'settings' => array(
'match_operator' => 'CONTAINS',
'size' => 60,
'path' => '',
),
),
);
// Call entityreference_autocomplete_callback_get_matches from entityreference.module.
return entityreference_autocomplete_callback_get_matches('single', $field, $instance, $entity_type, 'NULL', $string);
}