public static function WebformOptionsHelper::hasOption in Webform 8.5
Same name and namespace in other branches
- 6.x src/Utility/WebformOptionsHelper.php \Drupal\webform\Utility\WebformOptionsHelper::hasOption()
Determine if the options has a specified value.
Parameters
string $value: An value to look for in the options.
array $options: An associative array of options.
Return value
bool TRUE if the options has a specified value.
4 calls to WebformOptionsHelper::hasOption()
- EmailWebformHandler::buildConfigurationForm in src/
Plugin/ WebformHandler/ EmailWebformHandler.php - Form constructor.
- WebformElementOptions::processWebformElementOptions in src/
Element/ WebformElementOptions.php - Processes a webform element options element.
- WebformOptionsHelperTest::testHasOption in tests/
src/ Unit/ Utility/ WebformOptionsHelperTest.php - Tests WebformOptionsHelper::hasOption().
- WebformOtherBase::convertDefaultValueToElementValue in src/
Element/ WebformOtherBase.php - Convert default value to element value.
File
- src/
Utility/ WebformOptionsHelper.php, line 52
Class
- WebformOptionsHelper
- Helper class webform options based methods.
Namespace
Drupal\webform\UtilityCode
public static function hasOption($value, array $options) {
foreach ($options as $option_value => $option_text) {
if (is_array($option_text)) {
if ($has_value = self::hasOption($value, $option_text)) {
return $has_value;
}
}
elseif ((string) $value === (string) $option_value) {
return TRUE;
}
}
return FALSE;
}