Created
February 13, 2018 03:15
-
-
Save xuxucode/764456ebe72fc12849b67df03c7fb2c0 to your computer and use it in GitHub Desktop.
Revisions
-
xuxucode created this gist
Feb 13, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ diff --git a/src/Entity/CommerceContentEntityBase.php b/src/Entity/CommerceContentEntityBase.php index 026a79c4f..3e62a878e 100644 --- a/src/Entity/CommerceContentEntityBase.php +++ b/src/Entity/CommerceContentEntityBase.php @@ -23,7 +23,7 @@ public function getTranslatedReferencedEntities($field_name) { */ public function getTranslatedReferencedEntity($field_name) { $referenced_entities = $this->getTranslatedReferencedEntities($field_name); - return reset($referenced_entities); + return reset($referenced_entities) ?: NULL; } /** diff --git a/src/Entity/CommerceContentEntityInterface.php b/src/Entity/CommerceContentEntityInterface.php index d776d1109..387411dea 100644 --- a/src/Entity/CommerceContentEntityInterface.php +++ b/src/Entity/CommerceContentEntityInterface.php @@ -27,7 +27,7 @@ public function getTranslatedReferencedEntities($field_name); * The entity reference field name. * * @return \Drupal\Core\Entity\ContentEntityInterface - * The entity. + * The entity, or NULL if not found. */ public function getTranslatedReferencedEntity($field_name);