Save qeued Events to the Event Stream.

@param EventQeueObject[] $eventQeueObjects

@return bool
974252
public function publishQeued(array $eventQeueObjects): bool
    {
        $eventStreamObjects = array_map(function ($eventQeueObject) {
            /* @var EventQeueObject $eventQeueObject */
            return $eventQeueObject->getEventStreamObject();
        }, $eventQeueObjects);

        /**
         * Add EventStreamObjects to list of EventStreamObjects that should be persisted.
         *
         * @var EventStreamObject $eventStreamObject
         */
        foreach ($eventStreamObjects as $eventStreamObject) {
            $this->eventStore->add($eventStreamObject);
        }

        try {
            $this->eventStore->save();

            // Notify subscribers.
            $this->sendAggregateUpdates($eventStreamObjects);
        } catch (\Exception $e) {
            // Saving to the Event Store failed. This can happen for example when an aggregate version is already taken.
            $this->messageBus->dispatch(new Message(
                $e->getMessage(),
                $e->getCode(),
                null,
                null,
                $e
            ));

            return false;
        }

        /**
         * Remove EventQeueObjects from qeue.
         *
         * @var EventQeueObject $eventQeueObject
         */
        foreach ($eventQeueObjects as $eventQeueObject) {
            $this->eventStore->remove($eventQeueObject);
        }

        try {
            $this->eventStore->save();

            return true;
        } catch (\Exception $e) {
            // Removal from the Event Qeue failed.
            $this->messageBus->dispatch(new Message(
                $e->getMessage(),
                $e->getCode(),
                null,
                null,
                $e
            ));

            return false;
        }
    }
334083
public static function buildEventFromEventStreamObject(EventStreamObject $eventStreamObject): EventInterface
    {
        /** @var EventInterface $eventClass */
        $eventClass = $eventStreamObject->getEvent();
        /** @var \RevisionTen\CQRS\Interfaces\CommandInterface $commandClass */
        $commandClass = $eventClass::getCommandClass();

        $user = $eventStreamObject->getUser();
        $commandUuid = $eventStreamObject->getCommandUuid();
        $uuid = $eventStreamObject->getUuid();
        // Its safe to assume the command was created on the previous version, it would have failed otherwise.
        $onVersion = $eventStreamObject->getVersion() - 1;
        $payload = $eventStreamObject->getPayload();

        /** @var \RevisionTen\CQRS\Interfaces\CommandInterface $command */
        $command = new $commandClass($user, $commandUuid, $uuid, $onVersion, $payload);

        return new $eventClass($command);
    }
886452
public function save(array $attributes = [])
    {
        $this->fireModelEvent(new Events\Saving($this));

        $saved = $this->exists ? $this->update($attributes) : $this->create($attributes);

        if ($saved) {
            $this->fireModelEvent(new Events\Saved($this));
        }

        return $saved;
    }
508082
public function save($isNewRecord)
    {
        if ($this->validate()) {
            $user = $this->user;
            $data = [];
            $fn = $user->formName();
            if ($isNewRecord) {
                $data[$fn]['username']    = $this->username;
            }
            $data[$fn]['email']           = $this->email;
            $data[$fn]['password']        = $this->password_new;
            $data[$fn]['change_auth_key'] = $this->change_auth_key;

            $loaded = $user->load($data);
            if ($isNewRecord) {
                $user->scenario = $user::SCENARIO_CREATE;
                $user->status = $user::STATUS_REGISTERED;
                $saved = $user->insert();
            } else {
                $saved = $user->update();
            }
            if ($loaded && $saved) {
                $this->auth_key = $user->auth_key;
                return $saved;
            } else {
                $this->addErrors($user->errors);
            }
        }
        return false;
    }
1169759
@Transactional
	public void save(Event event) {
		Event merged = em.merge(event);
		em.flush();
		event.setId(merged.getId());
	}
624
public function setObserverEvents($observerEvents)
    {
        $this->observerEvents = [];

        $token = ' ,;';
        $ext = strtok($observerEvents, $token);

        while ($ext !== false) {
            $this->observerEvents[] = $ext;
            $ext = strtok($token);
        }
    }
744235
public function afterSave(Event $event, EntityInterface $entity, ArrayObject $options): void
    {
        if (empty($entity->get('source_id'))) {
            $entity->set('source_id', $entity->get('id'));
            $this->save($entity);
        }
    }
1263349
public function doSave(AggregateRoot $aggregateRoot)
    {
        $eventStream = $aggregateRoot->uncommittedChanges();

        if (!$eventStream->isEmpty()) {
            $this->eventStore->append($this->aggregateRootType, $eventStream);
        }
    }
73420
public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options) {
		$fields = $this->_getMappedFields();

		foreach ($fields as $map => $field) {
			if (!$entity->get($map)) {
				continue;
			}
			$val = $entity->get($map);
			$entity->set($field, $this->_encode($val));
		}
	}
233229
public function save()
	{
		// Trigger the onUserBeforeSave event.
		$data  = $this->toArray();
		$isNew = $this->isNew();

		// Allow an exception to be thrown.
		try
		{
			$oldUser = self::oneOrNew($this->get('id'));

			// Trigger the onUserBeforeSave event.
			$result = Event::trigger('user.onUserBeforeSave', array($oldUser->toArray(), $isNew, $data));

			if (in_array(false, $result, true))
			{
				// Plugin will have to raise its own error or throw an exception.
				return false;
			}

			// Get any set access groups
			$groups = null;

			if ($this->hasAttribute('accessgroups'))
			{
				$groups = $this->get('accessgroups');

				$this->removeAttribute('accessgroups');
			}

			// Save record
			$result = parent::save();

			if (!$result)
			{
				throw new Exception($this->getError());
			}

			// Update access groups
			if ($groups && is_array($groups))
			{
				Map::destroyByUser($this->get('id'));

				Map::addUserToGroup($this->get('id'), $groups);
			}

			// In case it's a new user, we need to grab the ID
			$data['id'] = $this->get('id');

			// Fire the onUserAfterSave event
			Event::trigger('user.onUserAfterSave', array($data, $isNew, $result, $this->getError()));

			$this->purgeCache();
		}
		catch (Exception $e)
		{
			$this->addError($e->getMessage());

			$result = false;
		}

		return $result;
	}
858824
public function saveAsync(array $options = [])
    {
        $create = !$this->exists;

        if ($this->fireModelEvent('saving') === false) {
            return false;
        }

        if ($create && $this->fireModelEvent('creating')  === false) {
            return false;
        }

        if (!$create && $this->fireModelEvent('updating') === false) {
            return false;
        }

        if ($this->usesTimestamps()) {
            $this->updateTimestamps();
        }

        $savePromise = $this->newQuery()->saveAsync();

        $savePromise->then(function ($result) use ($create, $options) {
            if (array_get($result, '@metadata.statusCode') === 200) {
                $this->exists = true;
                $this->wasRecentlyCreated = $create;
                $this->fireModelEvent($create ? 'created' : 'updated', false);

                $this->finishSave($options);
            }
        });

        return $savePromise;
    }
168130
public function save($object)
    {

        if (is_array($object)) {
            $objectData = $object;
            if ($object['id'] > 0) {
                $object = $this->find($object['id']);
            } else {
                $object = new Group();
            }
            $this->assignArrayToObject($object, $objectData);
        } else if (!($object instanceof GroupInterface)) {
            $this->addErrorMessage(self::ERROR_WRONG_OBJECT);
        }

        if (!$this->hasError()) {
            $check = $this->groupManager->update($object);
            if ($check === true) {
                $this->addSuccessMessage(self::SUCCESS_SAVED);
            }
        }

        return $object;
    }
276915
private function save(array $messages)
    {
        fseek($this->fh, 0);
        fwrite($this->fh, json_encode($messages));
    }
699764
protected function save($entities)
    {
        if (!is_array($entities)) {
            $entities = [$entities];
        }

        foreach ($entities as $entity) {
            $entityClass = get_class($entity);
            $entityManager = $this
                ->get('base.object_manager_provider')
                ->getObjectManagerByEntityNamespace($entityClass);
            $entityManager->persist($entity);
            $entityManager->flush($entity);
        }
    }
293498
private void writeObject(ObjectOutputStream stream) throws IOException {
		final Object[] lList = this.listeners;
		stream.defaultWriteObject();

		// Save the non-null event listeners:
		for (int i = 0; i < lList.length; i += 2) {
			final Class<?> t = (Class<?>) lList[i];
			final EventListener l = (EventListener) lList[i + 1];
			if ((l != null) && (l instanceof Serializable)) {
				stream.writeObject(t.getName());
				stream.writeObject(l);
			}
		}

		stream.writeObject(null);
	}
206465
public function checkAnyOrder(...$events): ?EventCollection
    {
        if (!count($events)) {
            return null;
        }

        return $this->assertionRecorder
            ->createSuccess($this->mergeEvents($events));
    }
814184
public function save(IEvent $event)
    {
        $this->latestEvent = $event;

        if (null === $event->getId()) {
            $event->setId((string)Uuid::uuid4());
        }

        $filename = sprintf('%s.%s.event', $this->prepareFilename($event->getEndpoint()), $event->getId());

        $file = null;

        try {
            $filePath = $this->directory . '/' . $filename;

            if (!file_exists($filePath)) {
                $this->writer->open($filePath, 'w+');
                $this->writer->write($event->getMethod() . ' ' . $event->getEndpoint() . PHP_EOL);
                $this->writer->write($event->getReference() . PHP_EOL);
                $this->writer->write($event->getRequest() . PHP_EOL);
            } else {
                $this->writer->open($filePath, 'a');
                $this->writer->write($event->getLatency() . PHP_EOL);
                $this->writer->write($event->getResponse() . PHP_EOL);
            }
        } catch (Exception $e) {
            if (null !== $this->logger) {
                $this->logger->error($e);
            }
        } finally {
            if ($this->writer->isOpen()) {
                $this->writer->close();
            }
        }

        return $event;
    }