Saves a Snapshot.

@param AggregateInterface $aggregate
337104
public function save(AggregateInterface $aggregate): void
    {
        $snapshot = new Snapshot();
        $snapshot->setUuid($aggregate->getUuid());
        $snapshot->setVersion($aggregate->getVersion());
        $snapshot->setAggregateCreated($aggregate->getCreated());
        $snapshot->setAggregateModified($aggregate->getModified());
        $snapshot->setAggregateClass(\get_class($aggregate));
        $snapshot->setHistory($aggregate->getHistory());
        $aggregateData = json_decode(json_encode($aggregate), true);
        $snapshot->setPayload($aggregateData);

        try {
            $this->em->persist($snapshot);
            $this->em->flush();
        } catch (OptimisticLockException $e) {
            $this->messageBus->dispatch(new Message(
                $e->getMessage(),
                $e->getCode(),
                null,
                $aggregate->getUuid(),
                $e
            ));
        } catch (UniqueConstraintViolationException $e) {
            $this->messageBus->dispatch(new Message(
                $e->getMessage(),
                $e->getCode(),
                null,
                $aggregate->getUuid(),
                $e
            ));
        }
    }
605337
function(aggregate, vm, callback) {
                vm.set(aggregate.toJSON());
                self.commit(vm, function(err) {
                    callback(err, aggregate, cmd);
                });
            }
1263349
public function doSave(AggregateRoot $aggregateRoot)
    {
        $eventStream = $aggregateRoot->uncommittedChanges();

        if (!$eventStream->isEmpty()) {
            $this->eventStore->append($this->aggregateRootType, $eventStream);
        }
    }
430383
def save_aggregate(aggregate, concurrency: :none)
      changeset = aggregate.changeset
      events = changeset.events.map { |event| event.with_metadata(namespace: @namespace) }
      revision = aggregate.revision if concurrency == :optimistic
      stream(aggregate.class, changeset.aggregate_id).write_events(events, revision: revision)
      notify_subscribers(changeset.aggregate_id, events)
    end
637838
function Snapshot (id, obj) {
  if (!id) {
    var errIdMsg = 'id not injected!';
    debug(errIdMsg);
    throw new Error(errIdMsg);
  }

  if (!obj) {
    var errObjMsg = 'object not injected!';
    debug(errObjMsg);
    throw new Error(errObjMsg);
  }

  if (!obj.aggregateId) {
    var errAggIdMsg = 'object.aggregateId not injected!';
    debug(errAggIdMsg);
    throw new Error(errAggIdMsg);
  }

  if (!obj.data) {
    var errDataMsg = 'object.data not injected!';
    debug(errDataMsg);
    throw new Error(errDataMsg);
  }

  this.id = id;
  this.streamId = obj.aggregateId;
  this.aggregateId = obj.aggregateId;
  this.aggregate = obj.aggregate || null;
  this.context = obj.context || null;
  this.commitStamp = null;
  this.revision = obj.revision;
  this.version = obj.version;
  this.data = obj.data;
}
1109059
public function preSave(MediaInterface $media)
    {
        $vimeoData = $this->getMetadata($media);

        $media->setReference($vimeoData->video_id);

        if(!$media->getName()) {
            $media->setName($vimeoData->title);
        }

        $thumb = $this->saveThumbnail($media, $vimeoData->thumbnail_url);
        $media->setThumb($thumb);

        $media->setMetadata($vimeoData);

        $media->setContentType('video/x-flv');
    }
377652
public function registerAggregate(
        AggregateRoot $aggregate,
        EventBus $eventBus,
        SaveAggregateCallback $saveAggregateCallback
    ) {
        return $this->registeredAggregates->add($aggregate, $eventBus, $saveAggregateCallback);
    }
1075344
private function initialize(string $aggregateClassName, string $methodName, bool $isCommandHandler, bool $isAggregateBased): void
    {
        if (!$isAggregateBased) {
            $this->registerRequiredReference($aggregateClassName);

            return;
        }

        $interfaceToCall = InterfaceToCall::create($aggregateClassName, $methodName);

        if ($interfaceToCall->hasReturnValue() && !$interfaceToCall->isStaticallyCalled() && $isCommandHandler) {
            throw InvalidArgumentException::create("{$aggregateClassName} with method {$methodName} must not return value for command handling");
        }

        if (!$interfaceToCall->hasReturnValue() && !$isCommandHandler) {
            throw InvalidArgumentException::create("{$aggregateClassName} with method {$methodName} must return value for query handling");
        }
    }
174369
public function postSave(Event $event, $id, $count) {
        if (!$this->getConfig('onSave') || !$this->_saveIndex) {
            return;
        }

        $this->_insertNode($id, $this->_saveIndex);
        $this->_saveIndex = null;
    }
727551
public function save(DomainObjectInterface &$domainObject): void
    {
        if ($domainObject->getId() === 0) {
            $this->concreteInsert($domainObject);
        }

        $this->concreteUpdate($domainObject);
    }
386671
public function persist()
    {
        $this->validate();

        if (!is_array($this->data)) {
            $this->data = [$this->data];
        }

        $append = $this instanceof StreamCollectorInterface;
        $patches = $this->jsonPatch->generateArrayAdd($this->getPath(), $this->data, $append);
        $this->dataSource->save($this->process, $patches);

        $this->data = [];
    }
423974
public function apply(AggregateInterface $aggregate, EventInterface $event): AggregateInterface
    {
        // Increase version on each apply call.
        $aggregate->setVersion($event->getCommand()->getOnVersion() + 1);

        // Add Event to pending Events.
        return $aggregate->addPendingEvent($event);
    }
1075458
def save(aggregate)
      new_events = aggregate.changes
      if new_events.any?
        event_sink.sink(new_events,
                        expected_version: aggregate.version - new_events.count)
      end
      aggregate.clear_changes
    end
410524
public function save(BlockInterface $block)
    {
        $block->setRootVersion($this->getNewVersion($block));

        $this->em->persist($block);
        $this->em->flush($block);

        return $this;
    }
541118
protected function storeSnapshotForJob($job)
    {
        $data = $this->baseSnapshotData($key = 'job:'.$job);

        $this->connection()->zadd(
            'snapshot:'.$key, $time = Chronos::now()->getTimestamp(), json_encode([
                'throughput' => $data['throughput'],
                'runtime' => $data['runtime'],
                'time' => $time,
            ])
        );

        $this->connection()->zremrangebyrank(
            'snapshot:'.$key, 0, -25
        );
    }
1362276
function (aggregate) {
    if (!aggregate || !(aggregate instanceof Aggregate)) {
      throw new Error('Passed object should be an Aggregate');
    }

    aggregate.defineContext(this);

    if (this.aggregates.indexOf(aggregate) < 0) {
      this.aggregates.push(aggregate);
    }
  }
632038
public function save(MediaProviderInterface $mediaProvider, $andFlush = true)
    {
        $context = $mediaProvider->getMedia()->getContext();
        $provider = $this->providerService->getProviderManager($context);

        if (null !== $mediaProvider->getMedia()->getFile()) {
            $this->uploadProcess($provider, $mediaProvider);
        }

        $this->persistProcess($provider, $mediaProvider, $andFlush);
    }