Skip to content

Commit

Permalink
Merge branch '8.x' into 8.x-2.x
Browse files Browse the repository at this point in the history
* 8.x:
  Formatting and PHPDoc
  MOC-813-85849 Issue with SBSYS component
  Added parallel composer install plugin
  Added more memory for Travis
  • Loading branch information
stankut committed Mar 13, 2020
2 parents be49857 + 197c833 commit 6466053
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 27 additions & 2 deletions modules/os2forms_sbsys/src/Element/WebformAttachmentSbsysXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit 6466053

Please sign in to comment.