protected function YamlFormEntityElementsValidator::getLineNumbers in YAML Form 8
Get the line numbers for given pattern in the form's elements string.
Parameters
string $pattern: A regular expression.
Return value
array An array of line numbers.
2 calls to YamlFormEntityElementsValidator::getLineNumbers()
- YamlFormEntityElementsValidator::validateDuplicateNames in src/
YamlFormEntityElementsValidator.php - Validate elements does not contain duplicate names.
- YamlFormEntityElementsValidator::validateProperties in src/
YamlFormEntityElementsValidator.php - Validate that elements are not using ignored properties.
File
- src/
YamlFormEntityElementsValidator.php, line 388
Class
- YamlFormEntityElementsValidator
- Defines a class to validate form elements.
Namespace
Drupal\yamlformCode
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;
}