public static function YamlFormArrayHelper::addPrefix in YAML Form 8
Add prefix to all top level keys in an associative array.
Parameters
array $array: An associative array.
string $prefix: Prefix to be prepended to all keys.
Return value
array An associative array with all top level keys prefixed.
6 calls to YamlFormArrayHelper::addPrefix()
- YamlFormElementBase::buildConfigurationForm in src/
YamlFormElementBase.php - Form constructor.
- YamlFormElementBase::getConfigurationFormProperties in src/
YamlFormElementBase.php - Get an associative array of element properties from configuration form.
- YamlFormEntitySettingsForm::form in src/
YamlFormEntitySettingsForm.php - Gets the actual form array to be built.
- YamlFormEntitySettingsForm::save in src/
YamlFormEntitySettingsForm.php - Form submission handler for the 'save' action.
- YamlFormTranslationManager::getBaseElements in src/
YamlFormTranslationManager.php - Get base form elements from the site's default language.
File
- src/
Utility/ YamlFormArrayHelper.php, line 183
Class
- YamlFormArrayHelper
- Provides helper to operate on arrays.
Namespace
Drupal\yamlform\UtilityCode
public static function addPrefix(array $array, $prefix = '#') {
$prefixed_array = [];
foreach ($array as $key => $value) {
if ($key[0] != $prefix) {
$key = $prefix . $key;
}
$prefixed_array[$key] = $value;
}
return $prefixed_array;
}