CoreBundle/Controller/ActorController.php
public function editAction(Request $request, Actor $actor)
    {
        $oldPassword = $actor->getPassword();
        $deleteForm = $this->createDeleteForm($actor);
        $editForm = $this->createForm('CoreBundle\Form\ActorEditType', $actor);
        $editForm->handleRequest($request);
        
        if ($editForm->isSubmitted() && $editForm->isValid()) {
            $em = $this->getDoctrine()->getManager();
            
            if($actor->getRemoveImage()){
                $actor->setImage(null);
            }
            
            //crypt password
            $password = $editForm->getNormData()->getPassword();
            if($password != ''){
                 
                $factory = $this->get('security.encoder_factory');
                $encoder = $factory->getEncoder(new BaseActor());
                $encodePassword = $encoder->encodePassword($password, $actor->getSalt());
                $actor->setPassword($encodePassword);
            }else{
                $actor->setPassword($oldPassword);
            }
            $em->persist($actor);
            $em->flush();
            
            //image
            $filesData = $request->files->get('actor_edit');
            if (isset($filesData['image']['file']) && $filesData['image']['file'] instanceof UploadedFile) {            
                $this->get('core_manager')->uploadProfileImage($actor);
            }

            $this->get('session')->getFlashBag()->add('success', 'actor.edited');
            
            return $this->redirectToRoute('core_actor_show', array('id' => $actor->getId()));
        }

        return array(
            'entity' => $actor,
            'edit_form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        );
    }
public function editAction(Request $request, Actor $actor)
    {
        $oldPassword = $actor->getPassword();
        $deleteForm = $this->createDeleteForm($actor);
        $editForm = $this->createForm('CoreBundle\Form\ActorEditType', $actor);
        $editForm->handleRequest($request);
        
        if ($editForm->isSubmitted() && $editForm->isValid()) {
            $em = $this->getDoctrine()->getManager();
            
            if($actor->getRemoveImage()){
                $actor->setImage(null);
            }
            
            //crypt password
            $password = $editForm->getNormData()->getPassword();
            if($password != ''){
                 
                $factory = $this->get('security.encoder_factory');
                $encoder = $factory->getEncoder(new BaseActor());
                $encodePassword = $encoder->encodePassword($password, $actor->getSalt());
                $actor->setPassword($encodePassword);
            }else{
                $actor->setPassword($oldPassword);
            }
            $em->persist($actor);
            $em->flush();
            
            //image
            $filesData = $request->files->get('actor_edit');
            if (isset($filesData['image']['file']) && $filesData['image']['file'] instanceof UploadedFile) {            
                $this->get('core_manager')->uploadProfileImage($actor);
            }

            $this->get('session')->getFlashBag()->add('success', 'actor.edited');
            
            return $this->redirectToRoute('core_actor_show', array('id' => $actor->getId()));
        }

        return array(
            'entity' => $actor,
            'edit_form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        );
    }
public function editAction ( Request $ request , Actor $ actor ) { $ oldPassword = $ actor -> getPassword ( ) ; $ deleteForm = $ this -> createDeleteForm ( $ actor ) ; $ editForm = $ this -> createForm ( 'CoreBundle\Form\ActorEditType' , $ actor ) ; $ editForm -> handleRequest ( $ request ) ; if ( $ editForm -> isSubmitted ( ) && $ editForm -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; if ( $ actor -> getRemoveImage ( ) ) { $ actor -> setImage ( null ) ; } //crypt password $ password = $ editForm -> getNormData ( ) -> getPassword ( ) ; if ( $ password != '' ) { $ factory = $ this -> get ( 'security.encoder_factory' ) ; $ encoder = $ factory -> getEncoder ( new BaseActor ( ) ) ; $ encodePassword = $ encoder -> encodePassword ( $ password , $ actor -> getSalt ( ) ) ; $ actor -> setPassword ( $ encodePassword ) ; } else { $ actor -> setPassword ( $ oldPassword ) ; } $ em -> persist ( $ actor ) ; $ em -> flush ( ) ; //image $ filesData = $ request -> files -> get ( 'actor_edit' ) ; if ( isset ( $ filesData [ 'image' ] [ 'file' ] ) && $ filesData [ 'image' ] [ 'file' ] instanceof UploadedFile ) { $ this -> get ( 'core_manager' ) -> uploadProfileImage ( $ actor ) ; } $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'actor.edited' ) ; return $ this -> redirectToRoute ( 'core_actor_show' , array ( 'id' => $ actor -> getId ( ) ) ) ; } return array ( 'entity' => $ actor , 'edit_form' => $ editForm -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ; }
Displays a form to edit an existing Actor entity.

@Route("/admin/actor/{id}/edit")
@Method({"GET", "POST"})
@Template()
Displays a form to edit an existing Actor entity .