public function YamlFormHandlerFormBase::getUniqueMachineName in YAML Form 8
Generates a unique machine name for a form handler instance.
Parameters
\Drupal\yamlform\YamlFormHandlerInterface $handler: The form handler.
Return value
string Returns the unique name.
1 call to YamlFormHandlerFormBase::getUniqueMachineName()
File
- src/
Form/ YamlFormHandlerFormBase.php, line 210
Class
- YamlFormHandlerFormBase
- Provides a base form for form handlers.
Namespace
Drupal\yamlform\FormCode
public function getUniqueMachineName(YamlFormHandlerInterface $handler) {
$suggestion = $handler
->getPluginId();
$count = 1;
$machine_default = $suggestion;
$instance_ids = $this->yamlform
->getHandlers()
->getInstanceIds();
while (isset($instance_ids[$machine_default])) {
$machine_default = $suggestion . '_' . $count++;
}
// Only return a suggestion if it is not the default plugin id.
return $machine_default != $handler
->getPluginId() ? $machine_default : '';
}