2009-12-14 20:18:56 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Helper module for the List module tests.
|
|
|
|
*/
|
|
|
|
|
2013-01-07 11:22:28 +00:00
|
|
|
use Drupal\Core\Entity\EntityInterface;
|
2013-10-19 08:12:13 +00:00
|
|
|
use Drupal\Core\Field\FieldDefinitionInterface;
|
2013-01-07 11:22:28 +00:00
|
|
|
|
2009-12-14 20:18:56 +00:00
|
|
|
/**
|
|
|
|
* Allowed values callback.
|
|
|
|
*/
|
2013-06-16 08:27:11 +00:00
|
|
|
function options_test_allowed_values_callback(FieldDefinitionInterface $field_definition, EntityInterface $entity) {
|
2009-12-14 20:18:56 +00:00
|
|
|
$values = array(
|
|
|
|
'Group 1' => array(
|
|
|
|
0 => 'Zero',
|
|
|
|
),
|
|
|
|
1 => 'One',
|
|
|
|
'Group 2' => array(
|
|
|
|
2 => 'Some <script>dangerous</script> & unescaped <strong>markup</strong>',
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
return $values;
|
|
|
|
}
|
2012-04-25 22:00:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An entity-bound allowed values callback.
|
|
|
|
*/
|
2013-06-16 08:27:11 +00:00
|
|
|
function options_test_dynamic_values_callback(FieldDefinitionInterface $field_definition, EntityInterface $entity, &$cacheable) {
|
2012-04-25 22:00:46 +00:00
|
|
|
$cacheable = FALSE;
|
|
|
|
// We need the values of the entity as keys.
|
2013-06-10 12:37:27 +00:00
|
|
|
$uri = $entity->uri();
|
2012-10-14 05:44:26 +00:00
|
|
|
return drupal_map_assoc(array(
|
2013-06-10 12:37:27 +00:00
|
|
|
$entity->label(),
|
|
|
|
$uri['path'],
|
|
|
|
$entity->uuid(),
|
2012-10-14 05:44:26 +00:00
|
|
|
$entity->bundle(),
|
|
|
|
));
|
2012-04-25 22:00:46 +00:00
|
|
|
}
|