diff --git a/src/Oro/Bundle/EntityExtendBundle/Tools/ExtendConfigDumper.php b/src/Oro/Bundle/EntityExtendBundle/Tools/ExtendConfigDumper.php index 7177fd46547..a879882fb3a 100644 --- a/src/Oro/Bundle/EntityExtendBundle/Tools/ExtendConfigDumper.php +++ b/src/Oro/Bundle/EntityExtendBundle/Tools/ExtendConfigDumper.php @@ -253,8 +253,8 @@ protected function checkFields( * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * * @param ConfigInterface $extendConfig - * @param array|null $aliases - * @param array|null $skippedOrigins + * @param array|null $aliases + * @param array|null $skippedOrigins */ protected function checkSchema(ConfigInterface $extendConfig, $aliases, array $skippedOrigins = null) { @@ -288,11 +288,12 @@ protected function checkSchema(ConfigInterface $extendConfig, $aliases, array $s ]; } - $schema = $extendConfig->get('schema', false, []); - $properties = isset($schema['property']) ? $schema['property'] : []; + $schema = $extendConfig->get('schema', false, []); + $properties = isset($schema['property']) && !empty($skippedOrigins) ? $schema['property'] : []; + // Need to check if relations already exists cause we can update them in updateRelationValues. $relationProperties = isset($schema['relation']) ? $schema['relation'] : []; - $defaultProperties = isset($schema['default']) ? $schema['default'] : []; - $addRemoveMethods = isset($schema['addremove']) ? $schema['addremove'] : []; + $defaultProperties = isset($schema['default']) && !empty($skippedOrigins) ? $schema['default'] : []; + $addRemoveMethods = isset($schema['addremove']) && !empty($skippedOrigins) ? $schema['addremove'] : []; $fieldConfigs = $extendProvider->filter($this->createOriginFilterCallback($skippedOrigins), $className, true); foreach ($fieldConfigs as $fieldConfig) { @@ -310,29 +311,33 @@ protected function checkSchema(ConfigInterface $extendConfig, $aliases, array $s $relations = $extendConfig->get('relation', false, []); foreach ($relations as &$relation) { - if (!$relation['field_id']) { + /** @var FieldConfigId $fieldId */ + $fieldId = $relation['field_id']; + if (!$fieldId) { continue; } $relation['assign'] = true; - if ($relation['field_id']->getFieldType() !== RelationType::MANY_TO_ONE) { - $fieldName = $relation['field_id']->getFieldName(); - $isDeleted = $extendProvider->hasConfig($relation['field_id']->getClassName(), $fieldName) - ? $extendProvider->getConfig($relation['field_id']->getClassName(), $fieldName)->is('is_deleted') + if ($fieldId->getFieldType() !== RelationType::MANY_TO_ONE) { + $fieldName = $fieldId->getFieldName(); + $isDeleted = $extendProvider->hasConfig($fieldId->getClassName(), $fieldName) + ? $extendProvider->getConfig($fieldId->getClassName(), $fieldName)->is('is_deleted') : false; if (!$isDeleted) { $addRemoveMethods[$fieldName]['self'] = $fieldName; - if ($relation['target_field_id']) { + /** @var FieldConfigId $targetFieldId */ + $targetFieldId = $relation['target_field_id']; + if ($targetFieldId) { $addRemoveMethods[$fieldName]['target'] = - $relation['target_field_id']->getFieldName(); + $targetFieldId->getFieldName(); $addRemoveMethods[$fieldName]['is_target_addremove'] = - $relation['field_id']->getFieldType() === RelationType::MANY_TO_MANY; + $targetFieldId->getFieldType() === RelationType::MANY_TO_MANY; } } } - $this->updateRelationValues($relation['target_entity'], $relation['field_id']); + $this->updateRelationValues($relation['target_entity'], $fieldId); } $extendConfig->set('relation', $relations);