public function execute(StorageInterface $storage, Operations $operations)
    {
        foreach ($operations->getOperations() as $operation) {
            if ($operation instanceof AddDocumentOperation) {
                $document = $operation->getDocument();
                $event = new DocumentEvent($document);
                if ($this->eventDispatcher->dispatch(IndexerEvents::BEFORE_STORAGE_ADD_DOCUMENT, $event)
                    ->isPropagationStopped()
                ) {
                    continue;
                }

                $storage->addDocument($document);

                $event = new DocumentEvent($document);
                $this->eventDispatcher->dispatch(IndexerEvents::STORAGE_ADD_DOCUMENT, $event);
            } elseif ($operation instanceof AddIdentityOperation) {
                throw new InvalidArgumentException('Add identity command not supported by run().');
            } elseif ($operation instanceof UpdateDocumentOperation) {
                $document = $operation->getDocument();
                $event = new DocumentEvent($document);
                if ($this->eventDispatcher->dispatch(IndexerEvents::BEFORE_STORAGE_UPDATE_DOCUMENT, $event)->isPropagationStopped()) {
                    continue;
                }

                $storage->updateDocument($document);

                $event = new DocumentEvent($document);
                $this->eventDispatcher->dispatch(IndexerEvents::STORAGE_UPDATE_DOCUMENT, $event);
            } elseif ($operation instanceof UpdateIdentityOperation) {
                throw new InvalidArgumentException('Update identity command not supported by run().');
            } elseif ($operation instanceof DeleteDocumentOperation) {
                $storage->deleteDocument($operation->getDocument());
            } elseif ($operation instanceof DeleteIdentityOperation) {
                $storage->delete($operation->getIdentity());
            } elseif ($operation instanceof DeleteTypeOperation) {
                $storage->deleteType($operation->getType());
            } elseif ($operation instanceof DeleteAllOperation) {
                $storage->deleteAll();
            } elseif ($operation instanceof FlushOperation) {
                if ($storage instanceof Flushable) {
                    $storage->flush();
                }
            } elseif ($operation instanceof OptimizeOperation) {
                if ($storage instanceof Optimizable) {
                    $storage->optimize();
                }
            } elseif ($operation instanceof CommitOperation) {
                if ($storage instanceof Commitable) {
                    $storage->commit();
                }
            } elseif ($operation instanceof RollbackOperation) {
                if ($storage instanceof Rollbackable) {
                    $storage->rollback();
                }
            }
        }

        return true;
    }