diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index 330f39c..26b5b30 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -110,4 +110,18 @@ public static function sort($a, $b) { } return ($a_weight < $b_weight) ? -1 : 1; } + + /** + * Implements Drupal\Core\Entity\EntityInterface::getBCEntity(). + */ + public function getBCEntity() { + return $this; + } + + /** + * Implements Drupal\Core\Entity\EntityInterface::getOriginalEntity(). + */ + public function getOriginalEntity() { + return $this; + } } diff --git a/core/lib/Drupal/Core/Entity/EntityBCDecorator.php b/core/lib/Drupal/Core/Entity/EntityBCDecorator.php index b71df50..d9c7a65 100644 --- a/core/lib/Drupal/Core/Entity/EntityBCDecorator.php +++ b/core/lib/Drupal/Core/Entity/EntityBCDecorator.php @@ -69,11 +69,6 @@ public function &__get($name) { // avoid them becoming out of sync. unset($this->decorated->fields[$name]); } - // Make sure reading with the default language code (e.g. 'en') works. - if (isset($this->decorated->values[$name][LANGUAGE_DEFAULT])) { - $langcode = $this->decorated->language()->langcode; - $this->decorated->values[$name][$langcode] = &$this->decorated->values[$name][LANGUAGE_DEFAULT]; - } if (!isset($this->decorated->values[$name])) { $this->decorated->values[$name] = NULL; } diff --git a/core/lib/Drupal/Core/Entity/EntityNG.php b/core/lib/Drupal/Core/Entity/EntityNG.php index 060a12b..5f0b044 100644 --- a/core/lib/Drupal/Core/Entity/EntityNG.php +++ b/core/lib/Drupal/Core/Entity/EntityNG.php @@ -296,23 +296,29 @@ public function getTranslation($langcode, $strict = TRUE) { */ public function getTranslationLanguages($include_default = TRUE) { $translations = array(); - // Build an array with the translation langcodes set as keys. + // Build an array with the translation langcodes set as keys. Empty + // translations must be filtered out. foreach ($this->getProperties() as $name => $property) { - if (isset($this->values[$name])) { - $translations += $this->values[$name]; + foreach ($this->fields[$name] as $langcode => $field) { + if (!$field->isEmpty()) { + $translations[$langcode] = TRUE; + } + if (isset($this->values[$name])) { + foreach ($this->values[$name] as $langcode => $values) { + if ($values && !(isset($this->fields[$name][$langcode]) && $this->fields[$name][$langcode]->isEmpty())) { + $translations[$langcode] = TRUE; + } + } + } } - $translations += $this->fields[$name]; } unset($translations[LANGUAGE_DEFAULT]); if ($include_default) { $translations[$this->language()->langcode] = TRUE; } - - // Now get languages based upon translation langcodes. Empty languages must - // be filtered out as they concern empty/unset properties. - $languages = array_intersect_key(language_list(LANGUAGE_ALL), array_filter($translations)); - return $languages; + // Now get languages based upon translation langcodes. + return array_intersect_key(language_list(LANGUAGE_ALL), $translations); } /** diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php index 0a10a1c..ec47785 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -257,10 +257,8 @@ public function validate(array $form, array &$form_state) { public function submit(array $form, array &$form_state) { $comment = parent::submit($form, $form_state); - if (empty($comment->date)) { - $comment->date = 'now'; - } - $date = new DrupalDateTime($comment->date); + // @todo: Move populating the entity over to self::buildEntity(). + $date = !empty($form_state['values']['date']) ? $form_state['values']['date'] : 'now'; $comment->created->value = $date; $comment->changed->value = REQUEST_TIME; diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php index 9321b1f..cc13922 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php @@ -24,7 +24,7 @@ * form_controller_class = { * "default" = "Drupal\comment\CommentFormController" * }, - * translation_controller_class = "Drupal\comment\CommentTranslationController", + * translation_controller_class = "Drupal\translation_entity\EntityTranslationControllerNG", * base_table = "comment", * uri_callback = "comment_uri", * fieldable = TRUE, diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index ebadf43..6898f81 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -2061,9 +2061,9 @@ protected function createTypedData($definition, $value = NULL, $context = array( // Assert the definition of the wrapper. $this->assertTrue($data instanceof \Drupal\Core\TypedData\TypedDataInterface, 'Typed data object is an instance of the typed data interface.'); $definition = $data->getDefinition(); - $this->assertTrue(!empty($definition['label']), $definition['label'] . ' data definition was returned.'); + $this->assertTrue(!empty($definition['type']), $definition['type'] . ' data definition was returned.'); // Assert that the correct type was constructed. - $this->assertEqual($data->getType(), $type, $definition['label'] . ' object returned type.'); + $this->assertEqual($data->getType(), $type, $definition['type'] . ' object returned type.'); return $data; } diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestTranslationController.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestTranslationController.php deleted file mode 100644 index e7ca050..0000000 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestTranslationController.php +++ /dev/null @@ -1,28 +0,0 @@ -getTranslation($langcode); - foreach ($translation->getPropertyDefinitions() as $property_name => $langcode) { - $translation->$property_name = array(); - } - } - -} diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php index de7188f..740a5cb 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php @@ -22,7 +22,7 @@ * form_controller_class = { * "default" = "Drupal\entity_test\EntityTestFormController" * }, - * translation_controller_class = "Drupal\entity_test\EntityTestTranslationController", + * translation_controller_class = "Drupal\translation_entity\EntityTranslationControllerNG", * base_table = "entity_test", * data_table = "entity_test_property_data", * fieldable = TRUE, diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationControllerNG.php b/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationControllerNG.php new file mode 100644 index 0000000..8dfc538 --- /dev/null +++ b/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationControllerNG.php @@ -0,0 +1,26 @@ +getTranslation($langcode); + foreach ($translation->getPropertyDefinitions() as $property_name => $langcode) { + $translation->$property_name = array(); + } + } +} diff --git a/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.php b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.php index a1aec9e..ac638ac 100644 --- a/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.php +++ b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.php @@ -1072,4 +1072,17 @@ public function setOriginalID($id) { return $this->__call(__FUNCTION__, func_get_args()); } + /** + * Implements Drupal\Core\Entity\EntityInterface::getBCEntity(). + */ + public function getBCEntity() { + return $this->__call(__FUNCTION__, func_get_args()); + } + + /** + * Implements Drupal\Core\Entity\EntityInterface::getOriginalEntity(). + */ + public function getOriginalEntity() { + return $this->__call(__FUNCTION__, func_get_args()); + } }