/**
  * @test
  */
 function mergeLocallangXmlWithXlf()
 {
     $this->markTestSkipped('The support for merging xml files with xlf is postponed.');
     $existingFile = t3lib_extmgm::extPath('extension_builder') . 'Tests/Examples/Tools/existing_locallang.xml';
     $newXlf = "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>\n\t\t\t<xliff version='1.0'>\n\t\t\t\t<file source-language='en' datatype='plaintext' original='messages' date='2012-03-47T19:00:47Z' product-name='test123'>\n\t\t\t\t\t<header/>\n\t\t\t\t\t<body>\n\t\t\t\t\t\t<trans-unit id='tx_test_index1'>\n\t\t\t\t\t\t\t<source>Label 1</source>\n\t\t\t\t\t\t</trans-unit>\n\t\t\t\t\t\t<trans-unit id='tx_test_index3'>\n\t\t\t\t\t\t\t<source>Additional label 3</source>\n\t\t\t\t\t\t</trans-unit>\n\t\t\t\t\t</body>\n\t\t\t\t</file>\n\t\t\t</xliff>";
     $result = Tx_ExtensionBuilder_Utility_Tools::mergeLocallangXml($existingFile, $newXlf, 'xlf');
     $expected = array('tx_test_index1' => 'Label 1 modified', 'tx_test_index3' => 'Additional label 3', 'tx_test_index2' => 'Label 2');
     $this->assertEquals($result, $expected);
 }
 /**
  *
  * @param string $encodeType (optional) default encode possible: decode, encode
  * @param boolean $arraysAsPhpNotation (optional) should arrays be notated as php arrays?
  * @return mixed the encoded string or decoded data
  */
 public function render($encodeType = 'encode', $arraysAsPhpNotation = TRUE)
 {
     $content = $this->renderChildren();
     if ($encodeType == 'decode') {
         return json_decode($content);
     } else {
         $content = json_encode($content);
         if ($arraysAsPhpNotation) {
             $content = Tx_ExtensionBuilder_Utility_Tools::convertJSONArrayToPHPArray($content);
         }
         return $content;
     }
 }
 /**
  * This methods renders the parameters of a method, including typeHints and default values.
  *
  * @param $methodObject
  * @return string parameters
  */
 private function renderMethodParameter($methodObject)
 {
     $parameters = array();
     if (is_array($methodObject->getParameters())) {
         foreach ($methodObject->getParameters() as $parameter) {
             $parameterName = $parameter->getName();
             $typeHint = $parameter->getTypeHint();
             if ($parameter->isOptional()) {
                 $defaultValue = $parameter->getDefaultValue();
                 // optional parameters have a default value
                 if (!empty($typeHint)) {
                     // typeHints of optional parameter have the format "typeHint or defaultValue"
                     $typeHintParts = explode(' ', $typeHint);
                     $typeHint = $typeHintParts[0];
                 }
                 // the default value has to be json_encoded to render its string representation
                 if (is_array($defaultValue)) {
                     if (!empty($defaultValue)) {
                         $defaultValue = json_encode($defaultValue);
                         // now we render php notation from JSON notation
                         $defaultValue = Tx_ExtensionBuilder_Utility_Tools::convertJSONArrayToPHPArray($defaultValue);
                         //t3lib_div::devLog('default Value: '. $defaultValue, 'parameter debug');
                     } else {
                         $defaultValue = 'array()';
                     }
                 } elseif ($defaultValue === NULL) {
                     $defaultValue = 'NULL';
                 } else {
                     $defaultValue = json_encode($defaultValue);
                 }
                 $parameterName .= ' = ' . $defaultValue;
             }
             $parameterName = '$' . $parameterName;
             if ($parameter->isPassedByReference()) {
                 $parameterName = '&' . $parameterName;
             }
             if (!empty($typeHint)) {
                 $parameterName = $typeHint . ' ' . $parameterName;
             }
             $parameters[] = $parameterName;
             //t3lib_div::devLog($methodSchemaObject->getName().':'.$parameter->getName(), 'parameter debug');
         }
     }
     return implode(', ', $parameters);
 }
 /**
  * @param string $fileNameSuffix
  * @param string $variableName
  * @param null $variable
  * @return mixed
  */
 protected function generateLocallangFileContent($fileNameSuffix = '', $variableName = '', $variable = NULL)
 {
     $targetFile = 'Resources/Private/Language/locallang' . $fileNameSuffix;
     $variableArray = array('extension' => $this->extension);
     if (strlen($variableName) > 0) {
         $variableArray[$variableName] = $variable;
     }
     if ($this->roundTripEnabled && Tx_ExtensionBuilder_Service_RoundTrip::getOverWriteSettingForPath($targetFile . '.' . $this->locallangFileFormat, $this->extension) == 1) {
         $existingFile = NULL;
         $filenameToLookFor = $this->extensionDirectory . $targetFile;
         if ($variableName == 'domainObject') {
             $filenameToLookFor .= '_' . $variable->getDatabaseTableName();
         }
         if (file_exists($filenameToLookFor . '.xlf')) {
             $existingFile = $filenameToLookFor . '.xlf';
         } else {
             if (file_exists($filenameToLookFor . '.xml')) {
                 $existingFile = $filenameToLookFor . '.xml';
             }
         }
         if ($existingFile != NULL) {
             $defaultFileContent = $this->renderTemplate($targetFile . '.' . $this->locallangFileFormat . 't', $variableArray);
             if ($this->locallangFileFormat == 'xlf') {
                 throw new Exception('Merging xlf files is not yet supported. Please set overwrite settings to "keep" or "overwrite"');
                 // this is prepared already but still needs some improvements
                 //$labelArray = Tx_ExtensionBuilder_Utility_Tools::mergeLocallangXml($existingFile, $defaultFileContent, $this->locallangFileFormat);
                 //$variableArray['labelArray'] = $labelArray;
             } else {
                 return Tx_ExtensionBuilder_Utility_Tools::mergeLocallangXml($existingFile, $defaultFileContent);
             }
         }
     }
     return $this->renderTemplate($targetFile . '.' . $this->locallangFileFormat . 't', $variableArray);
 }