@@ -59,24 +59,28 @@ public function process(PsrMessage $message, PsrContext $context)
5959 return Result::reject ('The message data misses id ' );
6060 }
6161 if (false == isset ($ data ['index_name ' ])) {
62- return Result::reject ('The message data misses id ' );
62+ return Result::reject ('The message data misses index_name ' );
6363 }
6464 if (false == isset ($ data ['type_name ' ])) {
65- return Result::reject ('The message data misses id ' );
65+ return Result::reject ('The message data misses type_name ' );
66+ }
67+ if (false == isset ($ data ['repository_method ' ])) {
68+ return Result::reject ('The message data misses repository_method ' );
6669 }
6770
6871 $ action = $ data ['action ' ];
6972 $ modelClass = $ data ['model_class ' ];
7073 $ id = $ data ['id ' ];
7174 $ index = $ data ['index_name ' ];
7275 $ type = $ data ['type_name ' ];
76+ $ repositoryMethod = $ data ['repository_method ' ];
7377
7478 $ repository = $ this ->doctrine ->getManagerForClass ($ modelClass )->getRepository ($ modelClass );
7579 $ persister = $ this ->persisterRegistry ->getPersister ($ index , $ type );
7680
7781 switch ($ action ) {
7882 case self ::UPDATE_ACTION :
79- if (false == $ object = $ repository ->find ($ id )) {
83+ if (false == $ object = $ repository ->{ $ repositoryMethod } ($ id )) {
8084 $ persister ->deleteById ($ id );
8185
8286 return Result::ack (sprintf ('The object "%s" with id "%s" could not be found. ' , $ modelClass , $ id ));
@@ -92,7 +96,7 @@ public function process(PsrMessage $message, PsrContext $context)
9296
9397 return self ::ACK ;
9498 case self ::INSERT_ACTION :
95- if (false == $ object = $ repository ->find ($ id )) {
99+ if (false == $ object = $ repository ->{ $ repositoryMethod } ($ id )) {
96100 $ persister ->deleteById ($ id );
97101
98102 return Result::ack (sprintf ('The object "%s" with id "%s" could not be found. ' , $ modelClass , $ id ));
0 commit comments