Skip to content

Instantly share code, notes, and snippets.

@xuxucode
Created February 13, 2018 03:15
Show Gist options
  • Select an option

  • Save xuxucode/764456ebe72fc12849b67df03c7fb2c0 to your computer and use it in GitHub Desktop.

Select an option

Save xuxucode/764456ebe72fc12849b67df03c7fb2c0 to your computer and use it in GitHub Desktop.

Revisions

  1. xuxucode created this gist Feb 13, 2018.
    25 changes: 25 additions & 0 deletions commerce_return_null_than_false.patch
    Original 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);