src/Prospekta/FileBundle/EventListener/FileSaver.php
/**
     * preUpdate Doctrine listener
     * 
     * The same as prePersist, but for update action.
     * WARNING! So far, updating file itself for File Entity instance is not allowed! You can only change other details.
     * 
     * @param \Doctrine\ORM\Event\LifecycleEventArgs $args
     */
preUpdate Doctrine listener

The same as prePersist, but for update action.
WARNING. So far, updating file itself for File Entity instance is not allowed. You can only change other details.


preUpdate Doctrine listener The same as prePersist but for update action . WARNING . So far updating file itself for File Entity instance is not allowed . You can only change other details .
public function preUpdate(LifecycleEventArgs $args)
    {
        $entity = $args->getEntity();
        $entityManager = $args->getEntityManager();
        if ($entity instanceof File)
        {
            if ($entity->isFileSet())            
            {
                throw new \Exception('You cannot change file for already peristed FileBundle\Entity\File instance! You can only change properties stored in database.');
            }
$newHandle = $this->storageManager->getEngine()->update($entity);
if ($newHandle != null)
{
    $entity->setFilehandle($newHandle);
    // funny workaround to make changes in entity visible in flush()
    $em = $args->getEntityManager();
    $uow = $em->getUnitOfWork();
    $meta = $em->getClassMetadata(get_class($entity));
    $uow->recomputeSingleEntityChangeSet($meta, $entity);
}
        }
    }
public function preUpdate ( LifecycleEventArgs $ args ) { $ entity = $ args -> getEntity ( ) ; $ entityManager = $ args -> getEntityManager ( ) ; if ( $ entity instanceof File ) { if ( $ entity -> isFileSet ( ) ) { throw new \ Exception ( 'You cannot change file for already peristed FileBundle\Entity\File instance! You can only change properties stored in database.' ) ; } } }
preUpdate Doctrine listener
preUpdate Doctrine listener
//             //            $newHandle = $this->storageManager->getEngine()->update($entity); //             //            if ($newHandle != null) //            { //                $entity->setFilehandle($newHandle); //                 //                // funny workaround to make changes in entity visible in flush() //                $em = $args->getEntityManager(); //                $uow = $em->getUnitOfWork(); //                $meta = $em->getClassMetadata(get_class($entity)); //                $uow->recomputeSingleEntityChangeSet($meta, $entity); //            }