From 6e5d1a09ca2bd071092543e98dad5a18c04e6f11 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Mon, 7 Jan 2013 11:22:28 +0000
Subject: [PATCH] Issue #1874300 by Berdir, swentel: Remove $entity_type
 argument from field.module functions that receive a single $entity.

---
 core/includes/entity.inc                      |   2 +-
 .../Core/Entity/DatabaseStorageController.php |   2 +-
 .../Entity/DatabaseStorageControllerNG.php    |   2 +-
 .../Core/Entity/EntityFormController.php      |   4 +-
 .../Core/Entity/EntityFormControllerNG.php    |   6 +-
 .../Core/Entity/EntityRenderController.php    |   2 +-
 core/modules/comment/comment.admin.inc        |   2 +-
 core/modules/comment/comment.module           |   4 +-
 core/modules/comment/comment.tokens.inc       |   4 +-
 .../edit/lib/Drupal/edit/EditController.php   |   4 +-
 .../lib/Drupal/edit/Form/EditFieldForm.php    |   6 +-
 .../lib/Drupal/email/Tests/EmailFieldTest.php |   2 +-
 core/modules/field/field.api.php              | 190 ++++++------------
 core/modules/field/field.attach.inc           | 173 +++++++---------
 core/modules/field/field.crud.inc             |  15 +-
 core/modules/field/field.default.inc          |  24 +--
 core/modules/field/field.module               |  56 +++---
 core/modules/field/field.multilingual.inc     |  12 +-
 .../Plugin/Type/Formatter/FormatterBase.php   |   2 +-
 .../field/Plugin/Type/Widget/WidgetBase.php   |   5 +-
 .../field/formatter/LegacyFormatter.php       |   2 +-
 .../Drupal/field/Plugin/views/field/Field.php |  20 +-
 .../lib/Drupal/field/Tests/BulkDeleteTest.php |   3 +-
 .../field/lib/Drupal/field/Tests/CrudTest.php |   4 +-
 .../lib/Drupal/field/Tests/DisplayApiTest.php |  20 +-
 .../field/Tests/FieldAttachOtherTest.php      |  53 +++--
 .../field/Tests/FieldAttachStorageTest.php    |  42 ++--
 .../lib/Drupal/field/Tests/FieldTestBase.php  |   5 +-
 .../field/lib/Drupal/field/Tests/FormTest.php |   2 +-
 .../Drupal/field/Tests/TranslationTest.php    |  16 +-
 .../modules/field_test/field_test.entity.inc  |  18 +-
 .../modules/field_test/field_test.field.inc   |  11 +-
 .../modules/field_test/field_test.module      |   6 +-
 .../modules/field_test/field_test.storage.inc |  25 +--
 .../Core/Entity/CacheableTestEntity.php       |   2 +
 .../field_sql_storage.module                  |  20 +-
 .../Tests/FieldSqlStorageTest.php             |  24 +--
 core/modules/field_ui/field_ui.admin.inc      |   2 +-
 core/modules/file/file.field.inc              |  21 +-
 core/modules/file/file.module                 |   2 +-
 core/modules/forum/forum.module               |   9 +-
 core/modules/image/image.field.inc            |  19 +-
 .../lib/Drupal/link/Tests/LinkFieldTest.php   |   2 +-
 core/modules/link/link.module                 |   8 +-
 core/modules/node/node.module                 |   2 +-
 core/modules/node/node.tokens.inc             |   4 +-
 core/modules/number/number.module             |   6 +-
 .../OptionsDynamicValuesValidationTest.php    |   4 +-
 core/modules/options/options.api.php          |   6 +-
 core/modules/options/options.module           |  30 ++-
 .../modules/options/tests/options_test.module |   6 +-
 core/modules/poll/poll.module                 |   5 +-
 core/modules/system/system.api.php            |   2 +-
 .../tests/modules/form_test/form_test.module  |   2 +-
 .../Plugin/views/argument_default/Tid.php     |   2 +-
 .../Tests/TermFieldMultipleVocabularyTest.php |   4 +-
 .../Drupal/taxonomy/Tests/TermFieldTest.php   |   6 +-
 core/modules/taxonomy/taxonomy.module         |  18 +-
 .../lib/Drupal/text/Tests/TextFieldTest.php   |   8 +-
 core/modules/text/text.module                 |   6 +-
 core/modules/translation/translation.module   |   2 +-
 .../translation_entity.admin.inc              |   4 +-
 .../Drupal/user/RegisterFormController.php    |   2 +-
 core/modules/user/user.pages.inc              |   2 +-
 64 files changed, 445 insertions(+), 529 deletions(-)

diff --git a/core/includes/entity.inc b/core/includes/entity.inc
index ea178465a280..808d07678e23 100644
--- a/core/includes/entity.inc
+++ b/core/includes/entity.inc
@@ -487,7 +487,7 @@ function entity_form_submit_build_entity($entity_type, $entity, $form, &$form_st
 
   // Copy field values to the entity.
   if ($info['fieldable']) {
-    field_attach_submit($entity_type, $entity, $form, $form_state);
+    field_attach_submit($entity, $form, $form_state);
   }
 }
 
diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
index a9f08abf45d4..5a5500953f77 100644
--- a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
+++ b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
@@ -653,7 +653,7 @@ protected function invokeHook($hook, EntityInterface $entity) {
       $function = 'field_attach_delete_revision';
     }
     if (!empty($this->entityInfo['fieldable']) && function_exists($function)) {
-      $function($this->entityType, $entity);
+      $function($entity);
     }
     // Invoke the hook.
     module_invoke_all($this->entityType . '_' . $hook, $entity);
diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php
index 5b538c895ebb..875b7a2d91e2 100644
--- a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php
+++ b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php
@@ -275,7 +275,7 @@ protected function invokeHook($hook, EntityInterface $entity) {
       $function = 'field_attach_delete_revision';
     }
     if (!empty($this->entityInfo['fieldable']) && function_exists($function)) {
-      $function($this->entityType, $entity->getBCEntity());
+      $function($entity->getBCEntity());
     }
 
     // Invoke the hook.
diff --git a/core/lib/Drupal/Core/Entity/EntityFormController.php b/core/lib/Drupal/Core/Entity/EntityFormController.php
index 4e0fc6a44e1f..0b3057e01d75 100644
--- a/core/lib/Drupal/Core/Entity/EntityFormController.php
+++ b/core/lib/Drupal/Core/Entity/EntityFormController.php
@@ -78,7 +78,7 @@ public function form(array $form, array &$form_state, EntityInterface $entity) {
     // entity properties.
     $info = $entity->entityInfo();
     if (!empty($info['fieldable'])) {
-      field_attach_form($entity->entityType(), $entity, $form, $form_state, $this->getFormLangcode($form_state));
+      field_attach_form($entity, $form, $form_state, $this->getFormLangcode($form_state));
     }
     return $form;
   }
@@ -160,7 +160,7 @@ public function validate(array $form, array &$form_state) {
     $info = $entity->entityInfo();
 
     if (!empty($info['fieldable'])) {
-      field_attach_form_validate($entity->entityType(), $entity, $form, $form_state);
+      field_attach_form_validate($entity, $form, $form_state);
     }
 
     // @todo Remove this.
diff --git a/core/lib/Drupal/Core/Entity/EntityFormControllerNG.php b/core/lib/Drupal/Core/Entity/EntityFormControllerNG.php
index 51bc911bb710..53667a501df3 100644
--- a/core/lib/Drupal/Core/Entity/EntityFormControllerNG.php
+++ b/core/lib/Drupal/Core/Entity/EntityFormControllerNG.php
@@ -23,7 +23,7 @@ public function form(array $form, array &$form_state, EntityInterface $entity) {
     // entity properties.
     $info = $entity->entityInfo();
     if (!empty($info['fieldable'])) {
-      field_attach_form($entity->entityType(), $entity->getBCEntity(), $form, $form_state, $this->getFormLangcode($form_state));
+      field_attach_form($entity->getBCEntity(), $form, $form_state, $this->getFormLangcode($form_state));
     }
     return $form;
   }
@@ -38,7 +38,7 @@ public function validate(array $form, array &$form_state) {
     $info = $entity->entityInfo();
 
     if (!empty($info['fieldable'])) {
-      field_attach_form_validate($entity->entityType(), $entity->getBCEntity(), $form, $form_state);
+      field_attach_form_validate($entity->getBCEntity(), $form, $form_state);
     }
 
     // @todo Remove this.
@@ -78,7 +78,7 @@ public function buildEntity(array $form, array &$form_state) {
 
     // Copy field values to the entity.
     if ($info['fieldable']) {
-      field_attach_submit($entity_type, $entity->getBCEntity(), $form, $form_state);
+      field_attach_submit($entity->getBCEntity(), $form, $form_state);
     }
     return $entity;
   }
diff --git a/core/lib/Drupal/Core/Entity/EntityRenderController.php b/core/lib/Drupal/Core/Entity/EntityRenderController.php
index f942ae0230ff..c839031bfba1 100644
--- a/core/lib/Drupal/Core/Entity/EntityRenderController.php
+++ b/core/lib/Drupal/Core/Entity/EntityRenderController.php
@@ -72,7 +72,7 @@ public function buildContent(array $entities = array(), $view_mode = 'full', $la
       module_invoke_all('entity_prepare_view', $view_mode_entities, $this->entityType);
 
       foreach ($view_mode_entities as $entity) {
-        $entity->content += field_attach_view($this->entityType, $entity, $displays[$view_mode][$entity->bundle()], $langcode);
+        $entity->content += field_attach_view($entity, $displays[$view_mode][$entity->bundle()], $langcode);
       }
     }
   }
diff --git a/core/modules/comment/comment.admin.inc b/core/modules/comment/comment.admin.inc
index b81fed31269b..c71d578d5ed2 100644
--- a/core/modules/comment/comment.admin.inc
+++ b/core/modules/comment/comment.admin.inc
@@ -110,7 +110,7 @@ function comment_admin_overview($form, &$form_state, $arg) {
     // Remove the first node title from the node_titles array and attach to
     // the comment.
     $comment->node_title = array_shift($node_titles);
-    $comment_body = field_get_items('comment', $comment, 'comment_body');
+    $comment_body = field_get_items($comment, 'comment_body');
     $options[$comment->cid] = array(
       'subject' => array(
         'data' => array(
diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index 9c300ab06ec0..41af61d97a84 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -1539,7 +1539,7 @@ function comment_preview(Comment $comment) {
   $preview_build = array();
 
   if (!form_get_errors()) {
-    $comment_body = field_get_items('comment', $comment, 'comment_body');
+    $comment_body = field_get_items($comment, 'comment_body');
     $comment->format = $comment_body[0]['format'];
     // Attach the user and time information.
     if (!empty($comment->name)) {
@@ -1665,7 +1665,7 @@ function template_preprocess_comment(&$variables) {
   }
 
   // Preprocess fields.
-  field_attach_preprocess('comment', $comment, $variables['elements'], $variables);
+  field_attach_preprocess($comment, $variables['elements'], $variables);
 
   // Helpful $content variable for templates.
   foreach (element_children($variables['elements']) as $key) {
diff --git a/core/modules/comment/comment.tokens.inc b/core/modules/comment/comment.tokens.inc
index c77cb677a1c1..826e56366cf4 100644
--- a/core/modules/comment/comment.tokens.inc
+++ b/core/modules/comment/comment.tokens.inc
@@ -155,9 +155,9 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
           break;
 
         case 'body':
-          if ($items = field_get_items('comment', $comment, 'comment_body', $langcode)) {
+          if ($items = field_get_items($comment, 'comment_body', $langcode)) {
             $instance = field_info_instance('comment', 'body', 'comment_body');
-            $field_langcode = field_language('comment', $comment, 'comment_body', $langcode);
+            $field_langcode = field_language($comment, 'comment_body', $langcode);
             $replacements[$original] = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], 'value') : $items[0]['value'];
           }
           break;
diff --git a/core/modules/edit/lib/Drupal/edit/EditController.php b/core/modules/edit/lib/Drupal/edit/EditController.php
index 5d6f8edd181b..7b33ffee4aed 100644
--- a/core/modules/edit/lib/Drupal/edit/EditController.php
+++ b/core/modules/edit/lib/Drupal/edit/EditController.php
@@ -95,7 +95,7 @@ public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view
       // The form submission took care of saving the updated entity. Return the
       // updated view of the field.
       $entity = $form_state['entity'];
-      $output = field_view_field($entity->entityType(), $entity, $field_name, $view_mode, $langcode);
+      $output = field_view_field($entity, $field_name, $view_mode, $langcode);
 
       $response->addCommand(new FieldFormSavedCommand(drupal_render($output)));
     }
@@ -135,7 +135,7 @@ public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view
   public function getUntransformedText(EntityInterface $entity, $field_name, $langcode, $view_mode) {
     $response = new AjaxResponse();
 
-    $output = field_view_field($entity->entityType(), $entity, $field_name, $view_mode, $langcode);
+    $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));
diff --git a/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php b/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php
index 0f451f51ce41..148404b2941a 100644
--- a/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php
+++ b/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php
@@ -23,7 +23,7 @@ public function build(array $form, array &$form_state, EntityInterface $entity,
     }
 
     // Add the field form.
-    field_attach_form($form_state['entity']->entityType(), $form_state['entity'], $form, $form_state, $form_state['langcode'], array('field_name' =>  $form_state['field_name']));
+    field_attach_form($form_state['entity'], $form, $form_state, $form_state['langcode'], array('field_name' =>  $form_state['field_name']));
 
     // Add a submit button. Give it a class for easy JavaScript targeting.
     $form['actions'] = array('#type' => 'actions');
@@ -63,7 +63,7 @@ protected function init(array &$form_state, EntityInterface $entity, $field_name
    */
   public function validate(array $form, array &$form_state) {
     $entity = $this->buildEntity($form, $form_state);
-    field_attach_form_validate($entity->entityType(), $entity, $form, $form_state, array('field_name' =>  $form_state['field_name']));
+    field_attach_form_validate($entity, $form, $form_state, array('field_name' =>  $form_state['field_name']));
   }
 
   /**
@@ -86,7 +86,7 @@ protected function buildEntity(array $form, array &$form_state) {
     // @todo field_attach_submit() only "submits" to the in-memory $entity
     //   object, not to anywhere persistent. Consider renaming it to minimize
     //   confusion: http://drupal.org/node/1846648.
-    field_attach_submit($entity->entityType(), $entity, $form, $form_state, array('field_name' =>  $form_state['field_name']));
+    field_attach_submit($entity, $form, $form_state, array('field_name' =>  $form_state['field_name']));
 
     // @todo Refine automated log messages and abstract them to all entity
     //   types: http://drupal.org/node/1678002.
diff --git a/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php b/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php
index 37d4ee58f1f1..c719c9792a54 100644
--- a/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php
+++ b/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php
@@ -89,7 +89,7 @@ function testEmailField() {
     // Verify that a mailto link is displayed.
     $entity = field_test_entity_test_load($id);
     $display = entity_get_display($entity->entityType(), $entity->bundle(), 'full');
-    $entity->content = field_attach_view('test_entity', $entity, $display);
+    $entity->content = field_attach_view($entity, $display);
     $this->drupalSetContent(drupal_render($entity->content));
     $this->assertLinkByHref('mailto:test@example.com');
   }
diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php
index c97c6ef4d9a3..c71836bca8cc 100644
--- a/core/modules/field/field.api.php
+++ b/core/modules/field/field.api.php
@@ -365,9 +365,7 @@ function hook_field_prepare_view($entity_type, $entities, $field, $instances, $l
  * If there are validation problems, add to the $errors array (passed by
  * reference). There is no return value.
  *
- * @param $entity_type
- *   The type of $entity.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity for the operation.
  * @param $field
  *   The field structure for the operation.
@@ -385,7 +383,7 @@ function hook_field_prepare_view($entity_type, $entities, $field, $instances, $l
  *   - error: An error code (should be a string prefixed with the module name).
  *   - message: The human-readable message to be displayed.
  */
-function hook_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
+function hook_field_validate(\Drupal\Core\Entity\EntityInterface $entity = NULL, $field, $instance, $langcode, $items, &$errors) {
   foreach ($items as $delta => $item) {
     if (!empty($item['value'])) {
       if (!empty($field['settings']['max_length']) && drupal_strlen($item['value']) > $field['settings']['max_length']) {
@@ -404,9 +402,7 @@ function hook_field_validate($entity_type, $entity, $field, $instance, $langcode
  * Make changes or additions to field values by altering the $items parameter by
  * reference. There is no return value.
  *
- * @param $entity_type
- *   The type of $entity.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity for the operation.
  * @param $field
  *   The field structure for the operation.
@@ -417,7 +413,7 @@ function hook_field_validate($entity_type, $entity, $field, $instance, $langcode
  * @param $items
  *   $entity->{$field['field_name']}[$langcode], or an empty array if unset.
  */
-function hook_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
+function hook_field_presave(\Drupal\Core\Entity\EntityInterface $entity, $field, $instance, $langcode, &$items) {
   if ($field['type'] == 'number_decimal') {
     // Let PHP round the value to ensure consistent behavior across storage
     // backends.
@@ -439,9 +435,7 @@ function hook_field_presave($entity_type, $entity, $field, $instance, $langcode,
  * storing or tracking information outside the standard field storage mechanism
  * need to implement this hook.
  *
- * @param $entity_type
- *   The type of $entity.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity for the operation.
  * @param $field
  *   The field structure for the operation.
@@ -455,8 +449,8 @@ function hook_field_presave($entity_type, $entity, $field, $instance, $langcode,
  * @see hook_field_update()
  * @see hook_field_delete()
  */
-function hook_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
-  if (config('taxonomy.settings')->get('maintain_index_table') && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node' && $entity->status) {
+function hook_field_insert(\Drupal\Core\Entity\EntityInterface $entity, $field, $instance, $langcode, &$items) {
+  if (config('taxonomy.settings')->get('maintain_index_table') && $field['storage']['type'] == 'field_sql_storage' && $entity->entityType() == 'node' && $entity->status) {
     $query = db_insert('taxonomy_index')->fields(array('nid', 'tid', 'sticky', 'created', ));
     foreach ($items as $item) {
       $query->values(array(
@@ -480,9 +474,7 @@ function hook_field_insert($entity_type, $entity, $field, $instance, $langcode,
  * storing or tracking information outside the standard field storage mechanism
  * need to implement this hook.
  *
- * @param $entity_type
- *   The type of $entity.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity for the operation.
  * @param $field
  *   The field structure for the operation.
@@ -496,8 +488,8 @@ function hook_field_insert($entity_type, $entity, $field, $instance, $langcode,
  * @see hook_field_insert()
  * @see hook_field_delete()
  */
-function hook_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) {
-  if (config('taxonomy.settings')->get('maintain_index_table') && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node') {
+function hook_field_update(\Drupal\Core\Entity\EntityInterface $entity, $field, $instance, $langcode, &$items) {
+  if (config('taxonomy.settings')->get('maintain_index_table') && $field['storage']['type'] == 'field_sql_storage' && $entity->entityType() == 'node') {
     $first_call = &drupal_static(__FUNCTION__, array());
 
     // We don't maintain data for old revisions, so clear all previous values
@@ -569,9 +561,7 @@ function hook_field_storage_update_field($field, $prior_field, $has_data) {
  * storing or tracking information outside the standard field storage mechanism
  * need to implement this hook.
  *
- * @param $entity_type
- *   The type of $entity.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity for the operation.
  * @param $field
  *   The field structure for the operation.
@@ -585,15 +575,10 @@ function hook_field_storage_update_field($field, $prior_field, $has_data) {
  * @see hook_field_insert()
  * @see hook_field_update()
  */
-function hook_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) {
+function hook_field_delete(\Drupal\Core\Entity\EntityInterface $entity, $field, $instance, $langcode, &$items) {
+  // Delete all file usages within this entity.
   foreach ($items as $delta => $item) {
-    // For hook_file_references(), remember that this is being deleted.
-    $item['file_field_name'] = $field['field_name'];
-    // Pass in the ID of the object that is being removed so all references can
-    // be counted in hook_file_references().
-    $item['file_field_type'] = $entity_type;
-    $item['file_field_id'] = $entity->id();
-    file_field_delete_file($item, $field, $entity_type, $entity->id());
+    file_usage()->delete(file_load($item['fid']), 'file', $entity->entityType(), $entity->id(), 0);
   }
 }
 
@@ -604,9 +589,7 @@ function hook_field_delete($entity_type, $entity, $field, $instance, $langcode,
  * field_attach_delete_revision(), and will only be called for fieldable types
  * that are versioned.
  *
- * @param $entity_type
- *   The type of $entity.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity for the operation.
  * @param $field
  *   The field structure for the operation.
@@ -617,22 +600,17 @@ function hook_field_delete($entity_type, $entity, $field, $instance, $langcode,
  * @param $items
  *   $entity->{$field['field_name']}[$langcode], or an empty array if unset.
  */
-function hook_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items) {
+function hook_field_delete_revision(\Drupal\Core\Entity\EntityInterface $entity, $field, $instance, $langcode, &$items) {
   foreach ($items as $delta => $item) {
-    // For hook_file_references, remember that this file is being deleted.
-    $item['file_field_name'] = $field['field_name'];
-    if (file_field_delete_file($item, $field, $entity_type, $entity->id())) {
-      $items[$delta] = NULL;
-    }
+    // Decrement the file usage count by 1.
+    file_usage()->delete(file_load($item['fid']), 'file', $entity->entityType(), $entity->id());
   }
 }
 
 /**
  * Define custom prepare_translation behavior for this module's field types.
  *
- * @param $entity_type
- *   The type of $entity.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity for the operation.
  * @param $field
  *   The field structure for the operation.
@@ -647,7 +625,7 @@ function hook_field_delete_revision($entity_type, $entity, $field, $instance, $l
  * @param $source_langcode
  *   The source language from which field values are being copied.
  */
-function hook_field_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) {
+function hook_field_prepare_translation(\Drupal\Core\Entity\EntityInterface $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) {
   // If the translating user is not permitted to use the assigned text format,
   // we must not expose the source values.
   $field_name = $field['field_name'];
@@ -883,9 +861,7 @@ function hook_field_formatter_info_alter(array &$info) {
  * This hook is invoked after the field module has performed the operation.
  * Implementing modules should alter the $form or $form_state parameters.
  *
- * @param $entity_type
- *   The type of $entity; for example, 'node' or 'user'.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity for which an edit form is being built.
  * @param $form
  *   The form structure field elements are attached to. This might be a full
@@ -901,7 +877,7 @@ function hook_field_formatter_info_alter(array &$info) {
  *   The language the field values are going to be entered in. If no language is
  *   provided the default site language will be used.
  */
-function hook_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
+function hook_field_attach_form(\Drupal\Core\Entity\EntityInterface $entity, &$form, &$form_state, $langcode) {
   // Add a checkbox allowing a given field to be emptied.
   // See hook_field_attach_submit() for the corresponding processing code.
   $form['empty_field_foo'] = array(
@@ -934,9 +910,7 @@ function hook_field_attach_load($entity_type, $entities, $age, $options) {
  *
  * This hook is invoked after the field module has performed the operation.
  *
- * @param $entity_type
- *   The type of $entity; e.g. 'node' or 'user'.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity with fields to validate.
  * @param $errors
  *   The array of errors (keyed by field name, language code, and delta) that
@@ -946,7 +920,7 @@ function hook_field_attach_load($entity_type, $entities, $age, $options) {
  *   - error: An error code (should be a string prefixed with the module name).
  *   - message: The human-readable message to be displayed.
  */
-function hook_field_attach_validate($entity_type, $entity, &$errors) {
+function hook_field_attach_validate(\Drupal\Core\Entity\EntityInterface $entity, &$errors) {
   // @todo Needs function body.
 }
 
@@ -955,9 +929,7 @@ function hook_field_attach_validate($entity_type, $entity, &$errors) {
  *
  * This hook is invoked after the field module has performed the operation.
  *
- * @param $entity_type
- *   The type of $entity; for example, 'node' or 'user'.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity for which an edit form is being submitted. The incoming form
  *   values have been extracted as field values of the $entity object.
  * @param $form
@@ -968,7 +940,7 @@ function hook_field_attach_validate($entity_type, $entity, &$errors) {
  * @param $form_state
  *   An associative array containing the current state of the form.
  */
-function hook_field_attach_submit($entity_type, $entity, $form, &$form_state) {
+function hook_field_attach_submit(\Drupal\Core\Entity\EntityInterface $entity, $form, &$form_state) {
   // Sample case of an 'Empty the field' checkbox added on the form, allowing
   // a given field to be emptied.
   $values = NestedArray::getValue($form_state['values'], $form['#parents']);
@@ -982,12 +954,10 @@ function hook_field_attach_submit($entity_type, $entity, $form, &$form_state) {
  *
  * This hook is invoked after the field module has performed the operation.
  *
- * @param $entity_type
- *   The type of $entity; e.g. 'node' or 'user'.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   the entity with fields to process.
  */
-function hook_field_attach_presave($entity_type, $entity) {
+function hook_field_attach_presave(\Drupal\Core\Entity\EntityInterface $entity) {
   // @todo Needs function body.
 }
 
@@ -996,12 +966,10 @@ function hook_field_attach_presave($entity_type, $entity) {
  *
  * This hook is invoked after the field module has performed the operation.
  *
- * @param $entity_type
- *   The type of $entity; e.g. 'node' or 'user'.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   the entity with fields to process.
  */
-function hook_field_attach_insert($entity_type, $entity) {
+function hook_field_attach_insert(\Drupal\Core\Entity\EntityInterface $entity) {
   // @todo Needs function body.
 }
 
@@ -1010,12 +978,10 @@ function hook_field_attach_insert($entity_type, $entity) {
  *
  * This hook is invoked after the field module has performed the operation.
  *
- * @param $entity_type
- *   The type of $entity; e.g. 'node' or 'user'.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   the entity with fields to process.
  */
-function hook_field_attach_update($entity_type, $entity) {
+function hook_field_attach_update(\Drupal\Core\Entity\EntityInterface $entity) {
   // @todo Needs function body.
 }
 
@@ -1030,7 +996,6 @@ function hook_field_attach_update($entity_type, $entity) {
  *   values.
  * @param $context
  *   An associative array containing:
- *   - entity_type: The type of $entity; for example, 'node' or 'user'.
  *   - entity: The entity with fields to render.
  *   - element: The structured array containing the values ready for rendering.
  */
@@ -1043,12 +1008,10 @@ function hook_field_attach_preprocess_alter(&$variables, $context) {
  *
  * This hook is invoked after the field module has performed the operation.
  *
- * @param $entity_type
- *   The type of $entity; e.g. 'node' or 'user'.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   the entity with fields to process.
  */
-function hook_field_attach_delete($entity_type, $entity) {
+function hook_field_attach_delete(\Drupal\Core\Entity\EntityInterface $entity) {
   // @todo Needs function body.
 }
 
@@ -1057,12 +1020,10 @@ function hook_field_attach_delete($entity_type, $entity) {
  *
  * This hook is invoked after the field module has performed the operation.
  *
- * @param $entity_type
- *   The type of $entity; e.g. 'node' or 'user'.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   the entity with fields to process.
  */
-function hook_field_attach_delete_revision($entity_type, $entity) {
+function hook_field_attach_delete_revision(\Drupal\Core\Entity\EntityInterface $entity) {
   // @todo Needs function body.
 }
 
@@ -1074,9 +1035,7 @@ function hook_field_attach_delete_revision($entity_type, $entity) {
  * relates data in the field with its own data, it may purge its own data during
  * this process as well.
  *
- * @param $entity_type
- *   The type of $entity; for example, 'node' or 'user'.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The pseudo-entity whose field data is being purged.
  * @param $field
  *   The (possibly deleted) field whose data is being purged.
@@ -1086,9 +1045,9 @@ function hook_field_attach_delete_revision($entity_type, $entity) {
  * @see @link field_purge Field API bulk data deletion @endlink
  * @see field_purge_data()
  */
-function hook_field_attach_purge($entity_type, $entity, $field, $instance) {
+function hook_field_attach_purge(\Drupal\Core\Entity\EntityInterface $entity, $field, $instance) {
   // find the corresponding data in mymodule and purge it
-  if ($entity_type == 'node' && $field->field_name == 'my_field_name') {
+  if ($entity->entityType() == 'node' && $field->field_name == 'my_field_name') {
     mymodule_remove_mydata($entity->nid);
   }
 }
@@ -1102,7 +1061,6 @@ function hook_field_attach_purge($entity_type, $entity, $field, $instance) {
  *   The structured content array tree for all of the entity's fields.
  * @param $context
  *   An associative array containing:
- *   - entity_type: The type of $entity; for example, 'node' or 'user'.
  *   - entity: The entity with fields to render.
  *   - view_mode: View mode; for example, 'full' or 'teaser'.
  *   - display_options: Either a view mode string or an array of display
@@ -1137,17 +1095,16 @@ function hook_field_attach_view_alter(&$output, $context) {
  *
  * This hook is invoked after the field module has performed the operation.
  *
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity being prepared for translation.
  * @param $context
  *   An associative array containing:
- *   - entity_type: The type of $entity; e.g. 'node' or 'user'.
  *   - langcode: The language the entity will be translated to.
  *   - source_entity: The entity holding the field values to be translated.
  *   - source_langcode: The source language from which to translate.
  */
-function hook_field_attach_prepare_translation_alter(&$entity, $context) {
-  if ($context['entity_type'] == 'custom_entity_type') {
+function hook_field_attach_prepare_translation_alter(\Drupal\Core\Entity\EntityInterface $entity, $context) {
+  if ($entity->entityType() == 'custom_entity_type') {
     $entity->custom_field = $context['source_entity']->custom_field;
   }
 }
@@ -1162,14 +1119,13 @@ function hook_field_attach_prepare_translation_alter(&$entity, $context) {
  *   A reference to an array of language codes keyed by field name.
  * @param $context
  *   An associative array containing:
- *   - entity_type: The type of the entity to be displayed.
  *   - entity: The entity with fields to render.
  *   - langcode: The language code $entity has to be displayed in.
  */
 function hook_field_language_alter(&$display_langcode, $context) {
   // Do not apply core language fallback rules if they are disabled or if Locale
   // is not registered as a translation handler.
-  if (variable_get('field_language_fallback', TRUE) && field_has_translation_handler($context['entity_type'])) {
+  if (variable_get('field_language_fallback', TRUE) && field_has_translation_handler($context['entity']->entityType())) {
     field_language_fallback($display_langcode, $context['entity'], $context['langcode']);
   }
 }
@@ -1456,9 +1412,7 @@ function hook_field_storage_load($entity_type, $entities, $age, $fields, $option
  * This hook is invoked from field_attach_insert() and field_attach_update(), to
  * ask the field storage module to save field data.
  *
- * @param $entity_type
- *   The entity type of entity, such as 'node' or 'user'.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity on which to operate.
  * @param $op
  *   FIELD_STORAGE_UPDATE when updating an existing entity,
@@ -1467,7 +1421,7 @@ function hook_field_storage_load($entity_type, $entities, $age, $fields, $option
  *   An array listing the fields to be written. The keys and values of the
  *   array are field IDs.
  */
-function hook_field_storage_write($entity_type, $entity, $op, $fields) {
+function hook_field_storage_write(\Drupal\Core\Entity\EntityInterface $entity, $op, $fields) {
   $id = $entity->id();
   $vid = $entity->getRevisionId();
   $bundle = $entity->bundle();
@@ -1481,7 +1435,7 @@ function hook_field_storage_write($entity_type, $entity, $op, $fields) {
     $table_name = _field_sql_storage_tablename($field);
     $revision_name = _field_sql_storage_revision_tablename($field);
 
-    $all_langcodes = field_available_languages($entity_type, $field);
+    $all_langcodes = field_available_languages($entity->entityType(), $field);
     $field_langcodes = array_intersect($all_langcodes, array_keys((array) $entity->$field_name));
 
     // Delete and insert, rather than update, in case a value was added.
@@ -1491,12 +1445,12 @@ function hook_field_storage_write($entity_type, $entity, $op, $fields) {
       $langcodes = !empty($entity->$field_name) ? $field_langcodes : $all_langcodes;
       if ($langcodes) {
         db_delete($table_name)
-          ->condition('entity_type', $entity_type)
+          ->condition('entity_type', $entity->entityType())
           ->condition('entity_id', $id)
           ->condition('langcode', $langcodes, 'IN')
           ->execute();
         db_delete($revision_name)
-          ->condition('entity_type', $entity_type)
+          ->condition('entity_type', $entity->entityType())
           ->condition('entity_id', $id)
           ->condition('revision_id', $vid)
           ->condition('langcode', $langcodes, 'IN')
@@ -1520,7 +1474,7 @@ function hook_field_storage_write($entity_type, $entity, $op, $fields) {
         // We now know we have someting to insert.
         $do_insert = TRUE;
         $record = array(
-          'entity_type' => $entity_type,
+          'entity_type' => $entity->entityType(),
           'entity_id' => $id,
           'revision_id' => $vid,
           'bundle' => $bundle,
@@ -1555,19 +1509,17 @@ function hook_field_storage_write($entity_type, $entity, $op, $fields) {
  * This hook is invoked from field_attach_delete() to ask the field storage
  * module to delete field data.
  *
- * @param $entity_type
- *   The entity type of entity, such as 'node' or 'user'.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity on which to operate.
  * @param $fields
  *   An array listing the fields to delete. The keys and values of the
  *   array are field IDs.
  */
-function hook_field_storage_delete($entity_type, $entity, $fields) {
-  foreach (field_info_instances($entity_type, $entity->bundle()) as $instance) {
+function hook_field_storage_delete(\Drupal\Core\Entity\EntityInterface $entity, $fields) {
+  foreach (field_info_instances($entity->entityType(), $entity->bundle()) as $instance) {
     if (isset($fields[$instance['field_id']])) {
       $field = field_info_field_by_id($instance['field_id']);
-      field_sql_storage_field_storage_purge($entity_type, $entity, $field, $instance);
+      field_sql_storage_field_storage_purge($entity, $field, $instance);
     }
   }
 }
@@ -1581,17 +1533,13 @@ function hook_field_storage_delete($entity_type, $entity, $fields) {
  * Deleting the current (most recently written) revision is not
  * allowed as has undefined results.
  *
- * @param $entity_type
- *   The entity type of entity, such as 'node' or 'user'.
- * @param $entity
- *   The entity on which to operate. The revision to delete is
- *   indicated by the entity's revision ID property, as identified by
- *   hook_fieldable_info() for $entity_type.
+ * @param \Drupal\Core\Entity\EntityInterface $entity
+ *   The entity on which to operate.
  * @param $fields
  *   An array listing the fields to delete. The keys and values of the
  *   array are field IDs.
  */
-function hook_field_storage_delete_revision($entity_type, $entity, $fields) {
+function hook_field_storage_delete_revision(\Drupal\Core\Entity\EntityInterface $entity, $fields) {
   $vid = $entity->getRevisionId();
   if (isset($vid)) {
     foreach ($fields as $field_id) {
@@ -1833,9 +1781,7 @@ function hook_field_storage_pre_load($entity_type, $entities, $age, &$skip_field
  * This hook allows modules to store data before the Field Storage API,
  * optionally preventing the field storage module from doing so.
  *
- * @param $entity_type
- *   The type of $entity; for example, 'node' or 'user'.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity with fields to save.
  * @param $skip_fields
  *   An array keyed by field IDs whose data has already been written and
@@ -1844,8 +1790,8 @@ function hook_field_storage_pre_load($entity_type, $entities, $age, &$skip_field
  * @return
  *   Saved field IDs are set set as keys in $skip_fields.
  */
-function hook_field_storage_pre_insert($entity_type, $entity, &$skip_fields) {
-  if ($entity_type == 'node' && $entity->status && _forum_node_check_node_type($entity)) {
+function hook_field_storage_pre_insert(\Drupal\Core\Entity\EntityInterface $entity, &$skip_fields) {
+  if ($entity->entityType() == 'node' && $entity->status && _forum_node_check_node_type($entity)) {
     $query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp'));
     foreach ($entity->taxonomy_forums as $language) {
       foreach ($language as $delta) {
@@ -1870,9 +1816,7 @@ function hook_field_storage_pre_insert($entity_type, $entity, &$skip_fields) {
  * This hook allows modules to store data before the Field Storage API,
  * optionally preventing the field storage module from doing so.
  *
- * @param $entity_type
- *   The type of $entity; for example, 'node' or 'user'.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity with fields to save.
  * @param $skip_fields
  *   An array keyed by field IDs whose data has already been written and
@@ -1881,10 +1825,10 @@ function hook_field_storage_pre_insert($entity_type, $entity, &$skip_fields) {
  * @return
  *   Saved field IDs are set set as keys in $skip_fields.
  */
-function hook_field_storage_pre_update($entity_type, $entity, &$skip_fields) {
+function hook_field_storage_pre_update(\Drupal\Core\Entity\EntityInterface $entity, &$skip_fields) {
   $first_call = &drupal_static(__FUNCTION__, array());
 
-  if ($entity_type == 'node' && $entity->status && _forum_node_check_node_type($entity)) {
+  if ($entity->entityType() == 'node' && $entity->status && _forum_node_check_node_type($entity)) {
     // We don't maintain data for old revisions, so clear all previous values
     // from the table. Since this hook runs once per field, per entity, make
     // sure we only wipe values once.
@@ -2204,24 +2148,22 @@ function hook_field_storage_purge_field_instance($instance) {
  * Called from field_purge_data() to allow the field storage module to delete
  * field data information.
  *
- * @param $entity_type
- *   The type of $entity; for example, 'node' or 'user'.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The pseudo-entity whose field data to delete.
  * @param $field
  *   The (possibly deleted) field whose data is being purged.
  * @param $instance
  *   The deleted field instance whose data is being purged.
  */
-function hook_field_storage_purge($entity_type, $entity, $field, $instance) {
+function hook_field_storage_purge(\Drupal\Core\Entity\EntityInterface $entity, $field, $instance) {
   $table_name = _field_sql_storage_tablename($field);
   $revision_name = _field_sql_storage_revision_tablename($field);
   db_delete($table_name)
-    ->condition('entity_type', $entity_type)
+    ->condition('entity_type', $entity->entityType())
     ->condition('entity_id', $entity->id())
     ->execute();
   db_delete($revision_name)
-    ->condition('entity_type', $entity_type)
+    ->condition('entity_type', $entity->entityType())
     ->condition('entity_id', $entity->id())
     ->execute();
 }
diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc
index 1a006ec5118f..32a8c3792b84 100644
--- a/core/modules/field/field.attach.inc
+++ b/core/modules/field/field.attach.inc
@@ -348,10 +348,8 @@ function field_invoke_method_multiple($method, $target_function, array $entities
  *   - delete revision
  *   - view
  *   - prepare translation
- * @param $entity_type
- *   The type of $entity; e.g. 'node' or 'user'.
- * @param Drupal\Core\Entity\EntityInterface $entity
- *   The fully formed $entity_type entity.
+ * @param \Drupal\Core\Entity\EntityInterface $entity
+ *   The entity object.
  * @param $a
  *   - The $form in the 'form' operation.
  *   - The value of $view_mode in the 'view' operation.
@@ -384,7 +382,7 @@ function field_invoke_method_multiple($method, $target_function, array $entities
  *    name. It will be used to narrow down to a single value the available
  *    languages to act on.
  */
-function _field_invoke($op, $entity_type, EntityInterface $entity, &$a = NULL, &$b = NULL, $options = array()) {
+function _field_invoke($op, EntityInterface $entity, &$a = NULL, &$b = NULL, $options = array()) {
   // Merge default options.
   $default_options = array(
     'default' => FALSE,
@@ -394,7 +392,7 @@ function _field_invoke($op, $entity_type, EntityInterface $entity, &$a = NULL, &
   $options += $default_options;
 
   // Determine the list of instances to iterate on.
-  $instances = _field_invoke_get_instances($entity_type, $entity->bundle(), $options);
+  $instances = _field_invoke_get_instances($entity->entityType(), $entity->bundle(), $options);
 
   // Iterate through the instances and collect results.
   $return = array();
@@ -406,12 +404,12 @@ function _field_invoke($op, $entity_type, EntityInterface $entity, &$a = NULL, &
     $function = $options['default'] ? 'field_default_' . $op : $field['module'] . '_field_' . $op;
     if (function_exists($function)) {
       // Determine the list of languages to iterate on.
-      $available_langcodes = field_available_languages($entity_type, $field);
+      $available_langcodes = field_available_languages($entity->entityType(), $field);
       $langcodes = _field_language_suggestion($available_langcodes, $options['langcode'], $field_name);
 
       foreach ($langcodes as $langcode) {
         $items = isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : array();
-        $result = $function($entity_type, $entity, $field, $instance, $langcode, $items, $a, $b);
+        $result = $function($entity, $field, $instance, $langcode, $items, $a, $b);
         if (isset($result)) {
           // For hooks with array results, we merge results together.
           // For hooks with scalar results, we collect results in an array.
@@ -585,9 +583,9 @@ function _field_invoke_multiple($op, $entity_type, $entities, &$a = NULL, &$b =
  *
  * @see _field_invoke()
  */
-function _field_invoke_default($op, $entity_type, EntityInterface $entity, &$a = NULL, &$b = NULL, $options = array()) {
+function _field_invoke_default($op, EntityInterface $entity, &$a = NULL, &$b = NULL, $options = array()) {
   $options['default'] = TRUE;
-  return _field_invoke($op, $entity_type, $entity, $a, $b, $options);
+  return _field_invoke($op, $entity, $a, $b, $options);
 }
 
 /**
@@ -801,9 +799,7 @@ function _field_invoke_widget_target() {
  * Additionally, some processing data is placed in $form_state, and can be
  * accessed by field_form_get_state() and field_form_set_state().
  *
- * @param $entity_type
- *   The type of $entity; e.g. 'node' or 'user'.
- * @param Drupal\Core\Entity\EntityInterface $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity for which to load form elements, used to initialize
  *   default form values.
  * @param $form
@@ -824,7 +820,7 @@ function _field_invoke_widget_target() {
  * @see field_form_get_state()
  * @see field_form_set_state()
  */
-function field_attach_form($entity_type, EntityInterface $entity, &$form, &$form_state, $langcode = NULL, array $options = array()) {
+function field_attach_form(EntityInterface $entity, &$form, &$form_state, $langcode = NULL, array $options = array()) {
   // Set #parents to 'top-level' by default.
   $form += array('#parents' => array());
 
@@ -834,14 +830,14 @@ function field_attach_form($entity_type, EntityInterface $entity, &$form, &$form
 
   // Add custom weight handling.
   $form['#pre_render'][] = '_field_extra_fields_pre_render';
-  $form['#entity_type'] = $entity_type;
+  $form['#entity_type'] = $entity->entityType();
   $form['#bundle'] = $entity->bundle();
 
   // Let other modules make changes to the form.
   // Avoid module_invoke_all() to let parameters be taken by reference.
   foreach (module_implements('field_attach_form') as $module) {
     $function = $module . '_field_attach_form';
-    $function($entity_type, $entity, $form, $form_state, $langcode);
+    $function($entity, $form, $form_state, $langcode);
   }
 }
 
@@ -1021,9 +1017,7 @@ function field_attach_load_revision($entity_type, $entities, $options = array())
  * It is intended to be called during API save operations. Use
  * field_attach_form_validate() to validate form submissions.
  *
- * @param $entity_type
- *   The type of $entity; e.g. 'node' or 'user'.
- * @param Drupal\Core\Entity\EntityInterface $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity with fields to validate.
  * @throws Drupal\field\FieldValidationException
  *   If validation errors are found, a FieldValidationException is thrown. The
@@ -1033,19 +1027,19 @@ function field_attach_load_revision($entity_type, $entities, $options = array())
  *   An associative array of additional options. See field_invoke_method() for
  *   details.
  */
-function field_attach_validate($entity_type, $entity, array $options = array()) {
+function field_attach_validate(EntityInterface $entity, array $options = array()) {
   $errors = array();
   // Check generic, field-type-agnostic errors first.
   $null = NULL;
-  _field_invoke_default('validate', $entity_type, $entity, $errors, $null, $options);
+  _field_invoke_default('validate', $entity, $errors, $null, $options);
   // Check field-type specific errors.
-  _field_invoke('validate', $entity_type, $entity, $errors, $null, $options);
+  _field_invoke('validate', $entity, $errors, $null, $options);
 
   // Let other modules validate the entity.
   // Avoid module_invoke_all() to let $errors be taken by reference.
   foreach (module_implements('field_attach_validate') as $module) {
     $function = $module . '_field_attach_validate';
-    $function($entity_type, $entity, $errors);
+    $function($entity, $errors);
   }
 
   if ($errors) {
@@ -1070,11 +1064,8 @@ function field_attach_validate($entity_type, $entity, array $options = array())
  * elements. Fieldable entity types should call this function during their own
  * form validation function.
  *
- * @param $entity_type
- *   The type of $entity; e.g. 'node' or 'user'.
- * @param Drupal\Core\Entity\EntityInterface $entity
- *   The entity being submitted. The 'bundle', 'id' and (if applicable)
- *   'revision' keys should be present. The actual field values will be read
+ * @param \Drupal\Core\Entity\EntityInterface $entity
+ *   The entity being submitted. The actual field values will be read
  *   from $form_state['values'].
  * @param $form
  *   The form structure where field elements are attached to. This might be a
@@ -1085,10 +1076,10 @@ function field_attach_validate($entity_type, $entity, array $options = array())
  *   An associative array of additional options. See field_invoke_method() for
  *   details.
  */
-function field_attach_form_validate($entity_type, EntityInterface $entity, $form, &$form_state, array $options = array()) {
+function field_attach_form_validate(EntityInterface $entity, $form, &$form_state, array $options = array()) {
   // Perform field_level validation.
   try {
-    field_attach_validate($entity_type, $entity, $options);
+    field_attach_validate($entity, $options);
   }
   catch (FieldValidationException $e) {
     // Pass field-level validation errors back to widgets for accurate error
@@ -1110,11 +1101,8 @@ function field_attach_form_validate($entity_type, EntityInterface $entity, $form
  * Currently, this accounts for drag-and-drop reordering of field values, and
  * filtering of empty values.
  *
- * @param $entity_type
- *   The type of $entity; e.g. 'node' or 'user'.
- * @param Drupal\Core\Entity\EntityInterface $entity
- *   The entity being submitted. The 'bundle', 'id' and (if applicable)
- *   'revision' keys should be present. The actual field values will be read
+ * @param \Drupal\Core\Entity\EntityInterface $entity
+ *   The entity being submitted. The actual field values will be read
  *   from $form_state['values'].
  * @param $form
  *   The form structure where field elements are attached to. This might be a
@@ -1125,7 +1113,7 @@ function field_attach_form_validate($entity_type, EntityInterface $entity, $form
  *   An associative array of additional options. See field_invoke_method() for
  *   details.
  */
-function field_attach_submit($entity_type, EntityInterface $entity, $form, &$form_state, array $options = array()) {
+function field_attach_submit(EntityInterface $entity, $form, &$form_state, array $options = array()) {
   // Extract field values from submitted values.
   field_invoke_method('submit', _field_invoke_widget_target(), $entity, $form, $form_state, $options);
 
@@ -1133,7 +1121,7 @@ function field_attach_submit($entity_type, EntityInterface $entity, $form, &$for
   // Avoid module_invoke_all() to let $form_state be taken by reference.
   foreach (module_implements('field_attach_submit') as $module) {
     $function = $module . '_field_attach_submit';
-    $function($entity_type, $entity, $form, $form_state);
+    $function($entity, $form, $form_state);
   }
 }
 
@@ -1143,16 +1131,14 @@ function field_attach_submit($entity_type, EntityInterface $entity, $form, &$for
  * We take no specific action here, we just give other modules the opportunity
  * to act.
  *
- * @param $entity_type
- *   The type of $entity; e.g. 'node' or 'user'.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity with fields to process.
  */
-function field_attach_presave($entity_type, $entity) {
-  _field_invoke('presave', $entity_type, $entity);
+function field_attach_presave($entity) {
+  _field_invoke('presave', $entity);
 
   // Let other modules act on presaving the entity.
-  module_invoke_all('field_attach_presave', $entity_type, $entity);
+  module_invoke_all('field_attach_presave', $entity);
 }
 
 /**
@@ -1163,29 +1149,27 @@ function field_attach_presave($entity_type, $entity) {
  * Default values (if any) will be saved for fields not present in the
  * $entity.
  *
- * @param $entity_type
- *   The type of $entity; e.g. 'node' or 'user'.
- * @param Drupal\Core\Entity\EntityInterface $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity with fields to save.
  * @return
  *   Default values (if any) will be added to the $entity parameter for fields
  *   it leaves unspecified.
  */
-function field_attach_insert($entity_type, EntityInterface $entity) {
-  _field_invoke_default('insert', $entity_type, $entity);
-  _field_invoke('insert', $entity_type, $entity);
+function field_attach_insert(EntityInterface $entity) {
+  _field_invoke_default('insert', $entity);
+  _field_invoke('insert', $entity);
 
   // Let any module insert field data before the storage engine, accumulating
   // saved fields along the way.
   $skip_fields = array();
   foreach (module_implements('field_storage_pre_insert') as $module) {
     $function = $module . '_field_storage_pre_insert';
-    $function($entity_type, $entity, $skip_fields);
+    $function($entity, $skip_fields);
   }
 
   // Collect the storage backends used by the remaining fields in the entities.
   $storages = array();
-  foreach (field_info_instances($entity_type, $entity->bundle()) as $instance) {
+  foreach (field_info_instances($entity->entityType(), $entity->bundle()) as $instance) {
     $field = field_info_field_by_id($instance['field_id']);
     $field_id = $field['id'];
     $field_name = $field['field_name'];
@@ -1200,37 +1184,33 @@ function field_attach_insert($entity_type, EntityInterface $entity) {
   // Field storage backends save any remaining unsaved fields.
   foreach ($storages as $storage => $fields) {
     $storage_info = field_info_storage_types($storage);
-    module_invoke($storage_info['module'], 'field_storage_write', $entity_type, $entity, FIELD_STORAGE_INSERT, $fields);
+    module_invoke($storage_info['module'], 'field_storage_write', $entity, FIELD_STORAGE_INSERT, $fields);
   }
 
   // Let other modules act on inserting the entity.
-  module_invoke_all('field_attach_insert', $entity_type, $entity);
-
-  $entity_info = entity_get_info($entity_type);
+  module_invoke_all('field_attach_insert', $entity);
 }
 
 /**
  * Saves field data for an existing entity.
  *
- * @param $entity_type
- *   The type of $entity; e.g. 'node' or 'user'.
- * @param Drupal\Core\Entity\EntityInterface $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity with fields to save.
  */
-function field_attach_update($entity_type, EntityInterface $entity) {
-  _field_invoke('update', $entity_type, $entity);
+function field_attach_update(EntityInterface $entity) {
+  _field_invoke('update', $entity);
 
   // Let any module update field data before the storage engine, accumulating
   // saved fields along the way.
   $skip_fields = array();
   foreach (module_implements('field_storage_pre_update') as $module) {
     $function = $module . '_field_storage_pre_update';
-    $function($entity_type, $entity, $skip_fields);
+    $function($entity, $skip_fields);
   }
 
   // Collect the storage backends used by the remaining fields in the entities.
   $storages = array();
-  foreach (field_info_instances($entity_type, $entity->bundle()) as $instance) {
+  foreach (field_info_instances($entity->entityType(), $entity->bundle()) as $instance) {
     $field = field_info_field_by_id($instance['field_id']);
     $field_id = $field['id'];
     $field_name = $field['field_name'];
@@ -1249,15 +1229,15 @@ function field_attach_update($entity_type, EntityInterface $entity) {
   // Field storage backends save any remaining unsaved fields.
   foreach ($storages as $storage => $fields) {
     $storage_info = field_info_storage_types($storage);
-    module_invoke($storage_info['module'], 'field_storage_write', $entity_type, $entity, FIELD_STORAGE_UPDATE, $fields);
+    module_invoke($storage_info['module'], 'field_storage_write', $entity, FIELD_STORAGE_UPDATE, $fields);
   }
 
   // Let other modules act on updating the entity.
-  module_invoke_all('field_attach_update', $entity_type, $entity);
+  module_invoke_all('field_attach_update', $entity);
 
-  $entity_info = entity_get_info($entity_type);
+  $entity_info = $entity->entityInfo();
   if ($entity_info['field_cache']) {
-    cache('field')->delete("field:$entity_type:" . $entity->id());
+    cache('field')->delete('field:' . $entity->entityType() . ':' . $entity->id());
   }
 }
 
@@ -1265,17 +1245,15 @@ function field_attach_update($entity_type, EntityInterface $entity) {
  * Deletes field data for an existing entity. This deletes all revisions of
  * field data for the entity.
  *
- * @param $entity_type
- *   The type of $entity; e.g. 'node' or 'user'.
- * @param Drupal\Core\Entity\EntityInterface $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity whose field data to delete.
  */
-function field_attach_delete($entity_type, $entity) {
-  _field_invoke('delete', $entity_type, $entity);
+function field_attach_delete(EntityInterface $entity) {
+  _field_invoke('delete', $entity);
 
   // Collect the storage backends used by the fields in the entities.
   $storages = array();
-  foreach (field_info_instances($entity_type, $entity->bundle()) as $instance) {
+  foreach (field_info_instances($entity->entityType(), $entity->bundle()) as $instance) {
     $field = field_info_field_by_id($instance['field_id']);
     $field_id = $field['id'];
     $storages[$field['storage']['type']][$field_id] = $field_id;
@@ -1284,15 +1262,15 @@ function field_attach_delete($entity_type, $entity) {
   // Field storage backends delete their data.
   foreach ($storages as $storage => $fields) {
     $storage_info = field_info_storage_types($storage);
-    module_invoke($storage_info['module'], 'field_storage_delete', $entity_type, $entity, $fields);
+    module_invoke($storage_info['module'], 'field_storage_delete', $entity, $fields);
   }
 
   // Let other modules act on deleting the entity.
-  module_invoke_all('field_attach_delete', $entity_type, $entity);
+  module_invoke_all('field_attach_delete', $entity);
 
-  $entity_info = entity_get_info($entity_type);
+  $entity_info = $entity->entityInfo();
   if ($entity_info['field_cache']) {
-    cache('field')->delete("field:$entity_type:" . $entity->id());
+    cache('field')->delete('field:' . $entity->entityType() . ':' . $entity->id());
   }
 }
 
@@ -1300,17 +1278,15 @@ function field_attach_delete($entity_type, $entity) {
  * Delete field data for a single revision of an existing entity. The passed
  * entity must have a revision ID attribute.
  *
- * @param $entity_type
- *   The type of $entity; e.g. 'node' or 'user'.
- * @param Drupal\Core\Entity\EntityInterface $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity with fields to save.
  */
-function field_attach_delete_revision($entity_type, $entity) {
-  _field_invoke('delete_revision', $entity_type, $entity);
+function field_attach_delete_revision(EntityInterface $entity) {
+  _field_invoke('delete_revision', $entity);
 
   // Collect the storage backends used by the fields in the entities.
   $storages = array();
-  foreach (field_info_instances($entity_type, $entity->bundle()) as $instance) {
+  foreach (field_info_instances($entity->entityType(), $entity->bundle()) as $instance) {
     $field = field_info_field_by_id($instance['field_id']);
     $field_id = $field['id'];
     $storages[$field['storage']['type']][$field_id] = $field_id;
@@ -1319,11 +1295,11 @@ function field_attach_delete_revision($entity_type, $entity) {
   // Field storage backends delete their data.
   foreach ($storages as $storage => $fields) {
     $storage_info = field_info_storage_types($storage);
-    module_invoke($storage_info['module'], 'field_storage_delete_revision', $entity_type, $entity, $fields);
+    module_invoke($storage_info['module'], 'field_storage_delete_revision', $entity, $fields);
   }
 
   // Let other modules act on deleting the revision.
-  module_invoke_all('field_attach_delete_revision', $entity_type, $entity);
+  module_invoke_all('field_attach_delete_revision', $entity);
 }
 
 /**
@@ -1367,7 +1343,7 @@ function field_attach_prepare_view($entity_type, array $entities, array $display
 
       // Determine the actual language code to display for each field, given the
       // language codes available in the field data.
-      $options['langcode'][$id] = field_language($entity_type, $entity, NULL, $langcode);
+      $options['langcode'][$id] = field_language($entity, NULL, $langcode);
 
       // Mark this item as prepared.
       $entity->_field_view_prepared = TRUE;
@@ -1421,8 +1397,6 @@ function field_attach_prepare_view($entity_type, array $entities, array $display
  * );
  * @endcode
  *
- * @param $entity_type
- *   The type of $entity; e.g. 'node' or 'user'.
  * @param Drupal\Core\Entity\EntityInterface $entity
  *   The entity with fields to render.
  * @param \Drupal\entity\Plugin\Core\Entity\EntityDisplay $display
@@ -1437,10 +1411,10 @@ function field_attach_prepare_view($entity_type, array $entities, array $display
  * @return array
  *   A renderable array for the field values.
  */
-function field_attach_view($entity_type, EntityInterface $entity, EntityDisplay $display, $langcode = NULL, array $options = array()) {
+function field_attach_view(EntityInterface $entity, EntityDisplay $display, $langcode = NULL, array $options = array()) {
   // Determine the actual language code to display for each field, given the
   // language codes available in the field data.
-  $options['langcode'] = field_language($entity_type, $entity, NULL, $langcode);
+  $options['langcode'] = field_language($entity, NULL, $langcode);
 
   // For each instance, call the view() method on the formatter object handed
   // by the entity display.
@@ -1453,7 +1427,6 @@ function field_attach_view($entity_type, EntityInterface $entity, EntityDisplay
   // Let other modules alter the renderable array.
   $view_mode = $display->originalViewMode;
   $context = array(
-    'entity_type' => $entity_type,
     'entity' => $entity,
     'view_mode' => $view_mode,
     'display_options' => $view_mode,
@@ -1477,9 +1450,7 @@ function field_attach_view($entity_type, EntityInterface $entity, EntityDisplay
  * translatable fields the language currently chosen for display will be
  * selected.
  *
- * @param $entity_type
- *   The type of $entity; e.g. 'node' or 'user'.
- * @param Drupal\Core\Entity\EntityInterface $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity with fields to render.
  * @param $element
  *   The structured array containing the values ready for rendering.
@@ -1487,8 +1458,8 @@ function field_attach_view($entity_type, EntityInterface $entity, EntityDisplay
  *   The variables array is passed by reference and will be populated with field
  *   values.
  */
-function field_attach_preprocess($entity_type, EntityInterface $entity, $element, &$variables) {
-  foreach (field_info_instances($entity_type, $entity->bundle()) as $instance) {
+function field_attach_preprocess(EntityInterface $entity, $element, &$variables) {
+  foreach (field_info_instances($entity->entityType(), $entity->bundle()) as $instance) {
     $field_name = $instance['field_name'];
     if (isset($element[$field_name]['#language'])) {
       $langcode = $element[$field_name]['#language'];
@@ -1498,7 +1469,6 @@ function field_attach_preprocess($entity_type, EntityInterface $entity, $element
 
   // Let other modules make changes to the $variables array.
   $context = array(
-    'entity_type' => $entity_type,
     'entity' => $entity,
     'element' => $element,
   );
@@ -1517,9 +1487,7 @@ function field_attach_preprocess($entity_type, EntityInterface $entity, $element
  * implemented only for nodes by translation.module. Other entity types may be
  * supported through contributed modules.
  *
- * @param $entity_type
- *   The type of $entity; e.g. 'node' or 'user'.
- * @param Drupal\Core\Entity\EntityInterface $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity to be prepared for translation.
  * @param $langcode
  *   The language the entity has to be translated in.
@@ -1528,15 +1496,14 @@ function field_attach_preprocess($entity_type, EntityInterface $entity, $element
  * @param $source_langcode
  *   The source language from which translate.
  */
-function field_attach_prepare_translation($entity_type, EntityInterface $entity, $langcode, $source_entity, $source_langcode) {
+function field_attach_prepare_translation(EntityInterface $entity, $langcode, EntityInterface $source_entity, $source_langcode) {
   $options = array('langcode' => $langcode);
   // Copy source field values into the entity to be prepared.
-  _field_invoke_default('prepare_translation', $entity_type, $entity, $source_entity, $source_langcode, $options);
+  _field_invoke_default('prepare_translation', $entity, $source_entity, $source_langcode, $options);
   // Let field types handle their own advanced translation pattern if needed.
-  _field_invoke('prepare_translation', $entity_type, $entity, $source_entity, $source_langcode, $options);
+  _field_invoke('prepare_translation', $entity, $source_entity, $source_langcode, $options);
   // Let other modules alter the entity translation.
   $context = array(
-    'entity_type' => $entity_type,
     'langcode' => $langcode,
     'source_entity' => $source_entity,
     'source_langcode' => $source_langcode,
diff --git a/core/modules/field/field.crud.inc b/core/modules/field/field.crud.inc
index a62ad2ef73a6..a5e582be7a9c 100644
--- a/core/modules/field/field.crud.inc
+++ b/core/modules/field/field.crud.inc
@@ -5,6 +5,7 @@
  * Field CRUD API, handling field and field instance creation and deletion.
  */
 
+use Drupal\Core\Entity\EntityInterface;
 use Drupal\field\FieldException;
 
 /**
@@ -883,7 +884,7 @@ function field_purge_batch($batch_size) {
       field_attach_load($entity_type, $entities, FIELD_LOAD_CURRENT, array('field_id' => $field['id'], 'deleted' => 1));
       foreach ($entities as $entity) {
         // Purge the data for the entity.
-        field_purge_data($entity_type, $entity, $field, $instance);
+        field_purge_data($entity, $field, $instance);
       }
     }
     else {
@@ -909,28 +910,26 @@ function field_purge_batch($batch_size) {
  * a single field. The entity itself is not being deleted, and it is quite
  * possible that other field data will remain attached to it.
  *
- * @param $entity_type
- *   The type of $entity; e.g. 'node' or 'user'.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The pseudo-entity whose field data is being purged.
  * @param $field
  *   The (possibly deleted) field whose data is being purged.
  * @param $instance
  *   The deleted field instance whose data is being purged.
  */
-function field_purge_data($entity_type, $entity, $field, $instance) {
+function field_purge_data(EntityInterface $entity, $field, $instance) {
   // Each field type's hook_field_delete() only expects to operate on a single
   // field at a time, so we can use it as-is for purging.
   $options = array('field_id' => $instance['field_id'], 'deleted' => TRUE);
-  _field_invoke('delete', $entity_type, $entity, $dummy, $dummy, $options);
+  _field_invoke('delete', $entity, $dummy, $dummy, $options);
 
   // Tell the field storage system to purge the data.
-  module_invoke($field['storage']['module'], 'field_storage_purge', $entity_type, $entity, $field, $instance);
+  module_invoke($field['storage']['module'], 'field_storage_purge', $entity, $field, $instance);
 
   // Let other modules act on purging the data.
   foreach (module_implements('field_attach_purge') as $module) {
     $function = $module . '_field_attach_purge';
-    $function($entity_type, $entity, $field, $instance);
+    $function($entity, $field, $instance);
   }
 }
 
diff --git a/core/modules/field/field.default.inc b/core/modules/field/field.default.inc
index d37d0ac16d06..91682650806b 100644
--- a/core/modules/field/field.default.inc
+++ b/core/modules/field/field.default.inc
@@ -1,5 +1,7 @@
 <?php
 
+use Drupal\Core\Entity\EntityInterface;
+
 /**
  * @file
  * Default 'implementations' of hook_field_*(): common field housekeeping.
@@ -18,9 +20,7 @@
  *
  * @see _hook_field_validate()
  *
- * @param $entity_type
- *   The type of $entity.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity for the operation.
  * @param $field
  *   The field structure for the operation.
@@ -38,7 +38,7 @@
  *   - error: An error code (should be a string, prefixed with the module name).
  *   - message: The human readable message to be displayed.
  */
-function field_default_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
+function field_default_validate(EntityInterface $entity, $field, $instance, $langcode, $items, &$errors) {
   // Filter out empty values.
   $items = _field_filter_items($field, $items);
 
@@ -60,9 +60,7 @@ function field_default_validate($entity_type, $entity, $field, $instance, $langc
  * the current user doesn't have 'edit' permission for the field. This is the
  * default field 'insert' operation.
  *
- * @param $entity_type
- *   The type of $entity.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity for the operation.
  * @param $field
  *   The field structure for the operation.
@@ -73,7 +71,7 @@ function field_default_validate($entity_type, $entity, $field, $instance, $langc
  * @param $items
  *   An array that this function will populate with default values.
  */
-function field_default_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
+function field_default_insert(EntityInterface $entity, $field, $instance, $langcode, &$items) {
   // _field_invoke() populates $items with an empty array if the $entity has no
   // entry for the field, so we check on the $entity itself.
   // We also check that the current field translation is actually defined before
@@ -82,16 +80,14 @@ function field_default_insert($entity_type, $entity, $field, $instance, $langcod
   // not yet open languages.
   if (empty($entity) || (!isset($entity->{$field['field_name']}[$langcode]) && !property_exists($entity, $field['field_name'])) ||
     (isset($entity->{$field['field_name']}[$langcode]) && count($entity->{$field['field_name']}[$langcode]) == 0)) {
-    $items = field_get_default_value($entity_type, $entity, $field, $instance, $langcode);
+    $items = field_get_default_value($entity, $field, $instance, $langcode);
   }
 }
 
 /**
  * Copies source field values into the entity to be prepared.
  *
- * @param $entity_type
- *   The type of $entity; e.g. 'node' or 'user'.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity to be prepared for translation.
  * @param $field
  *   The field structure for the operation.
@@ -101,12 +97,12 @@ function field_default_insert($entity_type, $entity, $field, $instance, $langcod
  *   The language the entity has to be translated to.
  * @param $items
  *   $entity->{$field['field_name']}[$langcode], or an empty array if unset.
- * @param $source_entity
+ * @param \Drupal\Core\Entity\EntityInterface $source_entity
  *   The source entity holding the field values to be translated.
  * @param $source_langcode
  *   The source language from which to translate.
  */
-function field_default_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) {
+function field_default_prepare_translation(EntityInterface $entity, $field, $instance, $langcode, &$items, EntityInterface $source_entity, $source_langcode) {
   $field_name = $field['field_name'];
   // If the field is untranslatable keep using LANGUAGE_NOT_SPECIFIED.
   if ($langcode == LANGUAGE_NOT_SPECIFIED) {
diff --git a/core/modules/field/field.module b/core/modules/field/field.module
index 01b012211a5f..4ed76707dedc 100644
--- a/core/modules/field/field.module
+++ b/core/modules/field/field.module
@@ -4,8 +4,8 @@
  * Attach custom data fields to Drupal entities.
  */
 
+use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Template\Attribute;
-use Drupal\Core\Entity\Query\QueryFactory;
 
 /*
  * Load all public Field API functions. Drupal currently has no
@@ -436,12 +436,12 @@ function field_entity_field_info($entity_type) {
  *
  * @param $field_langcodes
  *   A reference to an array of language codes keyed by field name.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity to be displayed.
  * @param $langcode
  *   The language code $entity has to be displayed in.
  */
-function field_language_fallback(&$field_langcodes, $entity, $langcode) {
+function field_language_fallback(&$field_langcodes, EntityInterface $entity, $langcode) {
   // Lazily init fallback candidates to avoid unnecessary calls.
   $fallback_candidates = NULL;
 
@@ -546,9 +546,7 @@ function field_associate_fields($module) {
 /**
  * Helper function to get the default value for a field on an entity.
  *
- * @param $entity_type
- *   The type of $entity; e.g., 'node' or 'user'.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity for the operation.
  * @param $field
  *   The field structure.
@@ -557,11 +555,11 @@ function field_associate_fields($module) {
  * @param $langcode
  *   The field language to fill-in with the default value.
  */
-function field_get_default_value($entity_type, $entity, $field, $instance, $langcode = NULL) {
+function field_get_default_value(EntityInterface $entity, $field, $instance, $langcode = NULL) {
   $items = array();
   if (!empty($instance['default_value_function'])) {
     $function = $instance['default_value_function'];
-    $items = $function($entity_type, $entity, $field, $instance, $langcode);
+    $items = $function($entity, $field, $instance, $langcode);
   }
   elseif (!empty($instance['default_value'])) {
     $items = $instance['default_value'];
@@ -729,7 +727,7 @@ function field_view_mode_settings($entity_type, $bundle) {
  * @todo Remove when all steps in the view callstack receive the
  * entity_display.
  *
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity.
  * @param $view_mode
  *   The view mode.
@@ -738,7 +736,7 @@ function field_view_mode_settings($entity_type, $bundle) {
  *   The display options to be used when viewing the entity's pseudo-fields in
  *   the view mode.
  */
-function field_extra_fields_get_display($entity, $view_mode) {
+function field_extra_fields_get_display(EntityInterface $entity, $view_mode) {
   $entity_display = entity_get_render_display($entity, $view_mode);
   $extra_fields = field_info_extra_fields($entity->entityType(), $entity->bundle(), 'display');
 
@@ -812,9 +810,7 @@ function _field_filter_xss_display_allowed_tags() {
 /**
  * Returns a renderable array for a single field value.
  *
- * @param $entity_type
- *   The type of $entity; e.g., 'node' or 'user'.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity containing the field to display. Must at least contain the ID
  *   key and the field data to display.
  * @param $field_name
@@ -832,18 +828,18 @@ function _field_filter_xss_display_allowed_tags() {
  * @return
  *   A renderable array for the field value.
  */
-function field_view_value($entity_type, $entity, $field_name, $item, $display = array(), $langcode = NULL) {
+function field_view_value(EntityInterface $entity, $field_name, $item, $display = array(), $langcode = NULL) {
   $output = array();
 
   if ($field = field_info_field($field_name)) {
     // Determine the langcode that will be used by language fallback.
-    $langcode = field_language($entity_type, $entity, $field_name, $langcode);
+    $langcode = field_language($entity, $field_name, $langcode);
 
     // Push the item as the single value for the field, and defer to
     // field_view_field() to build the render array for the whole field.
     $clone = clone $entity;
     $clone->{$field_name}[$langcode] = array($item);
-    $elements = field_view_field($entity_type, $clone, $field_name, $display, $langcode);
+    $elements = field_view_field($clone, $field_name, $display, $langcode);
 
     // Extract the part of the render array we need.
     $output = isset($elements[0]) ? $elements[0] : array();
@@ -872,11 +868,8 @@ function field_view_value($entity_type, $entity, $field_name, $item, $display =
  * The function takes care of invoking the prepare_view steps. It also respects
  * field access permissions.
  *
- * @param $entity_type
- *   The type of $entity; e.g., 'node' or 'user'.
- * @param $entity
- *   The entity containing the field to display. Must at least contain the ID
- *   key and the field data to display.
+ * @param \Drupal\Core\Entity\EntityInterface $entity
+ *   The entity containing the field to display.
  * @param $field_name
  *   The name of the field to display.
  * @param $display_options
@@ -909,12 +902,12 @@ function field_view_value($entity_type, $entity, $field_name, $item, $display =
  *
  * @see field_view_value()
  */
-function field_view_field($entity_type, $entity, $field_name, $display_options = array(), $langcode = NULL) {
+function field_view_field(EntityInterface $entity, $field_name, $display_options = array(), $langcode = NULL) {
   $output = array();
   $bundle = $entity->bundle();
 
   // Return nothing if the field doesn't exist.
-  $instance = field_info_instance($entity_type, $field_name, $bundle);
+  $instance = field_info_instance($entity->entityType(), $field_name, $bundle);
   if (!$instance) {
     return $output;
   }
@@ -940,7 +933,7 @@ function field_view_field($entity_type, $entity, $field_name, $display_options =
   }
 
   if ($formatter) {
-    $display_langcode = field_language($entity_type, $entity, $field_name, $langcode);
+    $display_langcode = field_language($entity, $field_name, $langcode);
     $items = $entity->{$field_name}[$display_langcode];
 
     // Invoke prepare_view steps if needed.
@@ -950,7 +943,7 @@ function field_view_field($entity_type, $entity, $field_name, $display_options =
       // First let the field types do their preparation.
       $options = array('field_name' => $field_name, 'langcode' => $display_langcode);
       $null = NULL;
-      _field_invoke_multiple('prepare_view', $entity_type, array($id => $entity), $null, $null, $options);
+      _field_invoke_multiple('prepare_view', $entity->entityType(), array($id => $entity), $null, $null, $options);
 
       // Then let the formatter do its own specific massaging.
       $items_multi = array($id => $entity->{$field_name}[$display_langcode]);
@@ -964,7 +957,6 @@ function field_view_field($entity_type, $entity, $field_name, $display_options =
     // Invoke hook_field_attach_view_alter() to let other modules alter the
     // renderable array, as in a full field_attach_view() execution.
     $context = array(
-      'entity_type' => $entity_type,
       'entity' => $entity,
       'view_mode' => $view_mode,
       'display_options' => $display_options,
@@ -982,9 +974,7 @@ function field_view_field($entity_type, $entity, $field_name, $display_options =
 /**
  * Returns the field items in the language they currently would be displayed.
  *
- * @param $entity_type
- *   The type of $entity; e.g., 'node' or 'user'.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity containing the data to be displayed.
  * @param $field_name
  *   The field to be displayed.
@@ -995,8 +985,8 @@ function field_view_field($entity_type, $entity, $field_name, $display_options =
  * @return
  *   An array of field items keyed by delta if available, FALSE otherwise.
  */
-function field_get_items($entity_type, $entity, $field_name, $langcode = NULL) {
-  $langcode = field_language($entity_type, $entity, $field_name, $langcode);
+function field_get_items(EntityInterface $entity, $field_name, $langcode = NULL) {
+  $langcode = field_language($entity, $field_name, $langcode);
   return isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : FALSE;
 }
 
@@ -1048,8 +1038,8 @@ function field_has_data($field) {
  * @param array $field
  *   The full field structure array for the field on which the operation is to
  *   be performed. See field_info_field().
- * @param string $entity_type
- *   The type of $entity; e.g., 'node' or 'user'.
+ * @param $entity_type
+ *   The type of $entity; for example, 'node' or 'user'.
  * @param $entity
  *   (optional) The entity for the operation.
  * @param $account
diff --git a/core/modules/field/field.multilingual.inc b/core/modules/field/field.multilingual.inc
index 73c47cb04045..a9b33ac492e2 100644
--- a/core/modules/field/field.multilingual.inc
+++ b/core/modules/field/field.multilingual.inc
@@ -1,5 +1,7 @@
 <?php
 
+use Drupal\Core\Entity\EntityInterface;
+
 /**
  * @file
  * Functions implementing Field API multilingual support.
@@ -283,9 +285,7 @@ function field_valid_language($langcode, $default = TRUE) {
  * Core language fallback rules are provided by field_language_fallback()
  * which is called by field_field_language_alter().
  *
- * @param $entity_type
- *   The type of $entity.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity to be displayed.
  * @param $field_name
  *   (optional) The name of the field to be displayed. Defaults to NULL. If
@@ -299,10 +299,11 @@ function field_valid_language($langcode, $default = TRUE) {
  *   A language code if a field name is specified, an array of language codes
  *   keyed by field name otherwise.
  */
-function field_language($entity_type, $entity, $field_name = NULL, $langcode = NULL) {
+function field_language(EntityInterface $entity, $field_name = NULL, $langcode = NULL) {
   $display_langcodes = &drupal_static(__FUNCTION__, array());
   $id = $entity->id();
   $bundle = $entity->bundle();
+  $entity_type = $entity->entityType();
   $langcode = field_valid_language($langcode, FALSE);
   if (!isset($display_langcodes[$entity_type][$id][$langcode])) {
     $display_langcode = array();
@@ -330,13 +331,12 @@ function field_language($entity_type, $entity, $field_name = NULL, $langcode = N
 
     if (field_has_translation_handler($entity_type)) {
       $context = array(
-        'entity_type' => $entity_type,
         'entity' => $entity,
         'langcode' => $langcode,
       );
       // Do not apply core language fallback rules if they are disabled or if
       // the entity does not have a translation handler registered.
-      if (variable_get('field_language_fallback', FALSE) && field_has_translation_handler($context['entity_type'])) {
+      if (variable_get('field_language_fallback', FALSE) && field_has_translation_handler($entity_type)) {
         field_language_fallback($display_langcode, $context['entity'], $context['langcode']);
       }
       drupal_alter('field_language', $display_langcode, $context);
diff --git a/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterBase.php b/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterBase.php
index 26664092d8d8..e599d150b4d5 100644
--- a/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterBase.php
+++ b/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterBase.php
@@ -105,7 +105,7 @@ public function view(EntityInterface $entity, $langcode, array $items) {
         '#theme' => 'field',
         '#weight' => $this->weight,
         '#title' => $instance['label'],
-        '#access' => field_access('view', $field, $entity_type, $entity),
+        '#access' => field_access('view', $field, $entity->entityType(), $entity),
         '#label_display' => $this->label,
         '#view_mode' => $this->viewMode,
         '#language' => $langcode,
diff --git a/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetBase.php b/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetBase.php
index fd434d15eed1..c4e1e26a2404 100644
--- a/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetBase.php
+++ b/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetBase.php
@@ -74,7 +74,6 @@ public function __construct($plugin_id, DiscoveryInterface $discovery, FieldInst
    * Implements Drupal\field\Plugin\Type\Widget\WidgetInterface::form().
    */
   public function form(EntityInterface $entity, $langcode, array $items, array &$form, array &$form_state, $get_delta = NULL) {
-    $entity_type = $entity->entityType();
     $field = $this->field;
     $instance = $this->instance;
     $field_name = $field['field_name'];
@@ -87,7 +86,7 @@ public function form(EntityInterface $entity, $langcode, array $items, array &$f
 
     // Populate widgets with default values when creating a new entity.
     if (empty($items) && ($entity->isNew())) {
-      $items = field_get_default_value($entity_type, $entity, $field, $instance, $langcode);
+      $items = field_get_default_value($entity, $field, $instance, $langcode);
     }
 
     // Store field information in $form_state.
@@ -165,7 +164,7 @@ public function form(EntityInterface $entity, $langcode, array $items, array &$f
       // when $langcode is unknown.
       '#language' => $langcode,
       $langcode => $elements,
-      '#access' => field_access('edit', $field, $entity_type, $entity),
+      '#access' => field_access('edit', $field, $entity->entityType(), $entity),
     );
 
     return $addition;
diff --git a/core/modules/field/lib/Drupal/field/Plugin/field/formatter/LegacyFormatter.php b/core/modules/field/lib/Drupal/field/Plugin/field/formatter/LegacyFormatter.php
index 4f2c4f5d0d61..34f96f1a13a2 100644
--- a/core/modules/field/lib/Drupal/field/Plugin/field/formatter/LegacyFormatter.php
+++ b/core/modules/field/lib/Drupal/field/Plugin/field/formatter/LegacyFormatter.php
@@ -115,7 +115,7 @@ public function viewElements(EntityInterface $entity, $langcode, array $items) {
         'label' => $this->label,
       );
 
-      return $function($entity->entityType(), $entity, $this->field, $this->instance, $langcode, $items, $display);
+      return $function($entity, $this->field, $this->instance, $langcode, $items, $display);
     }
   }
 
diff --git a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php
index eadd0b06830f..c8f9eaa8656d 100644
--- a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php
+++ b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\field\Plugin\views\field;
 
+use Drupal\Core\Entity\EntityInterface;
 use Drupal\views\ViewExecutable;
 use Drupal\views\Plugin\views\display\DisplayPluginBase;
 use Drupal\views\Plugin\views\field\FieldPluginBase;
@@ -661,9 +662,8 @@ function get_items($values) {
       'views_row_id' => $this->view->row_index,
     );
 
-    $entity_type = $entity->entityType();
-    $langcode = $this->field_langcode($entity_type, $entity);
-    $render_array = field_view_field($entity_type, $entity, $this->definition['field_name'], $display, $langcode);
+    $langcode = $this->field_langcode($entity);
+    $render_array = field_view_field($entity, $this->definition['field_name'], $display, $langcode);
 
     $items = array();
     if ($this->options['field_api_classes']) {
@@ -697,17 +697,15 @@ function get_items($values) {
    * Replaces values with aggregated values if aggregation is enabled.
    * Takes delta settings into account (@todo remove in #1758616).
    *
-   * @param $entity
+   * @param \Drupal\Core\Entity\EntityInterface $entity
    *   The entity to be processed.
    *
    * @return
    *   TRUE if the processing completed successfully, otherwise FALSE.
    */
-  function process_entity($entity) {
+  function process_entity(EntityInterface $entity) {
     $processed_entity = clone $entity;
-
-    $entity_type = $entity->entityType();
-    $langcode = $this->field_langcode($entity_type, $processed_entity);
+    $langcode = $this->field_langcode($processed_entity);
     // If we are grouping, copy our group fields into the cloned entity.
     // It's possible this will cause some weirdness, but there's only
     // so much we can hope to do.
@@ -835,8 +833,8 @@ function add_self_tokens(&$tokens, $item) {
    * Return the language code of the language the field should be displayed in,
    * according to the settings.
    */
-  function field_langcode($entity_type, $entity) {
-    if (field_is_translatable($entity_type, $this->field_info)) {
+  function field_langcode(EntityInterface $entity) {
+    if (field_is_translatable($entity->entityType(), $this->field_info)) {
       $default_langcode = language_default()->langcode;
       $langcode = str_replace(array('***CURRENT_LANGUAGE***', '***DEFAULT_LANGUAGE***'),
                               array(drupal_container()->get(LANGUAGE_TYPE_CONTENT)->langcode, $default_langcode),
@@ -846,7 +844,7 @@ function field_langcode($entity_type, $entity) {
       // (or LANGUAGE_NOT_SPECIFIED), in case the field has no data for the selected language.
       // field_view_field() does this as well, but since the returned language code
       // is used before calling it, the fallback needs to happen explicitly.
-      $langcode = field_language($entity_type, $entity, $this->field_info['field_name'], $langcode);
+      $langcode = field_language($entity, $this->field_info['field_name'], $langcode);
 
       return $langcode;
     }
diff --git a/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php b/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
index cc47e597fa12..c3659619261a 100644
--- a/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
@@ -81,7 +81,8 @@ function checkHooksInvocations($expected_hooks, $actual_hooks) {
       foreach ($invocations as $argument) {
         $found = FALSE;
         foreach ($actual_invocations as $actual_arguments) {
-          if ($actual_arguments[1] == $argument) {
+          // $entity is sometimes the first and sometimes the second argument.
+          if ($actual_arguments[0] == $argument || $actual_arguments[1] == $argument) {
             $found = TRUE;
             break;
           }
diff --git a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php
index 204419e10977..1c539daaa260 100644
--- a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php
@@ -340,7 +340,7 @@ function testDeleteField() {
     $values[0]['value'] = mt_rand(1, 127);
     $entity->{$field['field_name']}[$langcode] = $values;
     $entity_type = 'test_entity';
-    field_attach_insert('test_entity', $entity);
+    field_attach_insert($entity);
 
     // Verify the field is present on load
     $entity = field_test_create_entity(0, 0, $this->instance_definition['bundle']);
@@ -406,7 +406,7 @@ function testUpdateField() {
         $entity->field_update[LANGUAGE_NOT_SPECIFIED][$i]['value'] = $i;
       }
       // Save the entity.
-      field_attach_insert('test_entity', $entity);
+      field_attach_insert($entity);
       // Load back and assert there are $cardinality number of values.
       $entity = field_test_create_entity($id, $id, $instance['bundle']);
       field_attach_load('test_entity', array($id => $entity));
diff --git a/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php b/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php
index 32f91fd1d9e8..8c2872762acc 100644
--- a/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php
@@ -83,7 +83,7 @@ function setUp() {
    */
   function testFieldViewField() {
     // No display settings: check that default display settings are used.
-    $output = field_view_field('test_entity', $this->entity, $this->field_name);
+    $output = field_view_field($this->entity, $this->field_name);
     $this->drupalSetContent(drupal_render($output));
     $settings = field_info_formatter_settings('field_test_default');
     $setting = $settings['test_formatter_setting'];
@@ -101,7 +101,7 @@ function testFieldViewField() {
         'alter' => TRUE,
       ),
     );
-    $output = field_view_field('test_entity', $this->entity, $this->field_name, $display);
+    $output = field_view_field($this->entity, $this->field_name, $display);
     $this->drupalSetContent(drupal_render($output));
     $setting = $display['settings']['test_formatter_setting_multiple'];
     $this->assertNoText($this->label, 'Label was not displayed.');
@@ -120,7 +120,7 @@ function testFieldViewField() {
         'test_formatter_setting_additional' => $this->randomName(),
       ),
     );
-    $output = field_view_field('test_entity', $this->entity, $this->field_name, $display);
+    $output = field_view_field($this->entity, $this->field_name, $display);
     $view = drupal_render($output);
     $this->drupalSetContent($view);
     $setting = $display['settings']['test_formatter_setting_additional'];
@@ -132,7 +132,7 @@ function testFieldViewField() {
 
     // View mode: check that display settings specified in the display object
     // are used.
-    $output = field_view_field('test_entity', $this->entity, $this->field_name, 'teaser');
+    $output = field_view_field($this->entity, $this->field_name, 'teaser');
     $this->drupalSetContent(drupal_render($output));
     $setting = $this->display_options['teaser']['settings']['test_formatter_setting'];
     $this->assertText($this->label, 'Label was displayed.');
@@ -142,7 +142,7 @@ function testFieldViewField() {
 
     // Unknown view mode: check that display settings for 'default' view mode
     // are used.
-    $output = field_view_field('test_entity', $this->entity, $this->field_name, 'unknown_view_mode');
+    $output = field_view_field($this->entity, $this->field_name, 'unknown_view_mode');
     $this->drupalSetContent(drupal_render($output));
     $setting = $this->display_options['default']['settings']['test_formatter_setting'];
     $this->assertText($this->label, 'Label was displayed.');
@@ -160,7 +160,7 @@ function testFieldViewValue() {
     $setting = $settings['test_formatter_setting'];
     foreach ($this->values as $delta => $value) {
       $item = $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][$delta];
-      $output = field_view_value('test_entity', $this->entity, $this->field_name, $item);
+      $output = field_view_value($this->entity, $this->field_name, $item);
       $this->drupalSetContent(drupal_render($output));
       $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
     }
@@ -176,7 +176,7 @@ function testFieldViewValue() {
     $array = array();
     foreach ($this->values as $delta => $value) {
       $item = $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][$delta];
-      $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, $display);
+      $output = field_view_value($this->entity, $this->field_name, $item, $display);
       $this->drupalSetContent(drupal_render($output));
       $this->assertText($setting . '|0:' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
     }
@@ -192,7 +192,7 @@ function testFieldViewValue() {
     $array = array();
     foreach ($this->values as $delta => $value) {
       $item = $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][$delta];
-      $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, $display);
+      $output = field_view_value($this->entity, $this->field_name, $item, $display);
       $this->drupalSetContent(drupal_render($output));
       $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
     }
@@ -202,7 +202,7 @@ function testFieldViewValue() {
     $setting = $this->display_options['teaser']['settings']['test_formatter_setting'];
     foreach ($this->values as $delta => $value) {
       $item = $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][$delta];
-      $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, 'teaser');
+      $output = field_view_value($this->entity, $this->field_name, $item, 'teaser');
       $this->drupalSetContent(drupal_render($output));
       $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
     }
@@ -212,7 +212,7 @@ function testFieldViewValue() {
     $setting = $this->display_options['default']['settings']['test_formatter_setting'];
     foreach ($this->values as $delta => $value) {
       $item = $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][$delta];
-      $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, 'unknown_view_mode');
+      $output = field_view_value($this->entity, $this->field_name, $item, 'unknown_view_mode');
       $this->drupalSetContent(drupal_render($output));
       $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
     }
diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php
index 5f8ad5dc2786..c549c9e4fcd8 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php
@@ -65,7 +65,7 @@ function testFieldAttachView() {
 
     // View all fields.
     field_attach_prepare_view($entity_type, array($entity->ftid => $entity), $displays);
-    $entity->content = field_attach_view($entity_type, $entity, $display);
+    $entity->content = field_attach_view($entity, $display);
     $output = drupal_render($entity->content);
     $this->content = $output;
     $this->assertRaw($this->instance['label'], "First field's label is displayed.");
@@ -80,7 +80,7 @@ function testFieldAttachView() {
     }
     // View single field (the second field).
     field_attach_prepare_view($entity_type, array($entity->ftid => $entity), $displays, $langcode, $options);
-    $entity->content = field_attach_view($entity_type, $entity, $display, $langcode, $options);
+    $entity->content = field_attach_view($entity, $display, $langcode, $options);
     $output = drupal_render($entity->content);
     $this->content = $output;
     $this->assertNoRaw($this->instance['label'], "First field's label is not displayed.");
@@ -99,7 +99,7 @@ function testFieldAttachView() {
     $display_options['label'] = 'hidden';
     $display->setComponent($this->field['field_name'], $display_options);
     field_attach_prepare_view($entity_type, array($entity->ftid => $entity), $displays);
-    $entity->content = field_attach_view($entity_type, $entity, $display);
+    $entity->content = field_attach_view($entity, $display);
     $output = drupal_render($entity->content);
     $this->content = $output;
     $this->assertNoRaw($this->instance['label'], "Hidden label: label is not displayed.");
@@ -108,7 +108,7 @@ function testFieldAttachView() {
     $entity = clone($entity_init);
     $display->removeComponent($this->field['field_name']);
     field_attach_prepare_view($entity_type, array($entity->ftid => $entity), $displays);
-    $entity->content = field_attach_view($entity_type, $entity, $display);
+    $entity->content = field_attach_view($entity, $display);
     $output = drupal_render($entity->content);
     $this->content = $output;
     $this->assertNoRaw($this->instance['label'], "Hidden field: label is not displayed.");
@@ -127,7 +127,7 @@ function testFieldAttachView() {
       ),
     ));
     field_attach_prepare_view($entity_type, array($entity->ftid => $entity), $displays);
-    $entity->content = field_attach_view($entity_type, $entity, $display);
+    $entity->content = field_attach_view($entity, $display);
     $output = drupal_render($entity->content);
     $expected_output = $formatter_setting;
     foreach ($values as $delta => $value) {
@@ -147,7 +147,7 @@ function testFieldAttachView() {
       ),
     ));
     field_attach_prepare_view($entity_type, array($entity->ftid => $entity), $displays);
-    $entity->content = field_attach_view($entity_type, $entity, $display);
+    $entity->content = field_attach_view($entity, $display);
     $output = drupal_render($entity->content);
     $this->content = $output;
     foreach ($values as $delta => $value) {
@@ -160,7 +160,7 @@ function testFieldAttachView() {
 
     // Preprocess template.
     $variables = array();
-    field_attach_preprocess($entity_type, $entity, $entity->content, $variables);
+    field_attach_preprocess($entity, $entity->content, $variables);
     $result = TRUE;
     foreach ($values as $delta => $item) {
       if ($variables[$this->field_name][$delta]['value'] !== $item['value']) {
@@ -245,7 +245,7 @@ function testFieldAttachCache() {
     // Save, and check that no cache entry is present.
     $entity = clone($entity_init);
     $entity->{$this->field_name}[$langcode] = $values;
-    field_attach_insert($entity_type, $entity);
+    field_attach_insert($entity);
     $this->assertFalse(cache('field')->get($cid), 'Non-cached: no cache entry on insert');
 
     // Load, and check that no cache entry is present.
@@ -256,6 +256,11 @@ function testFieldAttachCache() {
 
     // Cacheable entity type.
     $entity_type = 'test_cacheable_entity';
+    $entity_init = entity_create($entity_type, array(
+      'ftid' => 1,
+      'ftvid' => 1,
+      'fttype' => $this->instance['bundle'],
+    ));
     $cid = "field:$entity_type:{$entity_init->ftid}";
     $instance = $this->instance;
     $instance['entity_type'] = $entity_type;
@@ -267,7 +272,7 @@ function testFieldAttachCache() {
     // Save, and check that no cache entry is present.
     $entity = clone($entity_init);
     $entity->{$this->field_name}[$langcode] = $values;
-    field_attach_insert($entity_type, $entity);
+    field_attach_insert($entity);
     $this->assertFalse(cache('field')->get($cid), 'Cached: no cache entry on insert');
 
     // Load a single field, and check that no cache entry is present.
@@ -286,7 +291,7 @@ function testFieldAttachCache() {
     $values = $this->_generateTestFieldValues($this->field['cardinality']);
     $entity = clone($entity_init);
     $entity->{$this->field_name}[$langcode] = $values;
-    field_attach_update($entity_type, $entity);
+    field_attach_update($entity);
     $this->assertFalse(cache('field')->get($cid), 'Cached: no cache entry on update');
 
     // Load, and check that a cache entry is present with the expected values.
@@ -296,11 +301,15 @@ function testFieldAttachCache() {
     $this->assertEqual($cache->data[$this->field_name][$langcode], $values, 'Cached: correct cache entry on load');
 
     // Create a new revision, and check that the cache entry is wiped.
-    $entity_init = field_test_create_entity(1, 2, $this->instance['bundle']);
+    $entity_init = entity_create($entity_type, array(
+      'ftid' => 1,
+      'ftvid' => 2,
+      'fttype' => $this->instance['bundle'],
+    ));
     $values = $this->_generateTestFieldValues($this->field['cardinality']);
     $entity = clone($entity_init);
     $entity->{$this->field_name}[$langcode] = $values;
-    field_attach_update($entity_type, $entity);
+    field_attach_update($entity);
     $cache = cache('field')->get($cid);
     $this->assertFalse(cache('field')->get($cid), 'Cached: no cache entry on new revision creation');
 
@@ -311,7 +320,7 @@ function testFieldAttachCache() {
     $this->assertEqual($cache->data[$this->field_name][$langcode], $values, 'Cached: correct cache entry on load');
 
     // Delete, and check that the cache entry is wiped.
-    field_attach_delete($entity_type, $entity);
+    field_attach_delete($entity);
     $this->assertFalse(cache('field')->get($cid), 'Cached: no cache entry after delete');
   }
 
@@ -346,7 +355,7 @@ function testFieldAttachValidate() {
 
     // Validate all fields.
     try {
-      field_attach_validate($entity_type, $entity);
+      field_attach_validate($entity);
     }
     catch (FieldValidationException $e) {
       $errors = $e->errors;
@@ -373,7 +382,7 @@ function testFieldAttachValidate() {
     // Validate a single field.
     $options = array('field_name' => $this->field_name_2);
     try {
-      field_attach_validate($entity_type, $entity, $options);
+      field_attach_validate($entity, $options);
     }
     catch (FieldValidationException $e) {
       $errors = $e->errors;
@@ -391,7 +400,7 @@ function testFieldAttachValidate() {
     $entity->{$this->field_name_2}[$langcode] = $this->_generateTestFieldValues($this->field_2['cardinality'] + 1);
     // When validating all fields.
     try {
-      field_attach_validate($entity_type, $entity);
+      field_attach_validate($entity);
     }
     catch (FieldValidationException $e) {
       $errors = $e->errors;
@@ -399,7 +408,7 @@ function testFieldAttachValidate() {
     $this->assertEqual($errors[$this->field_name_2][$langcode][0][0]['error'], 'field_cardinality', 'Cardinality validation failed.');
     // When validating a single field (the second field).
     try {
-      field_attach_validate($entity_type, $entity, $options);
+      field_attach_validate($entity, $options);
     }
     catch (FieldValidationException $e) {
       $errors = $e->errors;
@@ -423,7 +432,7 @@ function testFieldAttachForm() {
     // When generating form for all fields.
     $form = array();
     $form_state = form_state_defaults();
-    field_attach_form($entity_type, $entity, $form, $form_state);
+    field_attach_form($entity, $form, $form_state);
 
     $this->assertEqual($form[$this->field_name][$langcode]['#title'], $this->instance['label'], "First field's form title is {$this->instance['label']}");
     $this->assertEqual($form[$this->field_name_2][$langcode]['#title'], $this->instance_2['label'], "Second field's form title is {$this->instance_2['label']}");
@@ -440,7 +449,7 @@ function testFieldAttachForm() {
     $options = array('field_name' => $this->field_name_2);
     $form = array();
     $form_state = form_state_defaults();
-    field_attach_form($entity_type, $entity, $form, $form_state, NULL, $options);
+    field_attach_form($entity, $form, $form_state, NULL, $options);
 
     $this->assertFalse(isset($form[$this->field_name]), 'The first field does not exist in the form');
     $this->assertEqual($form[$this->field_name_2][$langcode]['#title'], $this->instance_2['label'], "Second field's form title is {$this->instance_2['label']}");
@@ -463,7 +472,7 @@ function testFieldAttachSubmit() {
     // Build the form for all fields.
     $form = array();
     $form_state = form_state_defaults();
-    field_attach_form($entity_type, $entity_init, $form, $form_state);
+    field_attach_form($entity_init, $form, $form_state);
 
     // Simulate incoming values.
     // First field.
@@ -503,7 +512,7 @@ function testFieldAttachSubmit() {
 
     // Call field_attach_submit() for all fields.
     $entity = clone($entity_init);
-    field_attach_submit($entity_type, $entity, $form, $form_state);
+    field_attach_submit($entity, $form, $form_state);
 
     asort($weights);
     asort($weights_2);
@@ -525,7 +534,7 @@ function testFieldAttachSubmit() {
     // Call field_attach_submit() for a single field (the second field).
     $options = array('field_name' => $this->field_name_2);
     $entity = clone($entity_init);
-    field_attach_submit($entity_type, $entity, $form, $form_state, $options);
+    field_attach_submit($entity, $form, $form_state, $options);
     $expected_values_2 = array();
     foreach ($weights_2 as $key => $value) {
       if ($key != 1) {
diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
index a4be944a27e8..1de9ffa7147d 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
@@ -49,12 +49,12 @@ function testFieldAttachSaveLoad() {
       // If this is the first revision do an insert.
       if (!$revision_id) {
         $revision[$revision_id]->{$this->field_name}[$langcode] = $values[$revision_id];
-        field_attach_insert($entity_type, $revision[$revision_id]);
+        field_attach_insert($revision[$revision_id]);
       }
       else {
         // Otherwise do an update.
         $revision[$revision_id]->{$this->field_name}[$langcode] = $values[$revision_id];
-        field_attach_update($entity_type, $revision[$revision_id]);
+        field_attach_update($revision[$revision_id]);
       }
     }
 
@@ -137,7 +137,7 @@ function testFieldAttachLoadMultiple() {
         $values[$index][$field_name] = mt_rand(1, 127);
         $entity->$field_name = array($langcode => array(array('value' => $values[$index][$field_name])));
       }
-      field_attach_insert($entity_type, $entity);
+      field_attach_insert($entity);
     }
 
     // Check that a single load correctly loads field values for both entities.
@@ -202,7 +202,7 @@ function testFieldAttachSaveLoadDifferentStorage() {
       $values[$field['field_name']] = $this->_generateTestFieldValues($this->field['cardinality']);
       $entity->{$field['field_name']}[$langcode] = $values[$field['field_name']];
     }
-    field_attach_insert($entity_type, $entity);
+    field_attach_insert($entity);
 
     // Check that values are loaded as expected.
     $entity = clone($entity_init);
@@ -264,7 +264,7 @@ function testFieldAttachSaveMissingData() {
 
     // Insert: Field is missing.
     $entity = clone($entity_init);
-    field_attach_insert($entity_type, $entity);
+    field_attach_insert($entity);
 
     $entity = clone($entity_init);
     field_attach_load($entity_type, array($entity->ftid => $entity));
@@ -274,7 +274,7 @@ function testFieldAttachSaveMissingData() {
     field_cache_clear();
     $entity = clone($entity_init);
     $entity->{$this->field_name} = NULL;
-    field_attach_insert($entity_type, $entity);
+    field_attach_insert($entity);
 
     $entity = clone($entity_init);
     field_attach_load($entity_type, array($entity->ftid => $entity));
@@ -285,7 +285,7 @@ function testFieldAttachSaveMissingData() {
     $entity = clone($entity_init);
     $values = $this->_generateTestFieldValues(1);
     $entity->{$this->field_name}[$langcode] = $values;
-    field_attach_insert($entity_type, $entity);
+    field_attach_insert($entity);
 
     $entity = clone($entity_init);
     field_attach_load($entity_type, array($entity->ftid => $entity));
@@ -294,7 +294,7 @@ function testFieldAttachSaveMissingData() {
     // Update: Field is missing. Data should survive.
     field_cache_clear();
     $entity = clone($entity_init);
-    field_attach_update($entity_type, $entity);
+    field_attach_update($entity);
 
     $entity = clone($entity_init);
     field_attach_load($entity_type, array($entity->ftid => $entity));
@@ -304,7 +304,7 @@ function testFieldAttachSaveMissingData() {
     field_cache_clear();
     $entity = clone($entity_init);
     $entity->{$this->field_name} = NULL;
-    field_attach_update($entity_type, $entity);
+    field_attach_update($entity);
 
     $entity = clone($entity_init);
     field_attach_load($entity_type, array($entity->ftid => $entity));
@@ -315,7 +315,7 @@ function testFieldAttachSaveMissingData() {
     $entity = clone($entity_init);
     $values = $this->_generateTestFieldValues(1);
     $entity->{$this->field_name}[$langcode] = $values;
-    field_attach_update($entity_type, $entity);
+    field_attach_update($entity);
 
     $entity = clone($entity_init);
     field_attach_load($entity_type, array($entity->ftid => $entity));
@@ -325,7 +325,7 @@ function testFieldAttachSaveMissingData() {
     field_cache_clear();
     $entity = clone($entity_init);
     $entity->{$this->field_name} = array();
-    field_attach_update($entity_type, $entity);
+    field_attach_update($entity);
 
     $entity = clone($entity_init);
     field_attach_load($entity_type, array($entity->ftid => $entity));
@@ -347,7 +347,7 @@ function testFieldAttachSaveMissingDataDefaultValue() {
     // Insert: Field is NULL.
     $entity = clone($entity_init);
     $entity->{$this->field_name}[$langcode] = NULL;
-    field_attach_insert($entity_type, $entity);
+    field_attach_insert($entity);
 
     $entity = clone($entity_init);
     field_attach_load($entity_type, array($entity->ftid => $entity));
@@ -356,11 +356,11 @@ function testFieldAttachSaveMissingDataDefaultValue() {
     // Insert: Field is missing.
     field_cache_clear();
     $entity = clone($entity_init);
-    field_attach_insert($entity_type, $entity);
+    field_attach_insert($entity);
 
     $entity = clone($entity_init);
     field_attach_load($entity_type, array($entity->ftid => $entity));
-    $values = field_test_default_value($entity_type, $entity, $this->field, $this->instance);
+    $values = field_test_default_value($entity, $this->field, $this->instance);
     $this->assertEqual($entity->{$this->field_name}[$langcode], $values, 'Insert: missing field results in default value saved');
   }
 
@@ -375,17 +375,17 @@ function testFieldAttachDelete() {
     // Create revision 0
     $values = $this->_generateTestFieldValues($this->field['cardinality']);
     $rev[0]->{$this->field_name}[$langcode] = $values;
-    field_attach_insert($entity_type, $rev[0]);
+    field_attach_insert($rev[0]);
 
     // Create revision 1
     $rev[1] = field_test_create_entity(0, 1, $this->instance['bundle']);
     $rev[1]->{$this->field_name}[$langcode] = $values;
-    field_attach_update($entity_type, $rev[1]);
+    field_attach_update($rev[1]);
 
     // Create revision 2
     $rev[2] = field_test_create_entity(0, 2, $this->instance['bundle']);
     $rev[2]->{$this->field_name}[$langcode] = $values;
-    field_attach_update($entity_type, $rev[2]);
+    field_attach_update($rev[2]);
 
     // Confirm each revision loads
     foreach (array_keys($rev) as $vid) {
@@ -395,7 +395,7 @@ function testFieldAttachDelete() {
     }
 
     // Delete revision 1, confirm the other two still load.
-    field_attach_delete_revision($entity_type, $rev[1]);
+    field_attach_delete_revision($rev[1]);
     foreach (array(0, 2) as $vid) {
       $read = field_test_create_entity(0, $vid, $this->instance['bundle']);
       field_attach_load_revision($entity_type, array(0 => $read));
@@ -408,7 +408,7 @@ function testFieldAttachDelete() {
     $this->assertEqual(count($read->{$this->field_name}[$langcode]), $this->field['cardinality'], "The test entity current revision has {$this->field['cardinality']} values.");
 
     // Delete all field data, confirm nothing loads
-    field_attach_delete($entity_type, $rev[2]);
+    field_attach_delete($rev[2]);
     foreach (array(0, 1, 2) as $vid) {
       $read = field_test_create_entity(0, $vid, $this->instance['bundle']);
       field_attach_load_revision($entity_type, array(0 => $read));
@@ -437,7 +437,7 @@ function testFieldAttachCreateRenameBundle() {
     $values = $this->_generateTestFieldValues($this->field['cardinality']);
     $entity->{$this->field_name}[$langcode] = $values;
     $entity_type = 'test_entity';
-    field_attach_insert($entity_type, $entity);
+    field_attach_insert($entity);
 
     // Verify the field data is present on load.
     $entity = field_test_create_entity(0, 0, $this->instance['bundle']);
@@ -494,7 +494,7 @@ function testFieldAttachDeleteBundle() {
     $values = $this->_generateTestFieldValues($this->field['cardinality']);
     $entity->{$this->field_name}[$langcode] = $values;
     $entity->{$field_name}[$langcode] = $this->_generateTestFieldValues(1);
-    field_attach_insert('test_entity', $entity);
+    field_attach_insert($entity);
 
     // Verify the fields are present on load
     $entity = field_test_create_entity(0, 0, $this->instance['bundle']);
diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php b/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php
index d82165f6837b..a34586e61fc0 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\field\Tests;
 
+use Drupal\Core\Entity\EntityInterface;
 use Drupal\simpletest\WebTestBase;
 
 /**
@@ -47,7 +48,7 @@ function _generateTestFieldValues($cardinality) {
    *
    * This function only checks a single column in the field values.
    *
-   * @param $entity
+   * @param EntityInterface $entity
    *   The entity to test.
    * @param $field_name
    *   The name of the field to test
@@ -58,7 +59,7 @@ function _generateTestFieldValues($cardinality) {
    * @param $column
    *   (Optional) the name of the column to check.
    */
-  function assertFieldValues($entity, $field_name, $langcode, $expected_values, $column = 'value') {
+  function assertFieldValues(EntityInterface $entity, $field_name, $langcode, $expected_values, $column = 'value') {
     $e = clone $entity;
     field_attach_load('test_entity', array($e->ftid => $e));
     $values = isset($e->{$field_name}[$langcode]) ? $e->{$field_name}[$langcode] : array();
diff --git a/core/modules/field/lib/Drupal/field/Tests/FormTest.php b/core/modules/field/lib/Drupal/field/Tests/FormTest.php
index b11638f199b2..4df7218b6165 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FormTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FormTest.php
@@ -407,7 +407,7 @@ function testFieldFormAccess() {
 
     $form = array();
     $form_state = form_state_defaults();
-    field_attach_form($entity_type, $entity, $form, $form_state);
+    field_attach_form($entity, $form, $form_state);
 
     $this->assertEqual($form[$field_name_no_access][$langcode][0]['value']['#entity_type'], $entity_type, 'The correct entity type is set in the field structure.');
     $this->assertFalse($form[$field_name_no_access]['#access'], 'Field #access is FALSE for the field without edit access.');
diff --git a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php
index 8f813c06133b..8930d97d0f64 100644
--- a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php
@@ -123,9 +123,9 @@ function testFieldInvoke() {
     }
     $entity->{$this->field_name} = $values;
 
-    $results = _field_invoke('test_op', $entity_type, $entity);
+    $results = _field_invoke('test_op', $entity);
     foreach ($results as $langcode => $result) {
-      $hash = hash('sha256', serialize(array($entity_type, $entity, $this->field_name, $langcode, $values[$langcode])));
+      $hash = hash('sha256', serialize(array($entity, $this->field_name, $langcode, $values[$langcode])));
       // Check whether the parameters passed to _field_invoke() were correctly
       // forwarded to the callback function.
       $this->assertEqual($hash, $result, format_string('The result for %language is correctly stored.', array('%language' => $langcode)));
@@ -182,7 +182,7 @@ function testFieldInvokeMultiple() {
       $entities[$id] = $entity;
 
       // Store per-entity language suggestions.
-      $options['langcode'][$id] = field_language($entity_type, $entity, NULL, $display_langcode);
+      $options['langcode'][$id] = field_language($entity, NULL, $display_langcode);
     }
 
     $grouped_results = _field_invoke_multiple('test_op_multiple', $entity_type, $entities);
@@ -230,7 +230,7 @@ function testTranslatableFieldSaveLoad() {
 
     // Save and reload the field translations.
     $entity->{$this->field_name} = $field_translations;
-    field_attach_insert($entity_type, $entity);
+    field_attach_insert($entity);
     unset($entity->{$this->field_name});
     field_attach_load($entity_type, array($eid => $entity));
 
@@ -305,7 +305,7 @@ function testFieldDisplayLanguage() {
     field_test_entity_info_translatable($entity_type, FALSE);
     drupal_static_reset('field_language');
     $requested_langcode = $enabled_langcodes[0];
-    $display_langcodes = field_language($entity_type, $entity, NULL, $requested_langcode);
+    $display_langcodes = field_language($entity, NULL, $requested_langcode);
     foreach ($instances as $instance) {
       $field_name = $instance['field_name'];
       $this->assertTrue($display_langcodes[$field_name] == $locked_languages[$field_name], format_string('The display language for field %field_name is %language.', array('%field_name' => $field_name, '%language' => $locked_languages[$field_name])));
@@ -314,7 +314,7 @@ function testFieldDisplayLanguage() {
     // Test multiple-fields display languages for translatable entities.
     field_test_entity_info_translatable($entity_type, TRUE);
     drupal_static_reset('field_language');
-    $display_langcodes = field_language($entity_type, $entity, NULL, $requested_langcode);
+    $display_langcodes = field_language($entity, NULL, $requested_langcode);
     foreach ($instances as $instance) {
       $field_name = $instance['field_name'];
       $langcode = $display_langcodes[$field_name];
@@ -326,14 +326,14 @@ function testFieldDisplayLanguage() {
 
     // Test single-field display language.
     drupal_static_reset('field_language');
-    $langcode = field_language($entity_type, $entity, $this->field_name, $requested_langcode);
+    $langcode = field_language($entity, $this->field_name, $requested_langcode);
     $this->assertTrue(isset($entity->{$this->field_name}[$langcode]) && $langcode != $requested_langcode, format_string('The display language for the (single) field %field_name is %language.', array('%field_name' => $field_name, '%language' => $langcode)));
 
     // Test field_language() basic behavior without language fallback.
     state()->set('field_test.language_fallback', FALSE);
     $entity->{$this->field_name}[$requested_langcode] = mt_rand(1, 127);
     drupal_static_reset('field_language');
-    $display_langcode = field_language($entity_type, $entity, $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/tests/modules/field_test/field_test.entity.inc b/core/modules/field/tests/modules/field_test/field_test.entity.inc
index 517f5cb8e1de..2a7f29598f3a 100644
--- a/core/modules/field/tests/modules/field_test/field_test.entity.inc
+++ b/core/modules/field/tests/modules/field_test/field_test.entity.inc
@@ -162,7 +162,7 @@ function field_test_entity_test_load($ftid, $ftvid = NULL) {
 /**
  * Saves a test_entity.
  *
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity to save.
  */
 function field_test_entity_save(EntityInterface $entity) {
@@ -198,7 +198,7 @@ function field_test_entity_nested_form($form, &$form_state, $entity_1, $entity_2
       '#value' => $entity_1->$key,
     );
   }
-  field_attach_form('test_entity', $entity_1, $form, $form_state);
+  field_attach_form($entity_1, $form, $form_state);
 
   // Second entity.
   $form['entity_2'] = array(
@@ -214,7 +214,7 @@ function field_test_entity_nested_form($form, &$form_state, $entity_1, $entity_2
       '#value' => $entity_2->$key,
     );
   }
-  field_attach_form('test_entity', $entity_2, $form['entity_2'], $form_state);
+  field_attach_form($entity_2, $form['entity_2'], $form_state);
 
   $form['save'] = array(
     '#type' => 'submit',
@@ -230,12 +230,12 @@ function field_test_entity_nested_form($form, &$form_state, $entity_1, $entity_2
  */
 function field_test_entity_nested_form_validate($form, &$form_state) {
   $entity_1 = entity_create('test_entity', $form_state['values']);
-  field_attach_submit('test_entity', $entity_1, $form, $form_state);
-  field_attach_form_validate('test_entity', $entity_1, $form, $form_state);
+  field_attach_submit($entity_1, $form, $form_state);
+  field_attach_form_validate($entity_1, $form, $form_state);
 
   $entity_2 = entity_create('test_entity', $form_state['values']['entity_2']);
-  field_attach_submit('test_entity', $entity_2, $form['entity_2'], $form_state);
-  field_attach_form_validate('test_entity', $entity_2, $form['entity_2'], $form_state);
+  field_attach_submit($entity_2, $form['entity_2'], $form_state);
+  field_attach_form_validate($entity_2, $form['entity_2'], $form_state);
 }
 
 /**
@@ -243,11 +243,11 @@ function field_test_entity_nested_form_validate($form, &$form_state) {
  */
 function field_test_entity_nested_form_submit($form, &$form_state) {
   $entity_1 = entity_create('test_entity', $form_state['values']);
-  field_attach_submit('test_entity', $entity_1, $form, $form_state);
+  field_attach_submit($entity_1, $form, $form_state);
   field_test_entity_save($entity_1);
 
   $entity_2 = entity_create('test_entity', $form_state['values']['entity_2']);
-  field_attach_submit('test_entity', $entity_2, $form['entity_2'], $form_state);
+  field_attach_submit($entity_2, $form['entity_2'], $form_state);
   field_test_entity_save($entity_2);
 
   drupal_set_message(t('test_entities @id_1 and @id_2 have been updated.', array('@id_1' => $entity_1->ftid, '@id_2' => $entity_2->ftid)));
diff --git a/core/modules/field/tests/modules/field_test/field_test.field.inc b/core/modules/field/tests/modules/field_test/field_test.field.inc
index 6f3283064ef9..a5f6fa5c9f02 100644
--- a/core/modules/field/tests/modules/field_test/field_test.field.inc
+++ b/core/modules/field/tests/modules/field_test/field_test.field.inc
@@ -5,6 +5,7 @@
  * Defines a field type and its formatters and widgets.
  */
 
+use Drupal\Core\Entity\EntityInterface;
 use Drupal\field\FieldException;
 
 /**
@@ -87,7 +88,7 @@ function field_test_field_load($entity_type, $entities, $field, $instances, $lan
 /**
  * Implements hook_field_insert().
  */
-function field_test_field_insert($entity_type, $entity, $field, $instance, $items) {
+function field_test_field_insert(EntityInterface $entity, $field, $instance, $items) {
   $args = func_get_args();
   field_test_memorize(__FUNCTION__, $args);
 }
@@ -95,7 +96,7 @@ function field_test_field_insert($entity_type, $entity, $field, $instance, $item
 /**
  * Implements hook_field_update().
  */
-function field_test_field_update($entity_type, $entity, $field, $instance, $items) {
+function field_test_field_update(EntityInterface $entity, $field, $instance, $items) {
   $args = func_get_args();
   field_test_memorize(__FUNCTION__, $args);
 }
@@ -103,7 +104,7 @@ function field_test_field_update($entity_type, $entity, $field, $instance, $item
 /**
  * Implements hook_field_delete().
  */
-function field_test_field_delete($entity_type, $entity, $field, $instance, $items) {
+function field_test_field_delete(EntityInterface $entity, $field, $instance, $items) {
   $args = func_get_args();
   field_test_memorize(__FUNCTION__, $args);
 }
@@ -114,7 +115,7 @@ function field_test_field_delete($entity_type, $entity, $field, $instance, $item
  * Possible error codes:
  * - 'field_test_invalid': The value is invalid.
  */
-function field_test_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
+function field_test_field_validate(EntityInterface $entity = NULL, $field, $instance, $langcode, $items, &$errors) {
   $args = func_get_args();
   field_test_memorize(__FUNCTION__, $args);
 
@@ -184,7 +185,7 @@ function field_test_widget_multiple_validate($element, &$form_state) {
 /**
  * Sample 'default value' callback.
  */
-function field_test_default_value($entity_type, $entity, $field, $instance) {
+function field_test_default_value(EntityInterface $entity, $field, $instance) {
   return array(array('value' => 99));
 }
 
diff --git a/core/modules/field/tests/modules/field_test/field_test.module b/core/modules/field/tests/modules/field_test/field_test.module
index 47d61b174211..741dd607cf85 100644
--- a/core/modules/field/tests/modules/field_test/field_test.module
+++ b/core/modules/field/tests/modules/field_test/field_test.module
@@ -1,5 +1,7 @@
 <?php
 
+use Drupal\Core\Entity\EntityInterface;
+
 /**
  * @file
  * Helper module for the Field API tests.
@@ -78,8 +80,8 @@ function field_test_menu() {
  *
  * This simulates a field operation callback to be invoked by _field_invoke().
  */
-function field_test_field_test_op($entity_type, $entity, $field, $instance, $langcode, &$items) {
-  return array($langcode => hash('sha256', serialize(array($entity_type, $entity, $field['field_name'], $langcode, $items))));
+function field_test_field_test_op(EntityInterface $entity, $field, $instance, $langcode, &$items) {
+  return array($langcode => hash('sha256', serialize(array($entity, $field['field_name'], $langcode, $items))));
 }
 
 /**
diff --git a/core/modules/field/tests/modules/field_test/field_test.storage.inc b/core/modules/field/tests/modules/field_test/field_test.storage.inc
index 630cde88adbd..a53b941aaf04 100644
--- a/core/modules/field/tests/modules/field_test/field_test.storage.inc
+++ b/core/modules/field/tests/modules/field_test/field_test.storage.inc
@@ -5,6 +5,7 @@
  * Defines a field storage backend.
  */
 
+use Drupal\Core\Entity\EntityInterface;
 
 /**
  * Implements hook_field_storage_info().
@@ -116,7 +117,7 @@ function field_test_field_storage_load($entity_type, $entities, $age, $fields, $
 /**
  * Implements hook_field_storage_write().
  */
-function field_test_field_storage_write($entity_type, $entity, $op, $fields) {
+function field_test_field_storage_write(EntityInterface $entity, $op, $fields) {
   $data = _field_test_storage_data();
 
   $id = $entity->id();
@@ -128,7 +129,7 @@ function field_test_field_storage_write($entity_type, $entity, $op, $fields) {
     $field_name = $field['field_name'];
     $field_data = &$data[$field_id];
 
-    $all_langcodes = field_available_languages($entity_type, $field);
+    $all_langcodes = field_available_languages($entity->entityType(), $field);
     $field_langcodes = array_intersect($all_langcodes, array_keys((array) $entity->$field_name));
 
     // Delete and insert, rather than update, in case a value was added.
@@ -138,13 +139,13 @@ function field_test_field_storage_write($entity_type, $entity, $op, $fields) {
       $langcodes = !empty($entity->$field_name) ? $field_langcodes : $all_langcodes;
       if ($langcodes) {
         foreach ($field_data['current'] as $key => $row) {
-          if ($row->type == $entity_type && $row->entity_id == $id && in_array($row->langcode, $langcodes)) {
+          if ($row->type == $entity->entityType() && $row->entity_id == $id && in_array($row->langcode, $langcodes)) {
             unset($field_data['current'][$key]);
           }
         }
         if (isset($vid)) {
           foreach ($field_data['revisions'] as $key => $row) {
-            if ($row->type == $entity_type && $row->revision_id == $vid) {
+            if ($row->type == $entity->entityType() && $row->revision_id == $vid) {
               unset($field_data['revisions'][$key]);
             }
           }
@@ -158,7 +159,7 @@ function field_test_field_storage_write($entity_type, $entity, $op, $fields) {
       foreach ($items as $delta => $item) {
         $row = (object) array(
           'field_id' => $field_id,
-          'type' => $entity_type,
+          'type' => $entity->entityType(),
           'entity_id' => $id,
           'revision_id' => $vid,
           'bundle' => $bundle,
@@ -188,13 +189,13 @@ function field_test_field_storage_write($entity_type, $entity, $op, $fields) {
 /**
  * Implements hook_field_storage_delete().
  */
-function field_test_field_storage_delete($entity_type, $entity, $fields) {
+function field_test_field_storage_delete(EntityInterface $entity, $fields) {
   // Note: reusing field_test_storage_purge(), like field_sql_storage.module
   // does, is highly inefficient in our case...
-  foreach (field_info_instances($entity->bundle()) as $instance) {
+  foreach (field_info_instances($entity->entityType(), $entity->bundle()) as $instance) {
     if (isset($fields[$instance['field_id']])) {
       $field = field_info_field_by_id($instance['field_id']);
-      field_test_field_storage_purge($entity_type, $entity, $field, $instance);
+      field_test_field_storage_purge($entity, $field, $instance);
     }
   }
 }
@@ -202,13 +203,13 @@ function field_test_field_storage_delete($entity_type, $entity, $fields) {
 /**
  * Implements hook_field_storage_purge().
  */
-function field_test_field_storage_purge($entity_type, $entity, $field, $instance) {
+function field_test_field_storage_purge(EntityInterface $entity, $field, $instance) {
   $data = _field_test_storage_data();
 
   $field_data = &$data[$field['id']];
   foreach (array('current', 'revisions') as $sub_table) {
     foreach ($field_data[$sub_table] as $key => $row) {
-      if ($row->type == $entity_type && $row->entity_id == $entity->id()) {
+      if ($row->type == $entity->entityType() && $row->entity_id == $entity->id()) {
         unset($field_data[$sub_table][$key]);
       }
     }
@@ -220,14 +221,14 @@ function field_test_field_storage_purge($entity_type, $entity, $field, $instance
 /**
  * Implements hook_field_storage_delete_revision().
  */
-function field_test_field_storage_delete_revision($entity_type, $entity, $fields) {
+function field_test_field_storage_delete_revision(EntityInterface $entity, $fields) {
   $data = _field_test_storage_data();
 
   foreach ($fields as $field_id) {
     $field_data = &$data[$field_id];
     foreach (array('current', 'revisions') as $sub_table) {
       foreach ($field_data[$sub_table] as $key => $row) {
-        if ($row->type == $entity_type && $row->entity_id == $entity->id() && $row->revision_id == $entity->getRevisionId()) {
+        if ($row->type == $entity->entityType() && $row->entity_id == $entity->id() && $row->revision_id == $entity->getRevisionId()) {
           unset($field_data[$sub_table][$key]);
         }
       }
diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Core/Entity/CacheableTestEntity.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Core/Entity/CacheableTestEntity.php
index 12de9504d971..20e930042a27 100644
--- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Core/Entity/CacheableTestEntity.php
+++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Core/Entity/CacheableTestEntity.php
@@ -19,6 +19,8 @@
  *   module = "field_test",
  *   controller_class = "Drupal\field_test\TestEntityController",
  *   field_cache = TRUE,
+ *   base_table = "test_entity",
+ *   revision_table = "test_entity_revision",
  *   fieldable = TRUE,
  *   entity_keys = {
  *     "id" = "ftid",
diff --git a/core/modules/field_sql_storage/field_sql_storage.module b/core/modules/field_sql_storage/field_sql_storage.module
index d354f51bffb0..accca35eed9b 100644
--- a/core/modules/field_sql_storage/field_sql_storage.module
+++ b/core/modules/field_sql_storage/field_sql_storage.module
@@ -6,6 +6,7 @@
  */
 
 use Drupal\Core\Database\Database;
+use Drupal\Core\Entity\EntityInterface;
 use Drupal\field\FieldUpdateForbiddenException;
 
 /**
@@ -398,10 +399,11 @@ function field_sql_storage_field_storage_load($entity_type, $entities, $age, $fi
 /**
  * Implements hook_field_storage_write().
  */
-function field_sql_storage_field_storage_write($entity_type, $entity, $op, $fields) {
+function field_sql_storage_field_storage_write(EntityInterface $entity, $op, $fields) {
   $vid = $entity->getRevisionId();
   $id = $entity->id();
   $bundle = $entity->bundle();
+  $entity_type = $entity->entityType();
   if (!isset($vid)) {
     $vid = $id;
   }
@@ -493,11 +495,11 @@ function field_sql_storage_field_storage_write($entity_type, $entity, $op, $fiel
  *
  * This function deletes data for all fields for an entity from the database.
  */
-function field_sql_storage_field_storage_delete($entity_type, $entity, $fields) {
-  foreach (field_info_instances($entity_type, $entity->bundle()) as $instance) {
+function field_sql_storage_field_storage_delete(EntityInterface $entity, $fields) {
+  foreach (field_info_instances($entity->entityType(), $entity->bundle()) as $instance) {
     if (isset($fields[$instance['field_id']])) {
       $field = field_info_field_by_id($instance['field_id']);
-      field_sql_storage_field_storage_purge($entity_type, $entity, $field, $instance);
+      field_sql_storage_field_storage_purge($entity, $field, $instance);
     }
   }
 }
@@ -508,15 +510,15 @@ function field_sql_storage_field_storage_delete($entity_type, $entity, $fields)
  * This function deletes data from the database for a single field on
  * an entity.
  */
-function field_sql_storage_field_storage_purge($entity_type, $entity, $field, $instance) {
+function field_sql_storage_field_storage_purge(EntityInterface $entity, $field, $instance) {
   $table_name = _field_sql_storage_tablename($field);
   $revision_name = _field_sql_storage_revision_tablename($field);
   db_delete($table_name)
-    ->condition('entity_type', $entity_type)
+    ->condition('entity_type', $entity->entityType())
     ->condition('entity_id', $entity->id())
     ->execute();
   db_delete($revision_name)
-    ->condition('entity_type', $entity_type)
+    ->condition('entity_type', $entity->entityType())
     ->condition('entity_id', $entity->id())
     ->execute();
 }
@@ -526,14 +528,14 @@ function field_sql_storage_field_storage_purge($entity_type, $entity, $field, $i
  *
  * This function actually deletes the data from the database.
  */
-function field_sql_storage_field_storage_delete_revision($entity_type, $entity, $fields) {
+function field_sql_storage_field_storage_delete_revision(EntityInterface $entity, $fields) {
   $vid = $entity->getRevisionId();
   if (isset($vid)) {
     foreach ($fields as $field_id) {
       $field = field_info_field_by_id($field_id);
       $revision_name = _field_sql_storage_revision_tablename($field);
       db_delete($revision_name)
-        ->condition('entity_type', $entity_type)
+        ->condition('entity_type', $entity->entityType())
         ->condition('entity_id', $entity->id())
         ->condition('revision_id', $vid)
         ->execute();
diff --git a/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php b/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php
index 5681f596af1d..e79757e792e4 100644
--- a/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php
+++ b/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php
@@ -138,7 +138,7 @@ function testFieldAttachInsertAndUpdate() {
       $values[$delta]['value'] = mt_rand(1, 127);
     }
     $entity->{$this->field_name}[$langcode] = $rev_values[0] = $values;
-    field_attach_insert($entity_type, $entity);
+    field_attach_insert($entity);
 
     $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC);
     foreach ($values as $delta => $value) {
@@ -158,7 +158,7 @@ function testFieldAttachInsertAndUpdate() {
       $values[$delta]['value'] = mt_rand(1, 127);
     }
     $entity->{$this->field_name}[$langcode] = $rev_values[1] = $values;
-    field_attach_update($entity_type, $entity);
+    field_attach_update($entity);
     $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC);
     foreach ($values as $delta => $value) {
       if ($delta < $this->field['cardinality']) {
@@ -188,7 +188,7 @@ function testFieldAttachInsertAndUpdate() {
     // Check that update leaves the field data untouched if
     // $entity->{$field_name} is absent.
     unset($entity->{$this->field_name});
-    field_attach_update($entity_type, $entity);
+    field_attach_update($entity);
     $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC);
     foreach ($values as $delta => $value) {
       if ($delta < $this->field['cardinality']) {
@@ -198,7 +198,7 @@ function testFieldAttachInsertAndUpdate() {
 
     // Check that update with an empty $entity->$field_name empties the field.
     $entity->{$this->field_name} = NULL;
-    field_attach_update($entity_type, $entity);
+    field_attach_update($entity);
     $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC);
     $this->assertEqual(count($rows), 0, t("Update with an empty field_name entry empties the field."));
   }
@@ -212,7 +212,7 @@ function testFieldAttachSaveMissingData() {
     $langcode = LANGUAGE_NOT_SPECIFIED;
 
     // Insert: Field is missing
-    field_attach_insert($entity_type, $entity);
+    field_attach_insert($entity);
     $count = db_select($this->table)
       ->countQuery()
       ->execute()
@@ -221,7 +221,7 @@ function testFieldAttachSaveMissingData() {
 
     // Insert: Field is NULL
     $entity->{$this->field_name} = NULL;
-    field_attach_insert($entity_type, $entity);
+    field_attach_insert($entity);
     $count = db_select($this->table)
       ->countQuery()
       ->execute()
@@ -230,7 +230,7 @@ function testFieldAttachSaveMissingData() {
 
     // Add some real data
     $entity->{$this->field_name}[$langcode] = array(0 => array('value' => 1));
-    field_attach_insert($entity_type, $entity);
+    field_attach_insert($entity);
     $count = db_select($this->table)
       ->countQuery()
       ->execute()
@@ -239,7 +239,7 @@ function testFieldAttachSaveMissingData() {
 
     // Update: Field is missing. Data should survive.
     unset($entity->{$this->field_name});
-    field_attach_update($entity_type, $entity);
+    field_attach_update($entity);
     $count = db_select($this->table)
       ->countQuery()
       ->execute()
@@ -248,7 +248,7 @@ function testFieldAttachSaveMissingData() {
 
     // Update: Field is NULL. Data should be wiped.
     $entity->{$this->field_name} = NULL;
-    field_attach_update($entity_type, $entity);
+    field_attach_update($entity);
     $count = db_select($this->table)
       ->countQuery()
       ->execute()
@@ -269,7 +269,7 @@ function testFieldAttachSaveMissingData() {
 
     // Again add some real data.
     $entity->{$this->field_name}[$langcode] = array(0 => array('value' => 1));
-    field_attach_insert($entity_type, $entity);
+    field_attach_insert($entity);
     $count = db_select($this->table)
       ->countQuery()
       ->execute()
@@ -280,7 +280,7 @@ function testFieldAttachSaveMissingData() {
     // data should survive.
     $entity->{$this->field_name}[$unavailable_langcode] = array(mt_rand(1, 127));
     unset($entity->{$this->field_name}[$langcode]);
-    field_attach_update($entity_type, $entity);
+    field_attach_update($entity);
     $count = db_select($this->table)
       ->countQuery()
       ->execute()
@@ -290,7 +290,7 @@ function testFieldAttachSaveMissingData() {
     // Update: Field translation is NULL but field is not empty. Translation
     // data should be wiped.
     $entity->{$this->field_name}[$langcode] = NULL;
-    field_attach_update($entity_type, $entity);
+    field_attach_update($entity);
     $count = db_select($this->table)
       ->countQuery()
       ->execute()
diff --git a/core/modules/field_ui/field_ui.admin.inc b/core/modules/field_ui/field_ui.admin.inc
index d3cabf34fc8e..57643433324e 100644
--- a/core/modules/field_ui/field_ui.admin.inc
+++ b/core/modules/field_ui/field_ui.admin.inc
@@ -987,7 +987,7 @@ function field_ui_field_edit_form_validate($form, &$form_state) {
     $errors = array();
     $function = $field['module'] . '_field_validate';
     if (function_exists($function)) {
-      $function(NULL, NULL, $field, $instance, LANGUAGE_NOT_SPECIFIED, $items, $errors);
+      $function(NULL, $field, $instance, LANGUAGE_NOT_SPECIFIED, $items, $errors);
     }
 
     // Report errors.
diff --git a/core/modules/file/file.field.inc b/core/modules/file/file.field.inc
index 6c696c3e1483..e166b824e1a1 100644
--- a/core/modules/file/file.field.inc
+++ b/core/modules/file/file.field.inc
@@ -6,6 +6,7 @@
  */
 
 use Drupal\Component\Utility\NestedArray;
+use Drupal\Core\Entity\EntityInterface;
 
 /**
  * Implements hook_field_info().
@@ -218,10 +219,10 @@ function file_field_prepare_view($entity_type, $entities, $field, $instances, $l
 /**
  * Implements hook_field_insert().
  */
-function file_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
+function file_field_insert(EntityInterface $entity, $field, $instance, $langcode, &$items) {
   // Add a new usage of each uploaded file.
   foreach ($items as $item) {
-    file_usage()->add(file_load($item['fid']), 'file', $entity_type, $entity->id());
+    file_usage()->add(file_load($item['fid']), 'file', $entity->entityType(), $entity->id());
   }
 }
 
@@ -230,12 +231,12 @@ function file_field_insert($entity_type, $entity, $field, $instance, $langcode,
  *
  * Checks for files that have been removed from the object.
  */
-function file_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) {
+function file_field_update(EntityInterface $entity, $field, $instance, $langcode, &$items) {
   // On new revisions, all files are considered to be a new usage and no
   // deletion of previous file usages are necessary.
   if (!empty($entity->original) && $entity->getRevisionId() != $entity->original->getRevisionId()) {
     foreach ($items as $item) {
-      file_usage()->add(file_load($item['fid']), 'file', $entity_type, $entity->id());
+      file_usage()->add(file_load($item['fid']), 'file', $entity->entityType(), $entity->id());
     }
     return;
   }
@@ -254,7 +255,7 @@ function file_field_update($entity_type, $entity, $field, $instance, $langcode,
       $original_fids[] = $original_item['fid'];
       if (isset($original_item['fid']) && !in_array($original_item['fid'], $current_fids)) {
         // Decrement the file usage count by 1.
-        file_usage()->delete(file_load($original_item['fid']), 'file', $entity_type, $entity->id());
+        file_usage()->delete(file_load($original_item['fid']), 'file', $entity->entityType(), $entity->id());
       }
     }
   }
@@ -262,7 +263,7 @@ function file_field_update($entity_type, $entity, $field, $instance, $langcode,
   // Add new usage entries for newly added files.
   foreach ($items as $item) {
     if (!in_array($item['fid'], $original_fids)) {
-      file_usage()->add(file_load($item['fid']), 'file', $entity_type, $entity->id());
+      file_usage()->add(file_load($item['fid']), 'file', $entity->entityType(), $entity->id());
     }
   }
 }
@@ -270,20 +271,20 @@ function file_field_update($entity_type, $entity, $field, $instance, $langcode,
 /**
  * Implements hook_field_delete().
  */
-function file_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) {
+function file_field_delete(EntityInterface $entity, $field, $instance, $langcode, &$items) {
   // Delete all file usages within this entity.
   foreach ($items as $delta => $item) {
-    file_usage()->delete(file_load($item['fid']), 'file', $entity_type, $entity->id(), 0);
+    file_usage()->delete(file_load($item['fid']), 'file', $entity->entityType(), $entity->id(), 0);
   }
 }
 
 /**
  * Implements hook_field_delete_revision().
  */
-function file_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items) {
+function file_field_delete_revision(EntityInterface $entity, $field, $instance, $langcode, &$items) {
   foreach ($items as $delta => $item) {
     // Decrement the file usage count by 1.
-    file_usage()->delete(file_load($item['fid']), 'file', $entity_type, $entity->id());
+    file_usage()->delete(file_load($item['fid']), 'file', $entity->entityType(), $entity->id());
   }
 }
 
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index 1590f4e09ea8..b6f69fcb3552 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -1544,7 +1544,7 @@ function file_get_file_references(File $file, $field = NULL, $age = FIELD_LOAD_R
           // the referenced file. This will fail if the usage checked is in a
           // non-current revision because field items are from the current
           // revision.
-          if (!$match && ($field_items = field_get_items($entity_type, $entity, $field_name))) {
+          if (!$match && ($field_items = field_get_items($entity, $field_name))) {
             foreach ($field_items as $item) {
               if ($file->fid == $item[$field_column]) {
                 $match = TRUE;
diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module
index 0a10e00b761f..58aeeae0b07d 100644
--- a/core/modules/forum/forum.module
+++ b/core/modules/forum/forum.module
@@ -5,6 +5,7 @@
  * Provides discussion forums.
  */
 
+use Drupal\Core\Entity\EntityInterface;
 use Drupal\node\Plugin\Core\Entity\Node;
 use Drupal\taxonomy\Plugin\Core\Entity\Term;
 
@@ -516,8 +517,8 @@ function forum_comment_delete($comment) {
 /**
  * Implements hook_field_storage_pre_insert().
  */
-function forum_field_storage_pre_insert($entity_type, $entity, &$skip_fields) {
-  if ($entity_type == 'node' && $entity->status && _forum_node_check_node_type($entity)) {
+function forum_field_storage_pre_insert(EntityInterface $entity, &$skip_fields) {
+  if ($entity->entityType() == 'node' && $entity->status && _forum_node_check_node_type($entity)) {
     $query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp'));
     foreach ($entity->taxonomy_forums as $language) {
       foreach ($language as $item) {
@@ -539,10 +540,10 @@ function forum_field_storage_pre_insert($entity_type, $entity, &$skip_fields) {
 /**
  * Implements hook_field_storage_pre_update().
  */
-function forum_field_storage_pre_update($entity_type, $entity, &$skip_fields) {
+function forum_field_storage_pre_update(EntityInterface $entity, &$skip_fields) {
   $first_call = &drupal_static(__FUNCTION__, array());
 
-  if ($entity_type == 'node' && _forum_node_check_node_type($entity)) {
+  if ($entity->entityType() == 'node' && _forum_node_check_node_type($entity)) {
 
     // If the node is published, update the forum index.
     if ($entity->status) {
diff --git a/core/modules/image/image.field.inc b/core/modules/image/image.field.inc
index f739f66654b7..e83d542d32cf 100644
--- a/core/modules/image/image.field.inc
+++ b/core/modules/image/image.field.inc
@@ -6,6 +6,7 @@
  */
 
 use Drupal\Component\Utility\NestedArray;
+use Drupal\Core\Entity\EntityInterface;
 
 /**
  * Implements hook_field_info().
@@ -240,7 +241,7 @@ function image_field_prepare_view($entity_type, $entities, $field, $instances, $
 /**
  * Implements hook_field_presave().
  */
-function image_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
+function image_field_presave(EntityInterface $entity, $field, $instance, $langcode, &$items) {
 
   // Determine the dimensions if necessary.
   foreach ($items as &$item) {
@@ -258,29 +259,29 @@ function image_field_presave($entity_type, $entity, $field, $instance, $langcode
 /**
  * Implements hook_field_insert().
  */
-function image_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
-  file_field_insert($entity_type, $entity, $field, $instance, $langcode, $items);
+function image_field_insert(EntityInterface $entity, $field, $instance, $langcode, &$items) {
+  file_field_insert($entity, $field, $instance, $langcode, $items);
 }
 
 /**
  * Implements hook_field_update().
  */
-function image_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) {
-  file_field_update($entity_type, $entity, $field, $instance, $langcode, $items);
+function image_field_update(EntityInterface $entity, $field, $instance, $langcode, &$items) {
+  file_field_update($entity, $field, $instance, $langcode, $items);
 }
 
 /**
  * Implements hook_field_delete().
  */
-function image_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) {
-  file_field_delete($entity_type, $entity, $field, $instance, $langcode, $items);
+function image_field_delete(EntityInterface $entity, $field, $instance, $langcode, &$items) {
+  file_field_delete($entity, $field, $instance, $langcode, $items);
 }
 
 /**
  * Implements hook_field_delete_revision().
  */
-function image_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items) {
-  file_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, $items);
+function image_field_delete_revision(EntityInterface $entity, $field, $instance, $langcode, &$items) {
+  file_field_delete_revision($entity, $field, $instance, $langcode, $items);
 }
 
 /**
diff --git a/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php b/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php
index a04a43f1d867..7b5413f0e8fc 100644
--- a/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php
+++ b/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php
@@ -473,7 +473,7 @@ protected function renderTestEntity($id, $view_mode = 'full', $reset = TRUE) {
     $entity = field_test_entity_test_load($id);
     $display = entity_get_display($entity->entityType(), $entity->bundle(), $view_mode);
     field_attach_prepare_view('test_entity', array($entity->id() => $entity), array($entity->bundle() => $display));
-    $entity->content = field_attach_view('test_entity', $entity, $display);
+    $entity->content = field_attach_view($entity, $display);
 
     $output = drupal_render($entity->content);
     $this->drupalSetContent($output);
diff --git a/core/modules/link/link.module b/core/modules/link/link.module
index 0e204df5da12..f8ee4091b5f4 100644
--- a/core/modules/link/link.module
+++ b/core/modules/link/link.module
@@ -5,6 +5,8 @@
  * Defines simple link field types.
  */
 
+use Drupal\Core\Entity\EntityInterface;
+
 /**
  * Implements hook_help().
  */
@@ -79,7 +81,7 @@ function link_field_is_empty($item, $field) {
 /**
  * Implements hook_field_presave().
  */
-function link_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
+function link_field_presave(EntityInterface $entity, $field, $instance, $langcode, &$items) {
   foreach ($items as $delta => &$item) {
     // Trim any spaces around the URL and title.
     $item['url'] = trim($item['url']);
@@ -339,7 +341,7 @@ function link_field_formatter_prepare_view($entity_type, $entities, $field, $ins
 /**
  * Implements hook_field_formatter_view().
  */
-function link_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
+function link_field_formatter_view(EntityInterface $entity, $field, $instance, $langcode, $items, $display) {
   $element = array();
   $settings = $display['settings'];
 
@@ -351,7 +353,7 @@ function link_field_formatter_view($entity_type, $entity, $field, $instance, $la
     if (empty($settings['url_only']) && !empty($item['title'])) {
       // Unsanitizied token replacement here because $options['html'] is FALSE
       // by default in theme_link().
-      $link_title = token_replace($item['title'], array($entity_type => $entity), array('sanitize' => FALSE, 'clear' => TRUE));
+      $link_title = token_replace($item['title'], array($entity->entityType() => $entity), array('sanitize' => FALSE, 'clear' => TRUE));
     }
 
     // Trim the link title to the desired length.
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index 7cbba867571c..9e8fbd35632d 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -1153,7 +1153,7 @@ function template_preprocess_node(&$variables) {
   }
 
   // Make the field variables available with the appropriate language.
-  field_attach_preprocess('node', $node, $variables['content'], $variables);
+  field_attach_preprocess($node, $variables['content'], $variables);
 
   // Display post information only on certain node types.
   if (variable_get('node_submitted_' . $node->type, TRUE)) {
diff --git a/core/modules/node/node.tokens.inc b/core/modules/node/node.tokens.inc
index 8827b981f48d..c882450217af 100644
--- a/core/modules/node/node.tokens.inc
+++ b/core/modules/node/node.tokens.inc
@@ -135,9 +135,9 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr
 
         case 'body':
         case 'summary':
-          if ($items = field_get_items('node', $node, 'body', $langcode)) {
+          if ($items = field_get_items($node, 'body', $langcode)) {
             $instance = field_info_instance('node', 'body', $node->type);
-            $field_langcode = field_language('node', $node, 'body', $langcode);
+            $field_langcode = field_language($node, 'body', $langcode);
 
             // If the summary was requested and is not empty, use it.
             if ($name == 'summary' && !empty($items[0]['summary'])) {
diff --git a/core/modules/number/number.module b/core/modules/number/number.module
index 85d87fdb3ba1..56b28a3ee921 100644
--- a/core/modules/number/number.module
+++ b/core/modules/number/number.module
@@ -5,6 +5,8 @@
  * Defines numeric field types.
  */
 
+use Drupal\Core\Entity\EntityInterface;
+
 /**
  * Implements hook_help().
  */
@@ -122,7 +124,7 @@ function number_field_instance_settings_form($field, $instance) {
  * - number_min: The value is less than the allowed minimum value.
  * - number_max: The value is greater than the allowed maximum value.
  */
-function number_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
+function number_field_validate(EntityInterface $entity = NULL, $field, $instance, $langcode, $items, &$errors) {
   foreach ($items as $delta => $item) {
     if ($item['value'] != '') {
       if (is_numeric($instance['settings']['min']) && $item['value'] < $instance['settings']['min']) {
@@ -144,7 +146,7 @@ function number_field_validate($entity_type, $entity, $field, $instance, $langco
 /**
  * Implements hook_field_presave().
  */
-function number_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
+function number_field_presave(EntityInterface $entity, $field, $instance, $langcode, &$items) {
   if ($field['type'] == 'number_decimal') {
     // Let PHP round the value to ensure consistent behavior across storage
     // backends.
diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesValidationTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesValidationTest.php
index 0fa0763ac686..693605a8239d 100644
--- a/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesValidationTest.php
+++ b/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesValidationTest.php
@@ -29,7 +29,7 @@ function testDynamicAllowedValues() {
     foreach ($this->test as $key => $value) {
       $this->entity->test_options[LANGUAGE_NOT_SPECIFIED][0]['value'] = $value;
       try {
-        field_attach_validate('test_entity', $this->entity);
+        field_attach_validate($this->entity);
         $this->pass("$key should pass");
       }
       catch (FieldValidationException $e) {
@@ -42,7 +42,7 @@ function testDynamicAllowedValues() {
       $this->entity->test_options[LANGUAGE_NOT_SPECIFIED][0]['value'] = is_numeric($value) ? (100 - $value) : ('X' . $value);
       $pass = FALSE;
       try {
-        field_attach_validate('test_entity', $this->entity);
+        field_attach_validate($this->entity);
       }
       catch (FieldValidationException $e) {
         $pass = TRUE;
diff --git a/core/modules/options/options.api.php b/core/modules/options/options.api.php
index d622137039da..2a303d5c7b2c 100644
--- a/core/modules/options/options.api.php
+++ b/core/modules/options/options.api.php
@@ -19,9 +19,7 @@
  *   The instance definition. It is recommended to only use instance level
  *   properties to filter out values from a list defined by field level
  *   properties.
- * @param $entity_type
- *   The entity type the field is attached to.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity object the field is attached to, or NULL if no entity
  *   exists (e.g. in field settings page).
  *
@@ -34,7 +32,7 @@
  *   widget. The HTML tags defined in _field_filter_xss_allowed_tags() are
  *   allowed, other tags will be filtered.
  */
-function hook_options_list($field, $instance, $entity_type, $entity) {
+function hook_options_list($field, $instance, $entity) {
   // Sample structure.
   $options = array(
     0 => t('Zero'),
diff --git a/core/modules/options/options.module b/core/modules/options/options.module
index d81896627b4b..b49d16b89393 100644
--- a/core/modules/options/options.module
+++ b/core/modules/options/options.module
@@ -5,9 +5,9 @@
  * Defines selection, check box and radio button widgets for text and numeric fields.
  */
 
-use Drupal\field\FieldUpdateForbiddenException;
 use Drupal\Component\Utility\NestedArray;
-use Drupal\Core\Entity\Query\QueryFactory;
+use Drupal\Core\Entity\EntityInterface;
+use Drupal\field\FieldUpdateForbiddenException;
 
 /**
  * Implements hook_help().
@@ -238,16 +238,14 @@ function options_field_update_field($field, $prior_field, $has_data) {
  *   The field definition.
  * @param $instance
  *   (optional) A field instance array. Defaults to NULL.
- * @param $entity_type
- *   (optional) The type of entity; e.g. 'node' or 'user'. Defaults to NULL.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   (optional) The entity object. Defaults to NULL.
  *
  * @return
  *   The array of allowed values. Keys of the array are the raw stored values
  *   (number or text), values of the array are the display labels.
  */
-function options_allowed_values($field, $instance = NULL, $entity_type = NULL, $entity = NULL) {
+function options_allowed_values($field, $instance = NULL, EntityInterface $entity = NULL) {
   $allowed_values = &drupal_static(__FUNCTION__, array());
 
   if (!isset($allowed_values[$field['id']])) {
@@ -257,7 +255,7 @@ function options_allowed_values($field, $instance = NULL, $entity_type = NULL, $
     // generating dynamic and uncached values.
     $cacheable = TRUE;
     if (!empty($function)) {
-      $values = $function($field, $instance, $entity_type, $entity, $cacheable);
+      $values = $function($field, $instance, $entity, $cacheable);
     }
     else {
       $values = $field['settings']['allowed_values'];
@@ -409,8 +407,8 @@ function _options_values_in_use($field, $values) {
  * Possible error codes:
  * - 'list_illegal_value': The value is not part of the list of allowed values.
  */
-function options_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
-  $allowed_values = options_allowed_values($field, $instance, $entity_type, $entity);
+function options_field_validate(EntityInterface $entity = NULL, $field, $instance, $langcode, $items, &$errors) {
+  $allowed_values = options_allowed_values($field, $instance, $entity);
   foreach ($items as $delta => $item) {
     if (!empty($item['value'])) {
       if (!empty($allowed_values) && !isset($allowed_values[$item['value']])) {
@@ -486,7 +484,7 @@ function options_field_widget_form(&$form, &$form_state, $field, $instance, $lan
   $entity = $element['#entity'];
 
   // Prepare the list of options.
-  $options = _options_get_options($field, $instance, $properties, $entity_type, $entity);
+  $options = _options_get_options($field, $instance, $properties, $entity);
 
   // Put current field values in shape.
   $default_value = _options_storage_to_form($items, $options, $value_key, $properties);
@@ -655,9 +653,9 @@ function _options_properties($type, $multiple, $required, $has_value) {
 /**
  * Collects the options for a field.
  */
-function _options_get_options($field, $instance, $properties, $entity_type, $entity) {
+function _options_get_options($field, $instance, $properties, EntityInterface $entity) {
   // Get the list of options.
-  $options = (array) module_invoke($field['module'], 'options_list', $field, $instance, $entity_type, $entity);
+  $options = (array) module_invoke($field['module'], 'options_list', $field, $instance, $entity);
 
   // Sanitize the options.
   _options_prepare_options($options, $properties);
@@ -827,8 +825,8 @@ function options_field_widget_error($element, $error, $form, &$form_state) {
 /**
  * Implements hook_options_list().
  */
-function options_options_list($field, $instance, $entity_type, $entity) {
-  return options_allowed_values($field, $instance, $entity_type, $entity);
+function options_options_list($field, $instance, $entity) {
+  return options_allowed_values($field, $instance, $entity);
 }
 
 /**
@@ -880,12 +878,12 @@ function options_field_formatter_info() {
 /**
  * Implements hook_field_formatter_view().
  */
-function options_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
+function options_field_formatter_view(EntityInterface $entity, $field, $instance, $langcode, $items, $display) {
   $element = array();
 
   switch ($display['type']) {
     case 'list_default':
-      $allowed_values = options_allowed_values($field, $instance, $entity_type, $entity);
+      $allowed_values = options_allowed_values($field, $instance, $entity);
       foreach ($items as $delta => $item) {
         if (isset($allowed_values[$item['value']])) {
           $output = field_filter_xss($allowed_values[$item['value']]);
diff --git a/core/modules/options/tests/options_test.module b/core/modules/options/tests/options_test.module
index 2f92a6659df3..90f6bf126287 100644
--- a/core/modules/options/tests/options_test.module
+++ b/core/modules/options/tests/options_test.module
@@ -5,10 +5,12 @@
  * Helper module for the List module tests.
  */
 
+use Drupal\Core\Entity\EntityInterface;
+
 /**
  * Allowed values callback.
  */
-function options_test_allowed_values_callback($field, $instance, $entity_type, $entity) {
+function options_test_allowed_values_callback($field, $instance, $entity) {
   $values = array(
     'Group 1' => array(
       0 => 'Zero',
@@ -25,7 +27,7 @@ function options_test_allowed_values_callback($field, $instance, $entity_type, $
 /**
  * An entity-bound allowed values callback.
  */
-function options_test_dynamic_values_callback($field, $instance, $entity_type, $entity, &$cacheable) {
+function options_test_dynamic_values_callback($field, $instance, EntityInterface $entity, &$cacheable) {
   $cacheable = FALSE;
   // We need the values of the entity as keys.
   return drupal_map_assoc(array(
diff --git a/core/modules/poll/poll.module b/core/modules/poll/poll.module
index 6acc7a483154..035d6fc48619 100644
--- a/core/modules/poll/poll.module
+++ b/core/modules/poll/poll.module
@@ -5,6 +5,7 @@
  * Collects votes on different topics in the form of multiple choice questions.
  */
 
+use Drupal\Core\Entity\EntityInterface;
 use Drupal\node\Plugin\Core\Entity\Node;
 
 /**
@@ -436,8 +437,8 @@ function poll_validate($node, $form) {
 /**
  * Implements hook_field_attach_prepare_translation_alter().
  */
-function poll_field_attach_prepare_translation_alter(&$entity, $context) {
-  if ($context['entity_type'] == 'node' && $entity->type == 'poll') {
+function poll_field_attach_prepare_translation_alter(EntityInterface $entity, $context) {
+  if ($entity->entityType() == 'node' && $entity->type == 'poll') {
     $entity->choice = $context['source_entity']->choice;
     foreach ($entity->choice as $i => $choice) {
       $entity->choice[$i]['chvotes'] = 0;
diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php
index 17922962e288..7e95a0347873 100644
--- a/core/modules/system/system.api.php
+++ b/core/modules/system/system.api.php
@@ -3497,7 +3497,7 @@ function hook_tokens_alter(array &$replacements, array $context) {
     // Alter the [node:title] token, and replace it with the rendered content
     // of a field (field_title).
     if (isset($context['tokens']['title'])) {
-      $title = field_view_field('node', $node, 'field_title', 'default', $langcode);
+      $title = field_view_field($node, 'field_title', 'default', $langcode);
       $replacements[$context['tokens']['title']] = drupal_render($title);
     }
   }
diff --git a/core/modules/system/tests/modules/form_test/form_test.module b/core/modules/system/tests/modules/form_test/form_test.module
index 7120c7ed8fb3..9fd4bcb2f816 100644
--- a/core/modules/system/tests/modules/form_test/form_test.module
+++ b/core/modules/system/tests/modules/form_test/form_test.module
@@ -2188,7 +2188,7 @@ function form_test_form_user_register_form_alter(&$form, &$form_state) {
     $node = entity_create('node', array(
       'type' => 'page',
     ));
-    field_attach_form('node', $node, $form, $form_state);
+    field_attach_form($node, $form, $form_state);
   }
 }
 
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_default/Tid.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_default/Tid.php
index b09ed5a0b312..de848da334ed 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_default/Tid.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_default/Tid.php
@@ -139,7 +139,7 @@ function get_argument() {
         foreach ($fields as $name => $info) {
           $field_info = field_info_field($name);
           if ($field_info['type'] == 'taxonomy_term_reference') {
-            $items = field_get_items('node', $node, $name);
+            $items = field_get_items($node, $name);
             if (is_array($items)) {
               foreach ($items as $item) {
                 $taxonomy[$item['tid']] = $field_info['settings']['allowed_values'][0]['vocabulary'];
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php
index 25bcc074dcca..8c5571ca8880 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php
@@ -100,7 +100,7 @@ function testTaxonomyTermFieldMultipleVocabularies() {
     $entities = array($id => $entity);
     $display = entity_get_display($entity->entityType(), $entity->bundle(), 'full');
     field_attach_prepare_view('test_entity', $entities, array($entity->bundle() => $display));
-    $entity->content = field_attach_view('test_entity', $entity, $display);
+    $entity->content = field_attach_view($entity, $display);
     $this->content = drupal_render($entity->content);
     $this->assertText($term1->name, 'Term 1 name is displayed.');
     $this->assertText($term2->name, 'Term 2 name is displayed.');
@@ -113,7 +113,7 @@ function testTaxonomyTermFieldMultipleVocabularies() {
     $entities = array($id => $entity);
     $display = entity_get_display($entity->entityType(), $entity->bundle(), 'full');
     field_attach_prepare_view('test_entity', $entities, array($entity->bundle() => $display));
-    $entity->content = field_attach_view('test_entity', $entity, $display);
+    $entity->content = field_attach_view($entity, $display);
     $this->plainTextContent = FALSE;
     $this->content = drupal_render($entity->content);
 
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php
index c20acf7d3efe..d5de5fa5afb9 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php
@@ -80,7 +80,7 @@ function testTaxonomyTermFieldValidation() {
     $term = $this->createTerm($this->vocabulary);
     $entity->{$this->field_name}[$langcode][0]['tid'] = $term->tid;
     try {
-      field_attach_validate('test_entity', $entity);
+      field_attach_validate($entity);
       $this->pass('Correct term does not cause validation error.');
     }
     catch (FieldValidationException $e) {
@@ -91,7 +91,7 @@ function testTaxonomyTermFieldValidation() {
     $bad_term = $this->createTerm($this->createVocabulary());
     $entity->{$this->field_name}[$langcode][0]['tid'] = $bad_term->tid;
     try {
-      field_attach_validate('test_entity', $entity);
+      field_attach_validate($entity);
       $this->fail('Wrong term causes validation error.');
     }
     catch (FieldValidationException $e) {
@@ -125,7 +125,7 @@ function testTaxonomyTermFieldWidgets() {
     $entities = array($id => $entity);
     $display = entity_get_display($entity->entityType(), $entity->bundle(), 'full');
     field_attach_prepare_view('test_entity', $entities, array($entity->bundle() => $display));
-    $entity->content = field_attach_view('test_entity', $entity, $display);
+    $entity->content = field_attach_view($entity, $display);
     $this->content = drupal_render($entity->content);
     $this->assertText($term->label(), 'Term label is displayed.');
 
diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module
index b82d3aa5c406..a15874ef62f6 100644
--- a/core/modules/taxonomy/taxonomy.module
+++ b/core/modules/taxonomy/taxonomy.module
@@ -561,7 +561,7 @@ function template_preprocess_taxonomy_term(&$variables) {
   // values of the field in the language that was selected for display, instead
   // of the raw values in $term->[field_name], which contain all values in all
   // languages.
-  field_attach_preprocess('taxonomy_term', $term, $variables['content'], $variables);
+  field_attach_preprocess($term, $variables['content'], $variables);
 
   // Gather classes, and clean up name so there are no underscores.
   $vocabulary_name_css = str_replace('_', '-', $term->bundle());
@@ -1010,9 +1010,9 @@ function taxonomy_field_widget_info_alter(&$info) {
 /**
  * Implements hook_options_list().
  */
-function taxonomy_options_list($field, $instance, $entity_type, $entity) {
+function taxonomy_options_list($field, $instance, $entity) {
   $function = !empty($field['settings']['options_list_callback']) ? $field['settings']['options_list_callback'] : 'taxonomy_allowed_values';
-  return $function($field, $instance, $entity_type, $entity);
+  return $function($field, $instance, $entity);
 }
 
 /**
@@ -1026,7 +1026,7 @@ function taxonomy_options_list($field, $instance, $entity_type, $entity) {
  * Possible error codes:
  * - 'taxonomy_term_illegal_value': The value is not part of the list of allowed values.
  */
-function taxonomy_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
+function taxonomy_field_validate(EntityInterface $entity = NULL, $field, $instance, $langcode, $items, &$errors) {
   // Build an array of existing term IDs so they can be loaded with
   // taxonomy_term_load_multiple();
   foreach ($items as $delta => $item) {
@@ -1107,7 +1107,7 @@ function taxonomy_field_formatter_info() {
 /**
  * Implements hook_field_formatter_view().
  */
-function taxonomy_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
+function taxonomy_field_formatter_view(EntityInterface $entity, $field, $instance, $langcode, $items, $display) {
   $element = array();
 
   // Terms whose tid is 'autocreate' do not exist
@@ -1169,16 +1169,14 @@ function taxonomy_field_formatter_view($entity_type, $entity, $field, $instance,
  *   The instance definition. It is recommended to only use instance level
  *   properties to filter out values from a list defined by field level
  *   properties.
- * @param $entity_type
- *   The entity type the field is attached to.
- * @param $entity
+ * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity object the field is attached to, or NULL if no entity
  *   exists (e.g. in field settings page).
  *
  * @return
  *   The array of valid terms for this field, keyed by term id.
  */
-function taxonomy_allowed_values($field, $instance, $entity_type, $entity) {
+function taxonomy_allowed_values($field, $instance, EntityInterface $entity) {
   $options = array();
   foreach ($field['settings']['allowed_values'] as $tree) {
     if ($vocabulary = taxonomy_vocabulary_load($tree['vocabulary'])) {
@@ -1369,7 +1367,7 @@ function taxonomy_rdf_mapping() {
  *
  * Create any new terms defined in a freetagging vocabulary.
  */
-function taxonomy_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
+function taxonomy_field_presave(EntityInterface $entity, $field, $instance, $langcode, &$items) {
   foreach ($items as $delta => $item) {
     if ($item['tid'] == 'autocreate') {
       unset($item['tid']);
diff --git a/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php b/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php
index 6bf7fe472b8a..f78396d88249 100644
--- a/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php
+++ b/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php
@@ -77,7 +77,7 @@ function testTextFieldValidation() {
     for ($i = 0; $i <= $max_length + 2; $i++) {
       $entity->{$this->field['field_name']}[$langcode][0]['value'] = str_repeat('x', $i);
       try {
-        field_attach_validate('test_entity', $entity);
+        field_attach_validate($entity);
         $this->assertTrue($i <= $max_length, "Length $i does not cause validation error when max_length is $max_length");
       }
       catch (FieldValidationException $e) {
@@ -144,7 +144,7 @@ function _testTextfieldWidgets($field_type, $widget_type) {
     // Display the entity.
     $entity = field_test_entity_test_load($id);
     $display = entity_get_display($entity->entityType(), $entity->bundle(), 'full');
-    $entity->content = field_attach_view($entity_type, $entity, $display);
+    $entity->content = field_attach_view($entity, $display);
     $this->content = drupal_render($entity->content);
     $this->assertText($value, 'Filtered tags are not displayed');
   }
@@ -213,7 +213,7 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) {
     // Display the entity.
     $entity = field_test_entity_test_load($id);
     $display = entity_get_display($entity->entityType(), $entity->bundle(), 'full');
-    $entity->content = field_attach_view($entity_type, $entity, $display);
+    $entity->content = field_attach_view($entity, $display);
     $this->content = drupal_render($entity->content);
     $this->assertNoRaw($value, 'HTML tags are not displayed.');
     $this->assertRaw(check_plain($value), 'Escaped HTML is displayed correctly.');
@@ -254,7 +254,7 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) {
     entity_get_controller('test_entity')->resetCache(array($id));
     $entity = field_test_entity_test_load($id);
     $display = entity_get_display($entity->entityType(), $entity->bundle(), 'full');
-    $entity->content = field_attach_view($entity_type, $entity, $display);
+    $entity->content = field_attach_view($entity, $display);
     $this->content = drupal_render($entity->content);
     $this->assertRaw($value, 'Value is displayed unfiltered');
   }
diff --git a/core/modules/text/text.module b/core/modules/text/text.module
index 7e92375592d9..a67903ca0721 100644
--- a/core/modules/text/text.module
+++ b/core/modules/text/text.module
@@ -5,6 +5,8 @@
  * Defines simple text field types.
  */
 
+use Drupal\Core\Entity\EntityInterface;
+
 /**
  * Implements hook_help().
  */
@@ -118,7 +120,7 @@ function text_field_instance_settings_form($field, $instance) {
  * - text_value_max_length: The value exceeds the maximum length.
  * - text_summary_max_length: The summary exceeds the maximum length.
  */
-function text_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
+function text_field_validate(EntityInterface $entity = NULL, $field, $instance, $langcode, $items, &$errors) {
   foreach ($items as $delta => $item) {
     // @todo Length is counted separately for summary and value, so the maximum
     //   length can be exceeded very easily.
@@ -327,7 +329,7 @@ function text_summary($text, $format = NULL, $size = NULL) {
 /**
  * Implements hook_field_prepare_translation().
  */
-function text_field_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) {
+function text_field_prepare_translation(EntityInterface $entity, $field, $instance, $langcode, &$items, EntityInterface $source_entity, $source_langcode) {
   // If the translating user is not permitted to use the assigned text format,
   // we must not expose the source values.
   $field_name = $field['field_name'];
diff --git a/core/modules/translation/translation.module b/core/modules/translation/translation.module
index 69d01c35b8bb..c29fe6a19744 100644
--- a/core/modules/translation/translation.module
+++ b/core/modules/translation/translation.module
@@ -337,7 +337,7 @@ function translation_node_prepare(Node $node) {
 
     // Add field translations and let other modules module add custom translated
     // fields.
-    field_attach_prepare_translation('node', $node, $node->langcode, $source_node, $source_node->langcode);
+    field_attach_prepare_translation($node, $node->langcode, $source_node, $source_node->langcode);
   }
 }
 
diff --git a/core/modules/translation_entity/translation_entity.admin.inc b/core/modules/translation_entity/translation_entity.admin.inc
index 4520ab023e5c..b6ceba0062c0 100644
--- a/core/modules/translation_entity/translation_entity.admin.inc
+++ b/core/modules/translation_entity/translation_entity.admin.inc
@@ -414,8 +414,8 @@ function _translation_entity_update_field($entity_type, EntityInterface $entity,
   // otherwise any stored empty field value would be deleted. If this happens
   // the range queries would be messed up.
   if ($empty < count($entity->{$field_name})) {
-    field_attach_presave($entity_type, $entity);
-    field_attach_update($entity_type, $entity);
+    field_attach_presave($entity);
+    field_attach_update($entity);
   }
 }
 
diff --git a/core/modules/user/lib/Drupal/user/RegisterFormController.php b/core/modules/user/lib/Drupal/user/RegisterFormController.php
index 23b4d790adff..2a844120e313 100644
--- a/core/modules/user/lib/Drupal/user/RegisterFormController.php
+++ b/core/modules/user/lib/Drupal/user/RegisterFormController.php
@@ -43,7 +43,7 @@ public function form(array $form, array &$form_state, EntityInterface $account)
 
     // Attach field widgets, and hide the ones where the 'user_register_form'
     // setting is not on.
-    field_attach_form('user', $account, $form, $form_state);
+    field_attach_form($account, $form, $form_state);
     foreach (field_info_instances('user', 'user') as $field_name => $instance) {
       if (empty($instance['settings']['user_register_form'])) {
         $form[$field_name]['#access'] = FALSE;
diff --git a/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc
index a80525830abc..c1b93496a8a5 100644
--- a/core/modules/user/user.pages.inc
+++ b/core/modules/user/user.pages.inc
@@ -200,7 +200,7 @@ function template_preprocess_user(&$variables) {
   }
 
   // Preprocess fields.
-  field_attach_preprocess('user', $account, $variables['elements'], $variables);
+  field_attach_preprocess($account, $variables['elements'], $variables);
 }
 
 /**
-- 
GitLab