public function WebformImageSelectImagesStorage::getUsedByWebforms in Webform 6.x
Same name and namespace in other branches
- 8.5 modules/webform_image_select/src/WebformImageSelectImagesStorage.php \Drupal\webform_image_select\WebformImageSelectImagesStorage::getUsedByWebforms()
Get list of webform that use the specified webform images.
Parameters
\Drupal\webform_image_select\WebformImageSelectImagesInterface $webform_images: A webform image select images entity.
Return value
array A list of webform that use the specified webform images.
Overrides WebformImageSelectImagesStorageInterface::getUsedByWebforms
File
- modules/
webform_image_select/ src/ WebformImageSelectImagesStorage.php, line 58
Class
- WebformImageSelectImagesStorage
- Storage controller class for "webform_image_select_images" configuration entities.
Namespace
Drupal\webform_image_selectCode
public function getUsedByWebforms(WebformImageSelectImagesInterface $webform_images) {
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('/images\'\\: ([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_images
->id();
return isset($this->usedByWebforms[$options_id]) ? $this->usedByWebforms[$options_id] : [];
}