You are here

protected static function PaymentLineItemsInput::lineItemExists in Payment 8.2

Checks if a line item name already exists.

Parameters

mixed[] $element:

\Drupal\Core\Form\FormStateInterface $form_state:

string $name:

Return value

bool

1 call to PaymentLineItemsInput::lineItemExists()
PaymentLineItemsInput::createLineItemName in src/Element/PaymentLineItemsInput.php
Creates a unique line item name.

File

src/Element/PaymentLineItemsInput.php, line 345

Class

PaymentLineItemsInput
Provides a payment line items configuration element.

Namespace

Drupal\payment\Element

Code

protected static function lineItemExists(array $element, FormStateInterface $form_state, $name) {
  foreach (static::getLineItems($element, $form_state) as $line_item) {
    if ($line_item
      ->getName() == $name) {
      return TRUE;
    }
  }
  return FALSE;
}