예제 #1
0
 public function testReplaceInArray()
 {
     $testArray = array('option' => array('default' => '{0}', 'testKey' => array('{0}' => 'testVal')));
     $testResult = array('option' => array('default' => 'DONE', 'testKey' => array('DONE' => 'testVal')));
     $this->assertEquals($testResult, Util::replaceInArray('{0}', 'DONE', $testArray, true));
 }
예제 #2
0
 protected function getInitValues(array $fieldParams)
 {
     $values = array();
     foreach ($this->fieldAccordances as $espoType => $ormType) {
         if (isset($fieldParams[$espoType])) {
             if (is_array($ormType)) {
                 $conditionRes = false;
                 if (!is_array($fieldParams[$espoType])) {
                     $conditionRes = preg_match('/' . $ormType['condition'] . '/i', $fieldParams[$espoType]);
                 }
                 if (!$conditionRes || $conditionRes && $conditionRes === $ormType['conditionEquals']) {
                     $value = is_array($fieldParams[$espoType]) ? json_encode($fieldParams[$espoType]) : $fieldParams[$espoType];
                     $values = Util::merge($values, Util::replaceInArray('{0}', $value, $ormType['value']));
                 }
             } else {
                 $values[$ormType] = $fieldParams[$espoType];
             }
         }
     }
     return $values;
 }