@@ 1100-1127 (lines=28) @@ | ||
1097 | * |
|
1098 | * @return array |
|
1099 | */ |
|
1100 | protected function getEntityDefaultValues($scope, $className = null, $metadata = null) |
|
1101 | { |
|
1102 | $propertyConfig = $this->getPropertyConfig($scope); |
|
1103 | ||
1104 | // try to get default values from an annotation |
|
1105 | if ($metadata && isset($metadata->defaultValues[$scope])) { |
|
1106 | // combine them with default values from a config file |
|
1107 | $defaultValues = array_merge( |
|
1108 | $propertyConfig->getDefaultValues(PropertyConfigContainer::TYPE_ENTITY), |
|
1109 | $metadata->defaultValues[$scope] |
|
1110 | ); |
|
1111 | } else { |
|
1112 | $defaultValues = $propertyConfig->getDefaultValues(PropertyConfigContainer::TYPE_ENTITY); |
|
1113 | } |
|
1114 | ||
1115 | // process translatable values |
|
1116 | if ($className) { |
|
1117 | $translatablePropertyNames = $propertyConfig->getTranslatableValues(PropertyConfigContainer::TYPE_ENTITY); |
|
1118 | foreach ($translatablePropertyNames as $propertyName) { |
|
1119 | if (empty($defaultValues[$propertyName])) { |
|
1120 | $defaultValues[$propertyName] = |
|
1121 | ConfigHelper::getTranslationKey($scope, $propertyName, $className); |
|
1122 | } |
|
1123 | } |
|
1124 | } |
|
1125 | ||
1126 | return $defaultValues; |
|
1127 | } |
|
1128 | ||
1129 | /** |
|
1130 | * Extracts field default values from an annotation and config file |
|
@@ 1140-1165 (lines=26) @@ | ||
1137 | * |
|
1138 | * @return array |
|
1139 | */ |
|
1140 | protected function getFieldDefaultValues($scope, $className, $fieldName, $fieldType, $metadata = null) |
|
1141 | { |
|
1142 | $propertyConfig = $this->getPropertyConfig($scope); |
|
1143 | ||
1144 | // try to get default values from an annotation |
|
1145 | if ($metadata && isset($metadata->defaultValues[$scope])) { |
|
1146 | // combine them with default values from a config file |
|
1147 | $defaultValues = array_merge( |
|
1148 | $propertyConfig->getDefaultValues(PropertyConfigContainer::TYPE_FIELD, $fieldType), |
|
1149 | $metadata->defaultValues[$scope] |
|
1150 | ); |
|
1151 | } else { |
|
1152 | $defaultValues = $propertyConfig->getDefaultValues(PropertyConfigContainer::TYPE_FIELD, $fieldType); |
|
1153 | } |
|
1154 | ||
1155 | // process translatable values |
|
1156 | $translatablePropertyNames = $propertyConfig->getTranslatableValues(PropertyConfigContainer::TYPE_FIELD); |
|
1157 | foreach ($translatablePropertyNames as $propertyName) { |
|
1158 | if (empty($defaultValues[$propertyName])) { |
|
1159 | $defaultValues[$propertyName] = |
|
1160 | ConfigHelper::getTranslationKey($scope, $propertyName, $className, $fieldName); |
|
1161 | } |
|
1162 | } |
|
1163 | ||
1164 | return $defaultValues; |
|
1165 | } |
|
1166 | ||
1167 | /** |
|
1168 | * Updates values of the given config based on the given default values and $force flag |