File tree Expand file tree Collapse file tree 4 files changed +58
-2
lines changed
Tests/Unit/Search/Metadata Expand file tree Collapse file tree 4 files changed +58
-2
lines changed Original file line number Diff line number Diff line change 7878 - php-version : ' 8.3'
7979 elasticsearch-version : ' 7.17.19'
8080 elasticsearch-package-constraint : ' ~7.17.0'
81- minimum-stability : ' dev'
81+ minimum-stability : ' stable'
82+ dependency-versions : ' highest'
83+ tools : ' composer:v2'
84+ php-cs-fixer : false
85+
86+ - php-version : ' 8.4'
87+ elasticsearch-version : ' 7.17.19'
88+ elasticsearch-package-constraint : ' ~7.17.0'
89+ minimum-stability : ' stable'
8290 dependency-versions : ' highest'
8391 tools : ' composer:v2'
8492 php-cs-fixer : false
Original file line number Diff line number Diff line change @@ -90,6 +90,9 @@ public function unserializeFromArray(array $data): void
9090 list ($ data , $ indexMetadata , $ this ->repositoryMethod ) = $ data ;
9191 parent ::unserializeFromArray ($ data );
9292 $ this ->indexMetadatas = $ indexMetadata ;
93+ foreach ($ this ->indexMetadatas as $ indexMetadata ) {
94+ $ indexMetadata ->setClassMetadata ($ this );
95+ }
9396 }
9497
9598 /**
Original file line number Diff line number Diff line change 1111
1212namespace Massive \Bundle \SearchBundle \Search \Metadata ;
1313
14+ use Metadata \SerializationHelper ;
15+
1416/**
1517 * Metadata for searchable objects.
1618 */
17- class IndexMetadata implements IndexMetadataInterface
19+ class IndexMetadata implements IndexMetadataInterface, \Serializable
1820{
21+ use SerializationHelper;
22+
1923 /**
2024 * @var string
2125 */
@@ -170,4 +174,34 @@ public function setClassMetadata(ClassMetadata $classMetadata)
170174 {
171175 $ this ->classMetadata = $ classMetadata ;
172176 }
177+
178+ public function serializeToArray (): array
179+ {
180+ return [
181+ $ this ->name ,
182+ $ this ->indexName ,
183+ $ this ->fieldMapping ,
184+ $ this ->idField ,
185+ $ this ->urlField ,
186+ $ this ->titleField ,
187+ $ this ->descriptionField ,
188+ $ this ->imageUrlField ,
189+ $ this ->localeField ,
190+ ];
191+ }
192+
193+ public function unserializeFromArray (array $ data ): void
194+ {
195+ list (
196+ $ this ->name ,
197+ $ this ->indexName ,
198+ $ this ->fieldMapping ,
199+ $ this ->idField ,
200+ $ this ->urlField ,
201+ $ this ->titleField ,
202+ $ this ->descriptionField ,
203+ $ this ->imageUrlField ,
204+ $ this ->localeField
205+ ) = $ data ;
206+ }
173207}
Original file line number Diff line number Diff line change @@ -74,4 +74,15 @@ public function testSerializeUnserialize()
7474
7575 $ this ->assertEquals ($ this ->classMetadata , \unserialize (\serialize ($ this ->classMetadata )));
7676 }
77+
78+ public function testSerializeUnserializeWithIndexMetadata ()
79+ {
80+ $ classMetadata = new ClassMetadata ('\stdClass ' );
81+ $ classMetadata ->addIndexMetadata (
82+ 'foo_context ' ,
83+ new IndexMetadata ()
84+ );
85+
86+ $ this ->assertEquals ($ classMetadata , \unserialize (\serialize ($ classMetadata )));
87+ }
7788}
You can’t perform that action at this time.
0 commit comments