/**
  * Generate the tokens
  *
  * @param array $arrData
  * @param array $arrForm
  * @param array $arrFiles
  * @param array $arrLabels
  *
  * @return array
  */
 public function generateTokens(array $arrData, array $arrForm, array $arrFiles, array $arrLabels)
 {
     $arrTokens = array();
     $arrTokens['raw_data'] = '';
     foreach ($arrData as $k => $v) {
         \Haste\Util\StringUtil::flatten($v, 'form_' . $k, $arrTokens);
         $arrTokens['raw_data'] .= (isset($arrLabels[$k]) ? $arrLabels[$k] : ucfirst($k)) . ': ' . (is_array($v) ? implode(', ', $v) : $v) . "\n";
     }
     foreach ($arrForm as $k => $v) {
         \Haste\Util\StringUtil::flatten($v, 'formconfig_' . $k, $arrTokens);
     }
     // Administrator e-mail
     $arrTokens['admin_email'] = $GLOBALS['TL_ADMIN_EMAIL'];
     // Upload fields
     foreach ($arrFiles as $fieldName => $file) {
         $arrTokens['form_' . $fieldName] = Form::getFileUploadPathForToken($file);
     }
     return $arrTokens;
 }
예제 #2
0
 /**
  * @param mixed  $value
  * @param string $key
  * @param array  $data
  * @param array  $expected
  *
  * @dataProvider flattenDataProvider
  */
 public function testFlatten($value, $key, array $data, array $expected)
 {
     StringUtil::flatten($value, $key, $data);
     $this->assertEquals($expected, $data);
 }