You are here

protected function EasyEmail::addEntityReferenceById in Easy Email 8

Same name and namespace in other branches
  1. 2.0.x src/Entity/EasyEmail.php \Drupal\easy_email\Entity\EasyEmail::addEntityReferenceById()

Add an entity by ID to the an entity reference field item list.

Parameters

int $id:

string $field_name:

Return value

$this

4 calls to EasyEmail::addEntityReferenceById()
EasyEmail::addAttachment in src/Entity/EasyEmail.php
@inheritDoc
EasyEmail::addBCC in src/Entity/EasyEmail.php
@inheritDoc
EasyEmail::addCC in src/Entity/EasyEmail.php
@inheritDoc
EasyEmail::addRecipient in src/Entity/EasyEmail.php
@inheritDoc

File

src/Entity/EasyEmail.php, line 840

Class

EasyEmail
Defines the Email entity.

Namespace

Drupal\easy_email\Entity

Code

protected function addEntityReferenceById($id, $field_name) {
  $ids = $this
    ->getEntityReferenceIds($this
    ->get($field_name));
  if (!is_null($ids) && !in_array($id, $ids)) {
    $ids[] = $id;
    $this
      ->set($field_name, $ids);
  }
  return $this;
}