@@ -288,14 +288,40 @@ protected function assertMetadata(CoreContextAwarePluginInterface $plugin, Execu
288288 protected function processData (CoreContextAwarePluginInterface $ plugin , ExecutionStateInterface $ rules_state ) {
289289 if (isset ($ this ->configuration ['context_processors ' ])) {
290290 foreach ($ this ->configuration ['context_processors ' ] as $ context_name => $ processors ) {
291+ $ definition = $ plugin ->getContextDefinition ($ context_name );
291292 $ value = $ plugin ->getContextValue ($ context_name );
292- foreach ($ processors as $ processor_plugin_id => $ configuration ) {
293- $ data_processor = $ this ->processorManager ->createInstance ($ processor_plugin_id , $ configuration );
294- $ value = $ data_processor ->process ($ value , $ rules_state );
293+ if ($ definition ->isMultiple ()) {
294+ foreach ($ value as &$ current ) {
295+ $ current = $ this ->processValue ($ current , $ processors , $ rules_state );
296+ }
297+ }
298+ else {
299+ $ value = $ this ->processValue ($ value , $ processors , $ rules_state );
295300 }
296301 $ plugin ->setContextValue ($ context_name , $ value );
297302 }
298303 }
299304 }
300305
306+ /**
307+ * Processes a single value.
308+ *
309+ * @param mixed $value
310+ * The current value.
311+ * @param array $processors
312+ * An array mapping processor plugin IDs to their configuration.
313+ * @param \Drupal\rules\Engine\ExecutionStateInterface $rules_state
314+ * The current Rules execution state with context variables.
315+ *
316+ * @return mixed
317+ * THe processed value.
318+ */
319+ protected function processValue ($ value , $ processors , ExecutionStateInterface $ rules_state ) {
320+ foreach ($ processors as $ processor_plugin_id => $ configuration ) {
321+ $ data_processor = $ this ->processorManager ->createInstance ($ processor_plugin_id , $ configuration );
322+ $ value = $ data_processor ->process ($ value , $ rules_state );
323+ }
324+ return $ value ;
325+ }
326+
301327}
0 commit comments