You are here

protected function EasyEmail::removeEntityReferenceById in Easy Email 8

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

Remove 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::removeEntityReferenceById()
EasyEmail::removeAttachment in src/Entity/EasyEmail.php
@inheritDoc
EasyEmail::removeBCC in src/Entity/EasyEmail.php
@inheritDoc
EasyEmail::removeCC in src/Entity/EasyEmail.php
@inheritDoc
EasyEmail::removeRecipient in src/Entity/EasyEmail.php
@inheritDoc

File

src/Entity/EasyEmail.php, line 857

Class

EasyEmail
Defines the Email entity.

Namespace

Drupal\easy_email\Entity

Code

protected function removeEntityReferenceById($id, $field_name) {
  $ids = $this
    ->getEntityReferenceIds($this
    ->get($field_name));
  if (!is_null($ids)) {
    foreach ($ids as $delta => $value) {
      if ($id === $value) {
        unset($ids[$delta]);
      }
    }
    $this
      ->set($field_name, $ids);
  }
  return $this;
}