You are here

protected function WebformEntityElementsValidator::getLineNumbers in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/WebformEntityElementsValidator.php \Drupal\webform\WebformEntityElementsValidator::getLineNumbers()

Get the line numbers for given pattern in the webform's elements string.

Parameters

string $pattern: A regular expression.

Return value

array An array of line numbers.

3 calls to WebformEntityElementsValidator::getLineNumbers()
WebformEntityElementsValidator::validateDuplicateNames in src/WebformEntityElementsValidator.php
Validate elements does not contain duplicate names.
WebformEntityElementsValidator::validateNames in src/WebformEntityElementsValidator.php
Validate elements names.
WebformEntityElementsValidator::validateProperties in src/WebformEntityElementsValidator.php
Validate that elements are not using ignored properties.

File

src/WebformEntityElementsValidator.php, line 635

Class

WebformEntityElementsValidator
Webform elements validator.

Namespace

Drupal\webform

Code

protected function getLineNumbers($pattern) {
  $lines = explode(PHP_EOL, $this->elementsRaw);
  $line_numbers = [];
  foreach ($lines as $index => $line) {
    if (preg_match($pattern, $line)) {
      $line_numbers[] = $index + 1;
    }
  }
  return $line_numbers;
}