diff --git a/composer.json b/composer.json index a1b54a63b55..663e29c8c84 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "ext-xml": "*", "symfony/symfony": "2.3.*", "twig/twig": "<=1.16.0", - "doctrine/orm": "2.4.6", + "doctrine/orm": "2.4.8", "doctrine/doctrine-bundle": "1.2.0", "doctrine/dbal": "2.4.*", "doctrine/data-fixtures": "1.0.0", diff --git a/src/Oro/Bundle/CalendarBundle/Resources/config/datagrid.yml b/src/Oro/Bundle/CalendarBundle/Resources/config/datagrid.yml index ca7a725afa8..5a3738772fc 100644 --- a/src/Oro/Bundle/CalendarBundle/Resources/config/datagrid.yml +++ b/src/Oro/Bundle/CalendarBundle/Resources/config/datagrid.yml @@ -283,8 +283,8 @@ datagrid: options: field_options: choices: - false: Inactive - true: Active + 'false': Inactive + 'true': Active base-system-calendar-event-grid: source: diff --git a/src/Oro/Bundle/EntityConfigBundle/EventListener/OptionSetListener.php b/src/Oro/Bundle/EntityConfigBundle/EventListener/OptionSetListener.php index 5ed92edf22a..be64047fa3c 100644 --- a/src/Oro/Bundle/EntityConfigBundle/EventListener/OptionSetListener.php +++ b/src/Oro/Bundle/EntityConfigBundle/EventListener/OptionSetListener.php @@ -48,7 +48,7 @@ public function postPersist(LifecycleEventArgs $event) return; } - foreach ($schema['relation'] as $fieldName) { + foreach ($schema['relation'] as $fieldName => $fieldOptions) { if (!$configProvider->hasConfig($className, $fieldName)) { continue; } diff --git a/src/Oro/Bundle/EntityConfigBundle/Tests/Unit/EventListener/OptionSetListenerTest.php b/src/Oro/Bundle/EntityConfigBundle/Tests/Unit/EventListener/OptionSetListenerTest.php index 7fab975b732..96d52d26ec8 100644 --- a/src/Oro/Bundle/EntityConfigBundle/Tests/Unit/EventListener/OptionSetListenerTest.php +++ b/src/Oro/Bundle/EntityConfigBundle/Tests/Unit/EventListener/OptionSetListenerTest.php @@ -113,7 +113,11 @@ public function testPostPersist() $fieldName = 'testFieldName'; $secondFieldName = 'secondTestField'; - $schema = array('relation' => array($fieldName, $secondFieldName, $thirdFieldName)); + $schema = array('relation' => array( + $fieldName => array(), + $secondFieldName => array(), + $thirdFieldName => array() + )); $configProvider = $this->getMockBuilder('Oro\Bundle\EntityConfigBundle\Provider\ConfigProvider') ->disableOriginalConstructor() diff --git a/src/Oro/Bundle/EntityExtendBundle/Tools/ExtendConfigDumper.php b/src/Oro/Bundle/EntityExtendBundle/Tools/ExtendConfigDumper.php index 70fa8acd8cf..a879882fb3a 100644 --- a/src/Oro/Bundle/EntityExtendBundle/Tools/ExtendConfigDumper.php +++ b/src/Oro/Bundle/EntityExtendBundle/Tools/ExtendConfigDumper.php @@ -218,7 +218,7 @@ protected function checkFields( $underlyingFieldType = $this->fieldTypeHelper->getUnderlyingType($fieldType); if (in_array($underlyingFieldType, array_merge(RelationType::$anyToAnyRelations, ['optionSet']))) { - $relationProperties[$fieldName] = $fieldName; + $relationProperties[$fieldName] = []; if ($isDeleted) { $relationProperties[$fieldName]['private'] = true; } @@ -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'); - $properties = []; - $relationProperties = $schema ? $schema['relation'] : []; - $defaultProperties = []; - $addRemoveMethods = []; + $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']) && !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); @@ -437,7 +442,7 @@ protected function updateRelationValues($targetClass, FieldConfigId $fieldId) /** @var FieldConfigId $relationFieldId */ $relationFieldId = $relation['field_id']; if ($relationFieldId) { - $schema['relation'][$relationFieldId->getFieldName()] = $relationFieldId->getFieldName(); + $schema['relation'][$relationFieldId->getFieldName()] = []; } } } diff --git a/src/Oro/Bundle/FormBundle/Autocomplete/SearchHandler.php b/src/Oro/Bundle/FormBundle/Autocomplete/SearchHandler.php index 74eae0bbf96..a1e1ffb7e09 100644 --- a/src/Oro/Bundle/FormBundle/Autocomplete/SearchHandler.php +++ b/src/Oro/Bundle/FormBundle/Autocomplete/SearchHandler.php @@ -170,7 +170,24 @@ protected function searchEntities($search, $firstResult, $maxResults) $resultEntities = []; if ($entityIds) { - $resultEntities = $this->getEntitiesByIds($entityIds); + $unsortedEntities = $this->getEntitiesByIds($entityIds); + + /** + * We need to sort entities in the same order given by method searchIds. + * + * @todo Should be not necessary after implementation of BAP-5691. + */ + $entityByIdHash = []; + + foreach ($unsortedEntities as $entity) { + $entityByIdHash[$this->getPropertyValue($this->idFieldName, $entity)] = $entity; + } + + foreach ($entityIds as $entityId) { + if (isset($entityByIdHash[$entityId])) { + $resultEntities[] = $entityByIdHash[$entityId]; + } + } } return $resultEntities; diff --git a/src/Oro/Bundle/FormBundle/Tests/Unit/Autocomplete/SearchHandlerTest.php b/src/Oro/Bundle/FormBundle/Tests/Unit/Autocomplete/SearchHandlerTest.php index a2c91a4cfab..f6c21ddae20 100644 --- a/src/Oro/Bundle/FormBundle/Tests/Unit/Autocomplete/SearchHandlerTest.php +++ b/src/Oro/Bundle/FormBundle/Tests/Unit/Autocomplete/SearchHandlerTest.php @@ -283,13 +283,16 @@ public function searchDataProvider() 'getResult', array(), array( + /** + * test sorting works correct + */ + array(self::TEST_ID_FIELD => 3,'name' => 'Jack'), $this->createMockEntity( array(self::TEST_ID_FIELD => 1, 'name' => 'John', 'email' => 'john@example.com') ), $this->createMockEntity( array(self::TEST_ID_FIELD => 2, 'name' => 'Jane', 'email' => 'jane@example.com') ), - array(self::TEST_ID_FIELD => 3,'name' => 'Jack'), $this->createStubEntityWithProperties( array( self::TEST_ID_FIELD => 4, @@ -337,11 +340,14 @@ public function searchDataProvider() 'getResult', array(), array( + /** + * test sorting works correct + */ $this->createMockEntity( - array(self::TEST_ID_FIELD => 1, 'name' => 'John', 'email' => 'john@example.com') + array(self::TEST_ID_FIELD => 2, 'name' => 'Jane', 'email' => 'jane@example.com') ), $this->createMockEntity( - array(self::TEST_ID_FIELD => 2, 'name' => 'Jane', 'email' => 'jane@example.com') + array(self::TEST_ID_FIELD => 1, 'name' => 'John', 'email' => 'john@example.com') ) ) ), diff --git a/src/Oro/Bundle/UserBundle/Resources/config/datagrid.yml b/src/Oro/Bundle/UserBundle/Resources/config/datagrid.yml index 038bb3c05b6..c0d8c96448f 100644 --- a/src/Oro/Bundle/UserBundle/Resources/config/datagrid.yml +++ b/src/Oro/Bundle/UserBundle/Resources/config/datagrid.yml @@ -103,8 +103,8 @@ datagrid: options: field_options: choices: - false: Inactive - true: Active + 'false': Inactive + 'true': Active actions: view: @@ -479,8 +479,8 @@ datagrid: options: field_options: choices: - false: Inactive - true: Active + 'false': Inactive + 'true': Active owner-users-select-grid: extended_entity_name: %oro_user.entity.class% @@ -543,8 +543,8 @@ datagrid: options: field_options: choices: - false: Inactive - true: Active + 'false': Inactive + 'true': Active users-select-grid-exclude-owner: extends: users-select-grid @@ -632,5 +632,5 @@ datagrid: options: field_options: choices: - false: Inactive - true: Active + 'false': Inactive + 'true': Active