protected function handleFiles($object)
    {
        $request = $this->getRequest();

        $rc = new \ReflectionClass($object);
        $className = $rc->getShortName();

        $repo = $this->manager->getRepository('LibrinfoMediaBundle:File');

        if ($remove = $request->get('remove_files')) {
            foreach ($remove as $key => $id) {
                $file = $repo->find($id);

                if ($file) {
                    if (method_exists($object, 'removeLibrinfoFile')) {
                        $object->removeLibrinfoFile($file);
                        $this->manager->remove($file);
                    } elseif (method_exists($object, 'setLibrinfoFile')) {
                        $object->setLibrinfoFile();
                        $this->manager->remove($file);
                    } else {
                        throw new \Exception('You must define ' . $className . '::removeLibrinfoFile() method or ' . $className . '::setFile() in case of a one to one');
                    }
                }
            }
        }

        if ($ids = $request->get('add_files')) {
            foreach ($ids as $key => $id) {
                $file = $repo->find($id);

                if ($file) {
                    if (method_exists($object, 'addLibrinfoFile')) {
                        $object->addLibrinfoFile($file);
                        $file->setOwned(true);
                    } elseif (method_exists($object, 'setLibrinfoFile')) {
                        $object->setLibrinfoFile($file);
                        $file->setOwned(true);
                    } else {
                        throw new \Exception('You must define ' . $className . '::addLibrinfoFile() method or ' . $className . '::setLibrinfoFile() in case of a one to one');
                    }
                }
            }
        }
    }
protected function handleFiles($object)
    {
        $request = $this->getRequest();

        $rc = new \ReflectionClass($object);
        $className = $rc->getShortName();

        $repo = $this->manager->getRepository('LibrinfoMediaBundle:File');

        if ($remove = $request->get('remove_files')) {
            foreach ($remove as $key => $id) {
                $file = $repo->find($id);

                if ($file) {
                    if (method_exists($object, 'removeLibrinfoFile')) {
                        $object->removeLibrinfoFile($file);
                        $this->manager->remove($file);
                    } elseif (method_exists($object, 'setLibrinfoFile')) {
                        $object->setLibrinfoFile();
                        $this->manager->remove($file);
                    } else {
                        throw new \Exception('You must define ' . $className . '::removeLibrinfoFile() method or ' . $className . '::setFile() in case of a one to one');
                    }
                }
            }
        }

        if ($ids = $request->get('add_files')) {
            foreach ($ids as $key => $id) {
                $file = $repo->find($id);

                if ($file) {
                    if (method_exists($object, 'addLibrinfoFile')) {
                        $object->addLibrinfoFile($file);
                        $file->setOwned(true);
                    } elseif (method_exists($object, 'setLibrinfoFile')) {
                        $object->setLibrinfoFile($file);
                        $file->setOwned(true);
                    } else {
                        throw new \Exception('You must define ' . $className . '::addLibrinfoFile() method or ' . $className . '::setLibrinfoFile() in case of a one to one');
                    }
                }
            }
        }
    }
protected function handleFiles ( $ object ) { $ request = $ this -> getRequest ( ) ; $ rc = new \ ReflectionClass ( $ object ) ; $ className = $ rc -> getShortName ( ) ; $ repo = $ this -> manager -> getRepository ( 'LibrinfoMediaBundle:File' ) ; if ( $ remove = $ request -> get ( 'remove_files' ) ) { foreach ( $ remove as $ key => $ id ) { $ file = $ repo -> find ( $ id ) ; if ( $ file ) { if ( method_exists ( $ object , 'removeLibrinfoFile' ) ) { $ object -> removeLibrinfoFile ( $ file ) ; $ this -> manager -> remove ( $ file ) ; } elseif ( method_exists ( $ object , 'setLibrinfoFile' ) ) { $ object -> setLibrinfoFile ( ) ; $ this -> manager -> remove ( $ file ) ; } else { throw new \ Exception ( 'You must define ' . $ className . '::removeLibrinfoFile() method or ' . $ className . '::setFile() in case of a one to one' ) ; } } } } if ( $ ids = $ request -> get ( 'add_files' ) ) { foreach ( $ ids as $ key => $ id ) { $ file = $ repo -> find ( $ id ) ; if ( $ file ) { if ( method_exists ( $ object , 'addLibrinfoFile' ) ) { $ object -> addLibrinfoFile ( $ file ) ; $ file -> setOwned ( true ) ; } elseif ( method_exists ( $ object , 'setLibrinfoFile' ) ) { $ object -> setLibrinfoFile ( $ file ) ; $ file -> setOwned ( true ) ; } else { throw new \ Exception ( 'You must define ' . $ className . '::addLibrinfoFile() method or ' . $ className . '::setLibrinfoFile() in case of a one to one' ) ; } } } } }
Binds the uploaded file to its owner on creation.

@param object $object
@param array  $ids
Binds the uploaded file to its owner on creation .