diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 6377418..0b2362a 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -169,16 +169,6 @@ protected function typedDataManager() { } /** - * Returns the module handler. - * - * @return \Drupal\Core\Extension\ModuleHandlerInterface - * The module handler. - */ - protected function moduleHandler() { - return \Drupal::moduleHandler(); - } - - /** * {@inheritdoc} */ public function setNewRevision($value = TRUE) { diff --git a/core/modules/language/lib/Drupal/language/DefaultLanguageItem.php b/core/modules/language/lib/Drupal/language/DefaultLanguageItem.php index 0d37a8f..fa74bc5 100644 --- a/core/modules/language/lib/Drupal/language/DefaultLanguageItem.php +++ b/core/modules/language/lib/Drupal/language/DefaultLanguageItem.php @@ -2,11 +2,12 @@ /** * @file - * Contains \Drupal\language\DefaultLanguageItem + * Contains \Drupal\language\DefaultLanguageItem. */ namespace Drupal\language; +use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Field\Plugin\Field\FieldType\LanguageItem; use Drupal\Core\Language\Language; @@ -30,11 +31,15 @@ public function applyDefaultValue($notify = TRUE) { // Default to LANGCODE_NOT_SPECIFIED. $langcode = Language::LANGCODE_NOT_SPECIFIED; if ($entity = $this->getEntity()) { - $langcode = language_get_default_langcode($entity->getEntityTypeId(), $entity->bundle()); + $langcode = $this->getDefaultLangcode($entity); } // Always notify otherwise default langcode will not be set correctly. $this->setValue(array('value' => $langcode), TRUE); return $this; } + public function getDefaultLangcode(EntityInterface $entity) { + return language_get_default_langcode($entity->getEntityTypeId(), $entity->bundle()); + } + } diff --git a/core/modules/language/tests/Drupal/language/Tests/EntityDefaultLanguageTest.php b/core/modules/language/tests/Drupal/language/Tests/EntityDefaultLanguageTest.php index 4b8401c..b96d4c7 100644 --- a/core/modules/language/tests/Drupal/language/Tests/EntityDefaultLanguageTest.php +++ b/core/modules/language/tests/Drupal/language/Tests/EntityDefaultLanguageTest.php @@ -34,7 +34,7 @@ public function setUp() { parent::setUp(); // Activate Spanish language, so there are two languages activated. - $language_entity = entity_create('language_entity', array( + $language_entity = $this->container->get('entity.manager')->getStorage('language_entity')->create(array( 'id' => 'es', )); $language_entity->save(); @@ -106,7 +106,7 @@ public function testEntityTranslationDefaultLanguageViaCode() { * Default language code of the nodes of this type. */ protected function createContentType($name, $langcode) { - $content_type = entity_create('node_type', array( + $content_type = $this->container->get('entity.manager')->getStorage('node_type')->create(array( 'name' => 'Test ' . $name, 'title_label' => 'Title', 'type' => $name, @@ -125,7 +125,7 @@ protected function createContentType($name, $langcode) { * @param $type * The node content type. * @param $langcode - * (optional) Language code to pass to entity_create(). + * (optional) Language code to pass to entity create. * * @return \Drupal\node\NodeInterface * The node created. @@ -138,7 +138,7 @@ protected function createNode($type, $langcode = NULL) { if (!empty($langcode)) { $values['langcode'] = $langcode; } - $node = entity_create('node', $values); + $node = $this->container->get('entity.manager')->getStorage('node')->create($values); return $node; }