concrete/src/File/StorageLocation/StorageLocationFactory.php
public function persist(StorageLocationEntity $storageLocation)
    {
        return $this->entityManager->transactional(function (EntityManagerInterface $em) use ($storageLocation) {
            if ($storageLocation->isDefault()) {
                $qb = $em->createQueryBuilder()->update(StorageLocationEntity::class, 'l')->set('l.fslIsDefault', 0);
                if ($storageLocation->getID()) {
                    $qb->andWhere('l.fslID <> :id')->setParameter('id', $storageLocation->getID());
                }
                $qb->getQuery()->execute();
            }
            $em->persist($storageLocation);

            return $storageLocation;
        });
    }
public function persist(StorageLocationEntity $storageLocation)
    {
        return $this->entityManager->transactional(function (EntityManagerInterface $em) use ($storageLocation) {
            if ($storageLocation->isDefault()) {
                $qb = $em->createQueryBuilder()->update(StorageLocationEntity::class, 'l')->set('l.fslIsDefault', 0);
                if ($storageLocation->getID()) {
                    $qb->andWhere('l.fslID <> :id')->setParameter('id', $storageLocation->getID());
                }
                $qb->getQuery()->execute();
            }
            $em->persist($storageLocation);

            return $storageLocation;
        });
    }
public function persist ( StorageLocationEntity $ storageLocation ) { return $ this -> entityManager -> transactional ( function ( EntityManagerInterface $ em ) use ( $ storageLocation ) { if ( $ storageLocation -> isDefault ( ) ) { $ qb = $ em -> createQueryBuilder ( ) -> update ( StorageLocationEntity :: class , 'l' ) -> set ( 'l.fslIsDefault' , 0 ) ; if ( $ storageLocation -> getID ( ) ) { $ qb -> andWhere ( 'l.fslID <> :id' ) -> setParameter ( 'id' , $ storageLocation -> getID ( ) ) ; } $ qb -> getQuery ( ) -> execute ( ) ; } $ em -> persist ( $ storageLocation ) ; return $ storageLocation ; } ) ; }
Store a created storage location to the database
@param StorageLocationEntity $storageLocation
@return StorageLocationEntity The persisted location, may not be the same as the passed in object
Store a created storage location to the database