diff --git a/core/lib/Drupal/Core/Entity/EntityFormController.php b/core/lib/Drupal/Core/Entity/EntityFormController.php index bc84d16..2912ed0 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormController.php +++ b/core/lib/Drupal/Core/Entity/EntityFormController.php @@ -273,31 +273,10 @@ public function validate(array $form, array &$form_state) { $violations = array(); - // @todo Simplify when all entity types are converted to EntityNG. - if ($entity instanceof EntityNG) { - foreach ($entity as $field_name => $field) { - $field_violations = $field->validate(); - if (count($field_violations)) { - $violations[$field_name] = $field_violations; - } - } - } - else { - // For BC entities, iterate through each field instance and - // instantiate NG items objects manually. - $definitions = \Drupal::entityManager()->getFieldDefinitions($entity->entityType(), $entity->bundle()); - foreach (field_info_instances($entity->entityType(), $entity->bundle()) as $field_name => $instance) { - $langcode = field_is_translatable($entity->entityType(), $instance->getField()) ? $entity_langcode : Language::LANGCODE_NOT_SPECIFIED; - - // Create the field object. - $items = isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : array(); - // @todo Exception : calls setValue(), tries to set the 'formatted' - // property. - $field = \Drupal::typedData()->create($definitions[$field_name], $items, $field_name, $entity); - $field_violations = $field->validate(); - if (count($field_violations)) { - $violations[$field->getName()] = $field_violations; - } + foreach ($entity as $field_name => $field) { + $field_violations = $field->validate(); + if (count($field_violations)) { + $violations[$field_name] = $field_violations; } } diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php index 4741c19..b586bd6 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php +++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php @@ -99,10 +99,6 @@ public function setValue($value, $notify = TRUE) { // Both the entity ID and the entity object may be passed as value. The // reference may also be unset by passing NULL as value. if (!isset($value) || $value instanceof EntityInterface) { - // Ensure we reference a NG Entity object. - if (isset($value)) { - $value = $value->getNGEntity(); - } $this->target = $value; } elseif (!is_scalar($value) || empty($this->definition['constraints']['EntityType'])) { diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 34e918c..5da51ab 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -610,19 +610,9 @@ function content_translation_form_alter(array &$form, array &$form_state) { // Handle fields shared between translations when there is at least one // translation available or a new one is being created. if (!$entity->isNew() && (!isset($translations[$form_langcode]) || count($translations) > 1)) { - $entity = $entity->getNGEntity(); - if ($entity instanceof EntityNG) { - foreach ($entity->getPropertyDefinitions() as $property_name => $definition) { - if (isset($form[$property_name])) { - $form[$property_name]['#multilingual'] = !empty($definition['translatable']); - } - } - } - else { - foreach (field_info_instances($entity->entityType(), $entity->bundle()) as $instance) { - $field_name = $instance['field_name']; - $field = field_info_field($field_name); - $form[$field_name]['#multilingual'] = !empty($field['translatable']); + foreach ($entity->getPropertyDefinitions() as $property_name => $definition) { + if (isset($form[$property_name])) { + $form[$property_name]['#multilingual'] = !empty($definition['translatable']); } } } diff --git a/core/modules/content_translation/content_translation.pages.inc b/core/modules/content_translation/content_translation.pages.inc index e277791..dc58376 100644 --- a/core/modules/content_translation/content_translation.pages.inc +++ b/core/modules/content_translation/content_translation.pages.inc @@ -237,23 +237,8 @@ function content_translation_edit_page(EntityInterface $entity, Language $langua * The language to be used as target. */ function content_translation_prepare_translation(EntityInterface $entity, Language $source, Language $target) { - // @todo Unify field and property handling. - $entity = $entity->getNGEntity(); - if ($entity instanceof EntityNG) { - $source_translation = $entity->getTranslation($source->id); - $entity->addTranslation($target->id, $source_translation->getPropertyValues()); - } - else { - $instances = field_info_instances($entity->entityType(), $entity->bundle()); - foreach ($instances as $field_name => $instance) { - $field = field_info_field($field_name); - if (!empty($field['translatable'])) { - $value = $entity->get($field_name); - $value[$target->id] = isset($value[$source->id]) ? $value[$source->id] : array(); - $entity->set($field_name, $value); - } - } - } + $source_translation = $entity->getTranslation($source->id); + $entity->addTranslation($target->id, $source_translation->getPropertyValues()); } /** diff --git a/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php b/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php index 9fd4b0e..46a5b89 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php @@ -37,12 +37,6 @@ public function __construct(EntityManager $entityManager) { * {@inheritdoc} */ public function synchronizeFields(EntityInterface $entity, $sync_langcode, $original_langcode = NULL) { - // Field synchronization is only supported for NG entities. - $entity = $entity->getNGEntity(); - if (!($entity instanceof EntityNG)) { - return; - } - $translations = $entity->getTranslationLanguages(); // If we have no information about what to sync to, if we are creating a new diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php index 74b779b..65e9ddd 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php @@ -258,9 +258,7 @@ protected function getFormSubmitAction(EntityInterface $entity) { * The translation object to act on. */ protected function getTranslation(EntityInterface $entity, $langcode) { - // @todo remove once EntityBCDecorator is gone. - $entity = $entity->getNGEntity(); - return $entity instanceof EntityNG ? $entity->getTranslation($langcode) : $entity; + return $entity->getTranslation($langcode); } /** @@ -278,13 +276,7 @@ protected function getTranslation(EntityInterface $entity, $langcode) { */ protected function getValue(EntityInterface $translation, $property, $langcode) { $key = $property == 'user_id' ? 'target_id' : 'value'; - // @todo remove EntityBCDecorator condition once EntityBCDecorator is gone. - if (($translation instanceof EntityInterface) && !($translation instanceof EntityNG) && !($translation instanceof EntityBCDecorator)) { - return is_array($translation->$property) ? $translation->{$property}[$langcode][0][$key] : $translation->$property; - } - else { - return $translation->get($property)->{$key}; - } + return $translation->get($property)->{$key}; } } diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc index 3125584..56cd048 100644 --- a/core/modules/field/field.attach.inc +++ b/core/modules/field/field.attach.inc @@ -407,8 +407,6 @@ function _field_invoke_widget_target($form_display) { * values. */ function field_attach_preprocess(EntityInterface $entity, $element, &$variables) { - // Ensure we are working with a BC mode entity. - $entity = $entity->getBCEntity(); foreach (field_info_instances($entity->entityType(), $entity->bundle()) as $instance) { $field_name = $instance['field_name']; if (isset($element[$field_name]['#language'])) { diff --git a/core/modules/field/field.deprecated.inc b/core/modules/field/field.deprecated.inc index 1b1d8f9..b535141 100644 --- a/core/modules/field/field.deprecated.inc +++ b/core/modules/field/field.deprecated.inc @@ -557,9 +557,6 @@ function field_read_instances($conditions = array(), $include_additional = array * @see field_form_set_state() */ function field_attach_form(EntityInterface $entity, &$form, &$form_state, $langcode = NULL, array $options = array()) { - // Ensure we are working with a BC mode entity. - $entity = $entity->getBCEntity(); - // Set #parents to 'top-level' by default. $form += array('#parents' => array()); @@ -823,11 +820,6 @@ function field_attach_load_revision($entity_type, $entities, $options = array()) * @deprecated as of Drupal 8.0. Use the entity system instead. */ function field_attach_form_validate(EntityInterface $entity, $form, &$form_state, array $options = array()) { - // Only support NG entities. - if (!($entity->getNGEntity() instanceof EntityNG)) { - return; - } - $has_violations = FALSE; foreach ($entity as $field_name => $field) { $definition = $field->getDefinition(); @@ -872,9 +864,6 @@ function field_attach_form_validate(EntityInterface $entity, $form, &$form_state * @deprecated as of Drupal 8.0. Use the entity system instead. */ function field_attach_extract_form_values(EntityInterface $entity, $form, &$form_state, array $options = array()) { - // Ensure we are working with a BC mode entity. - $entity = $entity->getBCEntity(); - // Extract field values from submitted values. $form_display = $form_state['form_display']; field_invoke_method('extractFormValues', _field_invoke_widget_target($form_display), $entity, $form, $form_state, $options); @@ -1076,9 +1065,6 @@ function field_attach_prepare_view($entity_type, array $entities, array $display $prepare = array(); foreach ($entities as $id => $entity) { if (empty($entity->_field_view_prepared)) { - // Ensure we are working with a BC mode entity. - $entity = $entity->getBCEntity(); - // Add this entity to the items to be prepared. $prepare[$id] = $entity; @@ -1132,8 +1118,6 @@ function field_attach_prepare_view($entity_type, array $entities, array $display * @deprecated as of Drupal 8.0. Use the entity system instead. */ function field_attach_view(EntityInterface $entity, EntityDisplay $display, $langcode = NULL, array $options = array()) { - // Ensure we are working with a BC mode entity. - $entity = $entity->getBCEntity(); // Determine the actual language code to display for each field, given the // language codes available in the field data. $options['langcode'] = field_language($entity, NULL, $langcode); @@ -1145,8 +1129,6 @@ function field_attach_view(EntityInterface $entity, EntityDisplay $display, $lan }; $null = NULL; $output = field_invoke_method('view', $target_function, $entity, $null, $null, $options); - // Remove the BC layer now. - $entity = $entity->getNGEntity(); // Let other modules alter the renderable array. $view_mode = $display->originalMode; @@ -1184,7 +1166,6 @@ function field_attach_view(EntityInterface $entity, EntityDisplay $display, $lan * $entity->getTranslation($langcode)->{$field_name} */ function field_get_items(EntityInterface $entity, $field_name, $langcode = NULL) { - $entity = $entity->getBCEntity(); $langcode = field_language($entity, $field_name, $langcode); return isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : array(); } diff --git a/core/modules/field/field.module b/core/modules/field/field.module index c355e67..16e4607 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -638,9 +638,6 @@ function _field_filter_xss_display_allowed_tags() { function field_view_value(EntityInterface $entity, $field_name, $item, $display = array(), $langcode = NULL) { $output = array(); - // Ensure we are working with a BC mode entity. - $entity = $entity->getBCEntity(); - if ($field = field_info_field($field_name)) { // Determine the langcode that will be used by language fallback. $langcode = field_language($entity, $field_name, $langcode); @@ -746,7 +743,7 @@ function field_view_field(EntityInterface $entity, $field_name, $display_options $display_langcode = field_language($entity, $field_name, $langcode); // Invoke the formatter's prepareView() and view() methods. - $items = $entity->getNGEntity()->getTranslation($display_langcode)->get($field_name); + $items = $entity->getTranslation($display_langcode)->get($field_name); $id = $entity->id(); $formatter->prepareView(array($id => $entity), $display_langcode, array($id => $items)); $result = $formatter->view($entity, $display_langcode, $items); diff --git a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php index 85c14e2..d4c3da7 100644 --- a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php @@ -324,7 +324,7 @@ function testFieldDisplayLanguage() { \Drupal::state()->set('field_test.language_fallback', FALSE); $entity->getTranslation($requested_langcode)->{$this->field_name}->value = mt_rand(1, 127); drupal_static_reset('field_language'); - $display_langcode = field_language($entity->getBCEntity(), $this->field_name, $requested_langcode); + $display_langcode = field_language($entity, $this->field_name, $requested_langcode); $this->assertEqual($display_langcode, $requested_langcode, 'Display language behave correctly when language fallback is disabled'); } diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php index 7e1b3bc..07aca77 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php @@ -231,14 +231,7 @@ public function submitForm(array &$form, array &$form_state) { * The field item object. */ protected function getFieldItem(EntityInterface $entity, $field_name) { - if ($entity instanceof EntityNG) { - $item = $entity->get($field_name)->offsetGet(0); - } - else { - $definitions = $this->entityManager->getFieldDefinitions($entity->entityType(), $entity->bundle()); - $item = $this->typedData->create($definitions[$field_name], array(), $field_name, $entity)->offsetGet(0); - } - return $item; + return $entity->get($field_name)->offsetGet(0); } } diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php index 4aff6da..b36812c 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php @@ -217,14 +217,7 @@ public function delete(array &$form, array &$form_state) { * The field object. */ protected function getFieldItems(EntityInterface $entity, $field_name) { - if ($entity instanceof EntityNG) { - $item = $entity->get($field_name); - } - else { - $definitions = \Drupal::entityManager()->getFieldDefinitions($entity->entityType(), $entity->bundle()); - $item = \Drupal::typedData()->create($definitions[$field_name], $this->instance->default_value, $field_name, $entity); - } - return $item; + return $entity->get($field_name); } /** diff --git a/core/modules/file/file.field.inc b/core/modules/file/file.field.inc index 7acd885..e2c1dd6 100644 --- a/core/modules/file/file.field.inc +++ b/core/modules/file/file.field.inc @@ -216,7 +216,7 @@ function file_field_update(EntityInterface $entity, $field, $instance, $langcode } // Compare the original field values with the ones that are being saved. - $original = $entity->original->getBCEntity(); + $original = $entity->original; $original_fids = array(); if (!empty($original->{$field['field_name']}[$langcode])) { foreach ($original->{$field['field_name']}[$langcode] as $original_item) { diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php index 27834a3..384c815 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php @@ -70,12 +70,12 @@ function testFieldAccess() { $values = array('name' => 'test'); $account = entity_create('user', $values); - $this->assertFalse($entity->field_test_text->access('view', $account->getNGEntity()), 'Access to the field was denied.'); + $this->assertFalse($entity->field_test_text->access('view', $account), 'Access to the field was denied.'); $entity->field_test_text = 'access alter value'; - $this->assertFalse($entity->field_test_text->access('view', $account->getNGEntity()), 'Access to the field was denied.'); + $this->assertFalse($entity->field_test_text->access('view', $account), 'Access to the field was denied.'); $entity->field_test_text = 'standard value'; - $this->assertTrue($entity->field_test_text->access('view', $account->getNGEntity()), 'Access to the field was granted.'); + $this->assertTrue($entity->field_test_text->access('view', $account), 'Access to the field was granted.'); } } diff --git a/core/modules/user/lib/Drupal/user/Tests/UserAdminListingTest.php b/core/modules/user/lib/Drupal/user/Tests/UserAdminListingTest.php index 9dfbe65..182812d 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserAdminListingTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserAdminListingTest.php @@ -34,17 +34,17 @@ public function testUserListing() { // Create a bunch of users. $accounts = array(); for ($i = 0; $i < 3; $i++) { - $account = $this->drupalCreateUser()->getNGEntity(); + $account = $this->drupalCreateUser(); $accounts[$account->label()] = $account; } // Create a blocked user. - $account = $this->drupalCreateUser()->getNGEntity(); + $account = $this->drupalCreateUser(); $account->block(); $account->save(); $accounts[$account->label()] = $account; // Create a user at a certain timestamp. - $account = $this->drupalCreateUser()->getNGEntity(); + $account = $this->drupalCreateUser(); $account->created = 1363219200; $account->save(); $accounts[$account->label()] = $account; @@ -53,7 +53,7 @@ public function testUserListing() { $rid_1 = $this->drupalCreateRole(array(), 'custom_role_1', 'custom_role_1'); $rid_2 = $this->drupalCreateRole(array(), 'custom_role_2', 'custom_role_2'); - $account = $this->drupalCreateUser()->getNGEntity(); + $account = $this->drupalCreateUser(); $account->addRole($rid_1); $account->addRole($rid_2); $account->save(); @@ -61,7 +61,7 @@ public function testUserListing() { $role_account_name = $account->label(); // Create an admin user and look at the listing. - $admin_user = $this->drupalCreateUser(array('administer users'))->getNGEntity(); + $admin_user = $this->drupalCreateUser(array('administer users')); $accounts[$admin_user->label()] = $admin_user; $accounts['admin'] = entity_load('user', 1);