From 79f2aaf7ec027a1095ccdd4b3d0b5cdf2df47c5f Mon Sep 17 00:00:00 2001
From: Mac_Weber <Mac_Weber@789986.no-reply.drupal.org>
Date: Mon, 28 Dec 2015 18:22:34 -0200
Subject: [PATCH] Issue #2641562 by Mac_Weber: Replace deprecated usage of
 entity_create('entity_view_display') with a direct call to
 EntityViewDisplay::create()

---
 core/includes/entity.inc                                 | 3 ++-
 core/modules/simpletest/src/Tests/KernelTestBaseTest.php | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/core/includes/entity.inc b/core/includes/entity.inc
index 70e8019..6dc8953 100644
--- a/core/includes/entity.inc
+++ b/core/includes/entity.inc
@@ -6,6 +6,7 @@
  */
 
 use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Entity\Entity\EntityViewDisplay;
 
 /**
  * Clears the entity render cache for all entity types.
@@ -469,7 +470,7 @@ function entity_get_display($entity_type, $bundle, $view_mode) {
   // configuration entries are only created when a display object is explicitly
   // configured and saved.
   if (!$display) {
-    $display = entity_create('entity_view_display', array(
+    $display = EntityViewDisplay::create(array(
       'targetEntityType' => $entity_type,
       'bundle' => $bundle,
       'mode' => $view_mode,
diff --git a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php
index 2187ccc..104a027 100644
--- a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php
+++ b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php
@@ -9,6 +9,7 @@
 
 use Drupal\Core\Database\Database;
 use Drupal\simpletest\KernelTestBase;
+use Drupal\Core\Entity\Entity\EntityViewDisplay;
 
 /**
  * Tests KernelTestBase functionality.
@@ -272,7 +273,7 @@ function testEnableModulesFixedList() {
     $this->enableModules(array('field_test'));
 
     // Create a field.
-    entity_create('entity_view_display', array(
+    EntityViewDisplay::create(array(
       'targetEntityType' => 'entity_test',
       'bundle' => 'entity_test',
       'mode' => 'default',
-- 
2.1.4

