function options_test_dynamic_values_callback in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/options/tests/options_test/options_test.module \options_test_dynamic_values_callback()
Implements callback_allowed_values_function().
@todo This function violates the recommendation in options_allowed_values() to return a list of all possible values in any context when $items is NULL. Since this is not yet used for testing Views integration, that is alright for now. Fix this in https://www.drupal.org/node/2012130.
See also
2 string references to 'options_test_dynamic_values_callback'
- OptionsDynamicValuesTestBase::setUp in core/
modules/ options/ src/ Tests/ OptionsDynamicValuesTestBase.php - Sets up a Drupal site for running functional and integration tests.
- ViewsDataTest::setUp in core/
modules/ options/ src/ Tests/ Views/ ViewsDataTest.php - Performs setup tasks before each individual test method is run.
File
- core/
modules/ options/ tests/ options_test/ options_test.module, line 43 - Helper module for the List module tests.
Code
function options_test_dynamic_values_callback(FieldStorageDefinitionInterface $definition, FieldableEntityInterface $entity = NULL, &$cacheable = NULL) {
$values = array();
if (isset($entity)) {
$cacheable = FALSE;
$values = array(
$entity
->label(),
$entity
->url(),
$entity
->uuid(),
$entity
->bundle(),
);
}
// We need the values of the entity as keys.
return array_combine($values, $values);
}