You are here

protected function EasyEmail::removeTextValueFromList in Easy Email 8

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

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

Parameters

string $text:

string $field_name:

Return value

$this

4 calls to EasyEmail::removeTextValueFromList()
EasyEmail::removeAttachmentPath in src/Entity/EasyEmail.php
@inheritDoc
EasyEmail::removeBCCAddress in src/Entity/EasyEmail.php
@inheritDoc
EasyEmail::removeCCAddress in src/Entity/EasyEmail.php
@inheritDoc
EasyEmail::removeRecipientAddress in src/Entity/EasyEmail.php
@inheritDoc

File

src/Entity/EasyEmail.php, line 914

Class

EasyEmail
Defines the Email entity.

Namespace

Drupal\easy_email\Entity

Code

protected function removeTextValueFromList($text, $field_name) {
  $strings = $this
    ->getListTextValues($this
    ->get($field_name));
  if (!is_null($strings)) {
    foreach ($strings as $delta => $value) {
      if ($text === $value) {
        unset($strings[$delta]);
      }
    }
    $this
      ->set($field_name, $strings);
  }
  return $this;
}