Пример #1
0
 /**
  * @param string $value
  * @param array $variables
  * @param string $expectation
  * @return void
  * @test
  * @dataProvider replaceVariablesInValueMatchingDataProvider
  */
 public function replaceVariablesInValueReturnsStringWithSubstitutedValues($value, $variables, $expectation)
 {
     $this->assertSame($expectation, MarkerUtility::replaceVariablesInValue($value, $variables));
 }
Пример #2
0
 /**
  * @param object $object
  * @param string $property
  * @param array $objectData
  * @param array $settings
  * @param string $key
  * @return mixed
  */
 protected function getPropertyValue($object, $property, $objectData, $settings, $key)
 {
     $value = NULL;
     // Value is configured by settings
     $modelName = $this->getModelName($object);
     if (isset($settings[$modelName][$property])) {
         if ($settings[$modelName][$property] === '{{_KEY_}}') {
             return $key;
         }
         if (is_array($settings[$modelName][$property])) {
             $value = array();
             foreach ($settings[$modelName][$property] as $key => $marker) {
                 $value[$key] = MarkerUtility::replaceVariablesInValue($marker, $objectData);
             }
         } else {
             $value = MarkerUtility::replaceVariablesInValue($settings[$modelName][$property], $objectData);
         }
     } else {
         $dataKeys = array($property, GeneralUtility::camelCaseToLowerCaseUnderscored($property));
         foreach ($dataKeys as $key) {
             if (isset($objectData[$key])) {
                 $value = $objectData[$key];
                 break;
             }
         }
     }
     // Is value an object? If yes, then render it as object
     if (is_array($value)) {
         $className = 'Lightwerk\\SurfCaptain\\Domain\\Model\\' . ucfirst($property);
         if (class_exists($className)) {
             $value = $this->mapToObject($value, $className, $settings);
         }
     }
     return $value;
 }