public static function SupportedEntities::optionToMachineName in CiviCRM Entity 8.3
Transforms an option value to a machine name.
This is leveraged to convert options into bundle names.
Parameters
string $value: The option value.
\Drupal\Component\Transliteration\TransliterationInterface $transliteration: The transliteration service.
Return value
string
5 calls to SupportedEntities::optionToMachineName()
- BundleFieldItemList::computeValue in src/
Plugin/ Field/ BundleFieldItemList.php - Computes the values for an item list.
- BundleFieldItemList::setValue in src/
Plugin/ Field/ BundleFieldItemList.php - This sets the bundle property if Drupal sets a value to `bundle`, which means we have to transliterate the options and convert a machine name to the option key.
- CivicrmEntity::preCreate in src/
Entity/ CivicrmEntity.php - Changes the values of an entity before it is created.
- civicrm_entity_entity_bundle_info in ./
civicrm_entity.module - Implements hook_entity_bundle_info().
- CiviEntityStorage::prepareLoadedEntity in src/
CiviEntityStorage.php - Prepares a loaded entity.
File
- src/
SupportedEntities.php, line 890
Class
- SupportedEntities
- Defines supported entities.
Namespace
Drupal\civicrm_entityCode
public static function optionToMachineName($value, TransliterationInterface $transliteration) {
$value = $transliteration
->transliterate($value, LanguageInterface::LANGCODE_DEFAULT, '_');
$value = mb_strtolower($value);
$value = preg_replace('/[^a-z0-9_]+/', '_', $value);
$value = preg_replace('/_+/', '_', $value);
return $value;
}