.../edit/lib/Drupal/edit/Tests/EditTestBase.php | 2 +- .../editor/lib/Drupal/editor/EditorController.php | 5 ++-- .../Drupal/editor/Tests/EditIntegrationTest.php | 26 ++++++++++---------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php b/core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php index c5b545e..6ac8b3b 100644 --- a/core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php +++ b/core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php @@ -29,7 +29,7 @@ function setUp() { $this->installSchema('system', 'variable'); $this->installSchema('field', array('field_config', 'field_config_instance')); - $this->installSchema('entity_test', array('entity_test', 'entity_test_revision')); + $this->installSchema('entity_test', array('entity_test', 'entity_test_rev')); // Set default storage backend. variable_set('field_storage_default', $this->default_storage); diff --git a/core/modules/editor/lib/Drupal/editor/EditorController.php b/core/modules/editor/lib/Drupal/editor/EditorController.php index 6e2ef76..2968454 100644 --- a/core/modules/editor/lib/Drupal/editor/EditorController.php +++ b/core/modules/editor/lib/Drupal/editor/EditorController.php @@ -36,10 +36,9 @@ class EditorController extends ContainerAware { public function getUntransformedText(EntityInterface $entity, $field_name, $langcode, $view_mode) { $response = new AjaxResponse(); - $output = field_view_field($entity, $field_name, $view_mode, $langcode); - $langcode = $output['#language']; // Direct text editing is only supported for single-valued fields. - $editable_text = check_markup($output['#items'][0]['value'], $output['#items'][0]['format'], $langcode, FALSE, array(FILTER_TYPE_TRANSFORM_REVERSIBLE, FILTER_TYPE_TRANSFORM_IRREVERSIBLE)); + $field = $entity->getTranslation($langcode, FALSE)->$field_name; + $editable_text = check_markup($field->value, $field->format, $langcode, FALSE, array(FILTER_TYPE_TRANSFORM_REVERSIBLE, FILTER_TYPE_TRANSFORM_IRREVERSIBLE)); $response->addCommand(new GetUntransformedTextCommand($editable_text)); return $response; diff --git a/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php b/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php index 6417bd3..9e443f8 100644 --- a/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php +++ b/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php @@ -109,8 +109,8 @@ function setUp() { * editor that Edit selects. */ protected function getSelectedEditor($items, $field_name, $view_mode = 'default') { - $options = entity_get_display('test_entity', 'test_bundle', $view_mode)->getComponent($field_name); - $field_instance = field_info_instance('test_entity', $field_name, 'test_bundle'); + $options = entity_get_display('entity_test', 'entity_test', $view_mode)->getComponent($field_name); + $field_instance = field_info_instance('entity_test', $field_name, 'entity_test'); return $this->editorSelector->getEditor($options['type'], $field_instance, $items); } @@ -152,11 +152,11 @@ function testMetadata() { $this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager); // Create an entity with values for the field. - $this->entity = field_test_create_entity(); - $this->is_new = TRUE; - $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED] = array(array('value' => 'Test', 'format' => 'full_html')); - field_test_entity_save($this->entity); - $entity = entity_load('test_entity', $this->entity->ftid); + $this->entity = entity_create('entity_test', array()); + $this->entity->{$this->field_name}->value = 'Test'; + $this->entity->{$this->field_name}->format = 'full_html'; + $this->entity->save(); + $entity = entity_load('entity_test', $this->entity->id()); // Verify metadata. $instance = field_info_instance($entity->entityType(), $this->field_name, $entity->bundle()); @@ -165,7 +165,7 @@ function testMetadata() { 'access' => TRUE, 'label' => 'Long text field', 'editor' => 'editor', - 'aria' => 'Entity test_entity 1, field Long text field', + 'aria' => 'Entity entity_test 1, field Long text field', 'custom' => array( 'format' => 'full_html', 'formatHasTransformations' => FALSE, @@ -179,11 +179,11 @@ function testMetadata() { */ function testGetUntransformedTextCommand() { // Create an entity with values for the field. - $this->entity = field_test_create_entity(); - $this->is_new = TRUE; - $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED] = array(array('value' => 'Test', 'format' => 'full_html')); - field_test_entity_save($this->entity); - $entity = entity_load('test_entity', $this->entity->ftid); + $this->entity = entity_create('entity_test', array()); + $this->entity->{$this->field_name}->value = 'Test'; + $this->entity->{$this->field_name}->format = 'full_html'; + $this->entity->save(); + $entity = entity_load('entity_test', $this->entity->id()); // Verify AJAX response. $controller = new EditorController();