diff --git a/core/modules/entity_reference/entity_reference.module b/core/modules/entity_reference/entity_reference.module index 08dd8c7..f5e968c 100644 --- a/core/modules/entity_reference/entity_reference.module +++ b/core/modules/entity_reference/entity_reference.module @@ -422,15 +422,15 @@ function entity_reference_query_entity_reference_alter(AlterableInterface $query /** * Creates an instance of a entity reference field on the specified bundle. * + * @param string $entity_type + * The type of entity the field instance will be attached to. + * @param string $bundle + * The bundle name of the entity the field instance will be attached to. * @param string $field_name * The name of the field; if it already exists, a new instance of the existing * field will be created. * @param string $field_label * The label of the field instance. - * @param string $entity_type - * The type of entity the field instance will be attached to. - * @param string $bundle - * The bundle name of the entity the field instance will be attached to. * @param string $target_entity_type * The type of the referenced entity. * @param string $selection_handler @@ -438,9 +438,10 @@ function entity_reference_query_entity_reference_alter(AlterableInterface $query * @param array $selection_handler_settings * An array of settings supported by the selection handler specified above. * (e.g. 'target_bundles', 'sort', 'auto_create', etc). - * @see \Drupal\entity_reference\Plugin\entity_reference\selection\SelectionBase::settingsForm(). + * + * @see \Drupal\entity_reference\Plugin\entity_reference\selection\SelectionBase::settingsForm() */ -function entity_reference_create_instance($field_name, $field_label, $entity_type, $bundle, $target_entity_type, $selection_handler = 'default', $selection_handler_settings = array()) { +function entity_reference_create_instance($entity_type, $bundle, $field_name, $field_label, $target_entity_type, $selection_handler = 'default', $selection_handler_settings = array()) { // If a field type we know should exist isn't found, clear the field cache. if (!field_info_field_types('entity_reference')) { field_cache_clear(); @@ -467,7 +468,6 @@ function entity_reference_create_instance($field_name, $field_label, $entity_typ 'field_name' => $field_name, 'entity_type' => $entity_type, 'bundle' => $bundle, - 'label' => $field_label, 'settings' => array( 'handler' => $selection_handler, diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceItemTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceItemTest.php index 8906e4d..75caa6b 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceItemTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceItemTest.php @@ -32,35 +32,14 @@ public static function getInfo() { ); } + /** + * Sets up the test. + */ public function setUp() { parent::setUp(); - $field = array( - 'translatable' => FALSE, - 'entity_types' => array(), - 'settings' => array( - 'target_type' => 'node', - ), - 'field_name' => 'field_test', - 'type' => 'entity_reference', - 'cardinality' => FIELD_CARDINALITY_UNLIMITED, - ); - - field_create_field($field); - - $instance = array( - 'entity_type' => 'entity_test', - 'field_name' => 'field_test', - 'bundle' => 'entity_test', - 'widget' => array( - 'type' => 'options_select', - ), - 'settings' => array( - 'handler' => 'default', - 'handler_settings' => array(), - ), - ); - field_create_instance($instance); + // Use the util to create an instance. + entity_reference_create_instance('entity_test', 'entity_test', 'field_test', 'Test entity reference', 'node'); } /**