src/Graviton/DocumentBundle/Listener/DocumentVersionListener.php
private function updateCounter(ModelEvent $event, $action)
    {
        if (!$this->constraint->isVersioningService()) {
            return;
        }

        $qb = $this->documentManager->createQueryBuilder($event->getCollectionClass());
        if ('update' == $action) {
            $qb->findAndUpdate()
                ->field('id')->equals($event->getCollectionId())
                ->field(VersionServiceConstraint::FIELD_NAME)->inc(1)
                ->getQuery()->execute();
        } else {
            $qb->findAndUpdate()
                ->field('id')->equals($event->getCollectionId())
                ->field(VersionServiceConstraint::FIELD_NAME)->set(1)
                ->getQuery()->execute();
        }
    }
private function updateCounter(ModelEvent $event, $action)
    {
        if (!$this->constraint->isVersioningService()) {
            return;
        }

        $qb = $this->documentManager->createQueryBuilder($event->getCollectionClass());
        if ('update' == $action) {
            $qb->findAndUpdate()
                ->field('id')->equals($event->getCollectionId())
                ->field(VersionServiceConstraint::FIELD_NAME)->inc(1)
                ->getQuery()->execute();
        } else {
            $qb->findAndUpdate()
                ->field('id')->equals($event->getCollectionId())
                ->field(VersionServiceConstraint::FIELD_NAME)->set(1)
                ->getQuery()->execute();
        }
    }
private function updateCounter ( ModelEvent $ event , $ action ) { if ( ! $ this -> constraint -> isVersioningService ( ) ) { return ; } $ qb = $ this -> documentManager -> createQueryBuilder ( $ event -> getCollectionClass ( ) ) ; if ( 'update' == $ action ) { $ qb -> findAndUpdate ( ) -> field ( 'id' ) -> equals ( $ event -> getCollectionId ( ) ) -> field ( VersionServiceConstraint :: FIELD_NAME ) -> inc ( 1 ) -> getQuery ( ) -> execute ( ) ; } else { $ qb -> findAndUpdate ( ) -> field ( 'id' ) -> equals ( $ event -> getCollectionId ( ) ) -> field ( VersionServiceConstraint :: FIELD_NAME ) -> set ( 1 ) -> getQuery ( ) -> execute ( ) ; } }
Update Counter for all new saved items

@param ModelEvent $event  Object event
@param string     $action What is to be done
@return void
Update Counter for all new saved items