diff --git a/.travis.yml b/.travis.yml index 505e9edb..4d72d98b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,11 @@ sudo: false php: - 7.2 +before_install: + - echo "memory_limit=2G" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini + install: + - composer global require hirak/prestissimo - composer global require drush/drush:8.x-dev drupal/coder mglaman/drupal-check friendsoftwig/twigcs - export PATH="$HOME/.config/composer/vendor/bin:$PATH" - phpcs --config-set installed_paths ../../drupal/coder/coder_sniffer diff --git a/modules/os2forms_sbsys/src/Element/WebformAttachmentSbsysXml.php b/modules/os2forms_sbsys/src/Element/WebformAttachmentSbsysXml.php index 0d21a47f..513873d9 100644 --- a/modules/os2forms_sbsys/src/Element/WebformAttachmentSbsysXml.php +++ b/modules/os2forms_sbsys/src/Element/WebformAttachmentSbsysXml.php @@ -179,14 +179,39 @@ protected static function getFirstValueByType($type, WebformSubmissionInterface $webform = $webform_submission->getWebform(); $webform_elements = $webform->getElementsDecoded(); foreach ($webform_elements as $key => $webform_element) { - if ($webform_element['#type'] == $type) { - $value = $webform_submission->getElementData($key); + if ($el_key = self::getElementKeyByType($webform_element, $type, $key)) { + $value = $webform_submission->getElementData($el_key); break; } } return $value; } + /** + * Gets key of first element by field type. + * + * @param array $webform_element + * The element of the webform. + * @param string $type + * Element value type. + * @param string $el_key + * Current element key. + * + * @return mixed + * Element key. + */ + protected static function getElementKeyByType(array $webform_element, $type, $el_key) { + foreach ($webform_element as $key => $value) { + if ($key == '#type' && $value == $type) { + return $el_key; + } + elseif (is_array($value)) { + return self::getElementKeyByType($value, $type, $key); + } + } + return FALSE; + } + /** * Helper function the returns the list of the fields + values as an array. *