diff --git a/core/modules/language/language.module b/core/modules/language/language.module index e2cfac7..5acdd60 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -6,9 +6,7 @@ */ use Drupal\Component\Utility\String; -use Drupal\Core\Entity\ContentEntityType; -use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Entity\EntityForm; +use Drupal\Core\Entity\EntityFormInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Routing\RouteMatchInterface; @@ -187,14 +185,13 @@ function language_configuration_element_submit(&$form, FormStateInterface $form_ // In case we are editing a bundle, we must check the new bundle name, // because e.g. hook_ENTITY_update fired before. $form_object = $form_state->getFormObject(); - if ($form_object instanceof EntityForm && !$form_object->getEntity()->isNew() && ($form_object->getOperation() === 'default' || $form_object->getOperation() === 'edit')) { - /** @var EntityForm $form_object */ + if ($form_object instanceof EntityFormInterface && !$form_object->getEntity()->isNew() && in_array($form_object->getOperation(), ['default', 'edit'])) { + /** @var EntityFormInterface $form_object */ $entity = $form_object->getEntity(); if ($entity->getEntityType()->getBundleOf()) { $bundle = $entity->id(); } } - /** @var ContentLanguageSettings $config */ $config = ContentLanguageSettings::loadByEntityTypeBundle($entity_type_id, $bundle); $config->setDefaultLangcode($form_state->getValue(array($element_name, 'langcode'))); $config->setLanguageAlterable($form_state->getValue(array($element_name, 'language_alterable'))); diff --git a/core/modules/language/src/ContentLanguageSettingsException.php b/core/modules/language/src/ContentLanguageSettingsException.php new file mode 100644 index 0000000..75592f5 --- /dev/null +++ b/core/modules/language/src/ContentLanguageSettingsException.php @@ -0,0 +1,13 @@ +getStorage('language_content_settings')->load($entity_type_id . '.' . $bundle); @@ -162,7 +199,9 @@ public function calculateDependencies() { if ($bundle_entity_type_id != 'bundle') { // If the target entity type uses entities to manage its bundles then // depend on the bundle entity. - $bundle_entity = $this->entityManager()->getStorage($bundle_entity_type_id)->load($this->target_bundle); + if (!$bundle_entity = $this->entityManager()->getStorage($bundle_entity_type_id)->load($this->target_bundle)) { + throw new \LogicException(String::format('Missing bundle entity, entity type %type, entity id %bundle.', array('%type' => $bundle_entity_type_id, '%bundle' => $this->target_bundle))); + } $this->addDependency('config', $bundle_entity->getConfigDependencyName()); } return $this->dependencies;