class menu_token_entity_random in Menu Token 7
Hierarchy
- class \menu_token_handler
- class \menu_token_entity_random
Expanded class hierarchy of menu_token_entity_random
1 string reference to 'menu_token_entity_random'
- menu_token_menu_token_plugins in ./
menu_token.module - Implements hook_menu_token_plugins().
File
- plugins/
menu_token_entity_random.inc, line 3
View source
class menu_token_entity_random extends menu_token_handler {
public function form_options($options) {
// Nothing to do here.
}
public function form_submit($form, &$form_state) {
// Nothing to do here.
}
public function form_alter(&$form, &$form_state) {
// Nothing to do here.
}
public function object_load($options) {
$entity_type = $options['_type'];
$info = entity_get_info($entity_type);
$id = db_select($info['base table'], 'e')
->fields('e', array(
$info['entity keys']['id'],
))
->orderRandom()
->range(0, 1)
->execute()
->fetchField(0);
if ($id) {
return entity_load_single($entity_type, $id);
}
return FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
menu_token_entity_random:: |
public | function |
You can alter the menu item administration form with this function. Overrides menu_token_handler:: |
|
menu_token_entity_random:: |
public | function |
You can provide options for your menu token handler via this function.
The return value will be appended to the form as soon as the administrator
chooses your plugin. Overrides menu_token_handler:: |
|
menu_token_entity_random:: |
public | function |
This function allows your plugin to act upon form submission. The return
value will be added to the $options array and thus should be an array
itself. Overrides menu_token_handler:: |
|
menu_token_entity_random:: |
public | function |
This function is used to load the relevant token replacement object. Overrides menu_token_handler:: |
|
menu_token_handler:: |
public | function | This function allows your plugin to act upon form validation. The return value will be added to the $options array and thus should be an array itself. | 2 |