Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/dev/1.7' into 1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrebenchuk committed Sep 28, 2015
2 parents 50d48bf + 4602f3f commit 5d747e6
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 35 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/Oro/Bundle/CalendarBundle/Resources/config/datagrid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ datagrid:
options:
field_options:
choices:
false: Inactive
true: Active
'false': Inactive
'true': Active

base-system-calendar-event-grid:
source:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
41 changes: 23 additions & 18 deletions src/Oro/Bundle/EntityExtendBundle/Tools/ExtendConfigDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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) {
Expand All @@ -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);

Expand Down Expand Up @@ -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()] = [];
}
}
}
Expand Down
19 changes: 18 additions & 1 deletion src/Oro/Bundle/FormBundle/Autocomplete/SearchHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '[email protected]')
),
$this->createMockEntity(
array(self::TEST_ID_FIELD => 2, 'name' => 'Jane', 'email' => '[email protected]')
),
array(self::TEST_ID_FIELD => 3,'name' => 'Jack'),
$this->createStubEntityWithProperties(
array(
self::TEST_ID_FIELD => 4,
Expand Down Expand Up @@ -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')
)
)
),
Expand Down
16 changes: 8 additions & 8 deletions src/Oro/Bundle/UserBundle/Resources/config/datagrid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ datagrid:
options:
field_options:
choices:
false: Inactive
true: Active
'false': Inactive
'true': Active

actions:
view:
Expand Down Expand Up @@ -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%
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -632,5 +632,5 @@ datagrid:
options:
field_options:
choices:
false: Inactive
true: Active
'false': Inactive
'true': Active

0 comments on commit 5d747e6

Please sign in to comment.