Skip to content

Commit 2aac027

Browse files
committed
Merge branch '4.x'
2 parents 9b5cbec + f38ad32 commit 2aac027

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

doc/cookbook/manual-provider.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Manual pager provider
22
====================
33

4-
Create a service with the tag "fos_elastica.provider" and attributes for the
4+
Create a service with the tag "fos_elastica.pager_provider" and attributes for the
55
index and type for which the service will provide.
66

77
```yaml

src/Doctrine/Listener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ private function persistScheduled()
223223
private function scheduleForDeletion($object)
224224
{
225225
if ($identifierValue = $this->propertyAccessor->getValue($object, $this->config['identifier'])) {
226-
$this->scheduledForDeletion[] = $identifierValue;
226+
$this->scheduledForDeletion[] = !is_scalar($identifierValue) ? (string) $identifierValue : $identifierValue;
227227
}
228228
}
229229

src/Transformer/ModelToElasticaAutoTransformer.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ public function setPropertyAccessor(PropertyAccessorInterface $propertyAccessor)
7777
public function transform($object, array $fields)
7878
{
7979
$identifier = $this->propertyAccessor->getValue($object, $this->options['identifier']);
80-
$document = $this->transformObjectToDocument($object, $fields, $identifier);
80+
if ($identifier && !is_scalar($identifier)) {
81+
$identifier = (string) $identifier;
82+
}
8183

82-
return $document;
84+
return $this->transformObjectToDocument($object, $fields, $identifier);
8385
}
8486

8587
/**

tests/Functional/app/ORM/bundles.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@
1818
new FrameworkBundle(),
1919
new FOSElasticaBundle(),
2020
new DoctrineBundle(),
21-
new JMSSerializerBundle(),
2221
];

tests/Unit/Transformer/ModelToElasticaAutoTransformerTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,20 @@ public function testUnmappedFieldValuesAreNormalisedToStrings()
546546
$this->assertSame('bar', $data['unmappedValue']);
547547
}
548548

549+
public function testIdentifierIsCastedToString()
550+
{
551+
$idObject = new CastableObject();;
552+
$idObject->foo = '00000000-0000-0000-0000-000000000000';
553+
554+
$object = new \stdClass();
555+
$object->id = $idObject;
556+
557+
$transformer = $this->getTransformer();
558+
$document = $transformer->transform($object, []);
559+
560+
$this->assertSame('00000000-0000-0000-0000-000000000000', $document->getId());
561+
}
562+
549563
/**
550564
* @param null|\Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher
551565
*

0 commit comments

Comments
 (0)