public function WebformOptionsCustomStorage::getUsedByWebforms in Webform 8.5
Same name and namespace in other branches
- 6.x modules/webform_options_custom/src/WebformOptionsCustomStorage.php \Drupal\webform_options_custom\WebformOptionsCustomStorage::getUsedByWebforms()
Get list of webform that use the specified webform custom options.
Parameters
\Drupal\webform_options_custom\WebformOptionsCustomInterface $webform_options_custom: A webform options custom entity.
Return value
array A list of webform that use the specified webform custom options
Overrides WebformOptionsCustomStorageInterface::getUsedByWebforms
File
- modules/
webform_options_custom/ src/ WebformOptionsCustomStorage.php, line 58
Class
- WebformOptionsCustomStorage
- Storage controller class for "webform_options_custom" configuration entities.
Namespace
Drupal\webform_options_customCode
public function getUsedByWebforms(WebformOptionsCustomInterface $webform_options_custom) {
if (!isset($this->usedByWebforms)) {
// Looping through webform configuration instead of webform entities to
// improve performance.
$this->usedByWebforms = [];
foreach ($this->configFactory
->listAll('webform.webform.') as $webform_config_name) {
$config = $this->configFactory
->get($webform_config_name);
$element_data = Yaml::encode($config
->get('elements'));
if (preg_match_all('/webform_options_custom(?:_entity)?\\:([a-z_]+)\'/', $element_data, $matches)) {
$webform_id = $config
->get('id');
$webform_title = $config
->get('title');
foreach ($matches[1] as $options_id) {
$this->usedByWebforms[$options_id][$webform_id] = $webform_title;
}
}
}
}
$options_id = $webform_options_custom
->id();
return isset($this->usedByWebforms[$options_id]) ? $this->usedByWebforms[$options_id] : [];
}