public function dispatchBatch($channel, array $events)
    {
        $messages = [];
        $validates = true;

        foreach ($events as $event) {
            /** @var EventInterface $event */
            $event = $this->prepEventForDispatch($event);

            if ($this->validator) {
                $result = $this->validator->validate($event);
                if ($result->fails()) {
                    $validates = false;

                    // pass to validation fail handler?
                    if ($this->validationFailHandler) {
                        call_user_func($this->validationFailHandler, $result);
                    }

                    if ($this->throwValidationExceptionsOnDispatch) {
                        throw new ValidationException($result);
                    }
                }
            }

            $messages[] = $event->toMessage();
        }

        if ($validates) {
            $this->adapter->publishBatch($channel, $messages);
        }
    }
public function dispatchBatch($channel, array $events)
    {
        $messages = [];
        $validates = true;

        foreach ($events as $event) {
            /** @var EventInterface $event */
            $event = $this->prepEventForDispatch($event);

            if ($this->validator) {
                $result = $this->validator->validate($event);
                if ($result->fails()) {
                    $validates = false;

                    // pass to validation fail handler?
                    if ($this->validationFailHandler) {
                        call_user_func($this->validationFailHandler, $result);
                    }

                    if ($this->throwValidationExceptionsOnDispatch) {
                        throw new ValidationException($result);
                    }
                }
            }

            $messages[] = $event->toMessage();
        }

        if ($validates) {
            $this->adapter->publishBatch($channel, $messages);
        }
    }
public function dispatchBatch ( $ channel , array $ events ) { $ messages = [ ] ; $ validates = true ; foreach ( $ events as $ event ) { /** @var EventInterface $event */ $ event = $ this -> prepEventForDispatch ( $ event ) ; if ( $ this -> validator ) { $ result = $ this -> validator -> validate ( $ event ) ; if ( $ result -> fails ( ) ) { $ validates = false ; // pass to validation fail handler? if ( $ this -> validationFailHandler ) { call_user_func ( $ this -> validationFailHandler , $ result ) ; } if ( $ this -> throwValidationExceptionsOnDispatch ) { throw new ValidationException ( $ result ) ; } } } $ messages [ ] = $ event -> toMessage ( ) ; } if ( $ validates ) { $ this -> adapter -> publishBatch ( $ channel , $ messages ) ; } }
Dispatch multiple events.

@param string $channel
@param array $events

@throws ValidationException
Dispatch multiple events .