function options_test_dynamic_values_callback
Same name and namespace in other branches
- 9 core/modules/options/tests/options_test/options_test.module \options_test_dynamic_values_callback()
- 8.9.x core/modules/options/tests/options_test/options_test.module \options_test_dynamic_values_callback()
- 10 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
3 string references to 'options_test_dynamic_values_callback'
- OptionsDynamicValuesApiTest::setUp in core/
modules/ options/ tests/ src/ Kernel/ OptionsDynamicValuesApiTest.php - Set the default field storage backend for fields created during tests.
- OptionsDynamicValuesTestBase::setUp in core/
modules/ options/ tests/ src/ Functional/ OptionsDynamicValuesTestBase.php - ViewsDataTest::setUp in core/
modules/ options/ tests/ src/ Kernel/ Views/ ViewsDataTest.php
File
-
core/
modules/ options/ tests/ options_test/ options_test.module, line 44
Code
function options_test_dynamic_values_callback(FieldStorageDefinitionInterface $definition, ?FieldableEntityInterface $entity = NULL, &$cacheable = NULL) {
$values = [];
if (isset($entity)) {
$cacheable = FALSE;
$values = [
$entity->label(),
$entity->toUrl()
->toString(),
$entity->uuid(),
$entity->bundle(),
];
}
// We need the values of the entity as keys.
return array_combine($values, $values);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.