public function newAction(Request $request, $access)
    {
        $file = new SakonninFile();
        $form = $this->createCreateForm($file);
        $data = $request->request->all();

        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $sf = $this->container->get('sakonnin.files');
            $sf->storeFile($file, isset($data['file_context']) ? $data['file_context'] : array());

            if ($this->isRest($access)) {
                return $this->returnRestData($request, "OK Done");
            }
            return $this->redirectToRoute('file_show', array('id' => $file->getId()));
        }

        if ($this->isRest($access)) {
            # We have a problem, and need to tell our user what it is.
            # Better make this a Json some day.
            return $this->returnErrorResponse("Validation Error", 400,
                $this->handleFormErrors($form));
        }

        return $this->render('BisonLabSakonninBundle:SakonninFile:new.html.twig',
            array('file' => $file, 'form' => $form->createView()
        ));
    }
public function newAction(Request $request, $access)
    {
        $file = new SakonninFile();
        $form = $this->createCreateForm($file);
        $data = $request->request->all();

        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $sf = $this->container->get('sakonnin.files');
            $sf->storeFile($file, isset($data['file_context']) ? $data['file_context'] : array());

            if ($this->isRest($access)) {
                return $this->returnRestData($request, "OK Done");
            }
            return $this->redirectToRoute('file_show', array('id' => $file->getId()));
        }

        if ($this->isRest($access)) {
            # We have a problem, and need to tell our user what it is.
            # Better make this a Json some day.
            return $this->returnErrorResponse("Validation Error", 400,
                $this->handleFormErrors($form));
        }

        return $this->render('BisonLabSakonninBundle:SakonninFile:new.html.twig',
            array('file' => $file, 'form' => $form->createView()
        ));
    }
public function newAction ( Request $ request , $ access ) { $ file = new SakonninFile ( ) ; $ form = $ this -> createCreateForm ( $ file ) ; $ data = $ request -> request -> all ( ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ sf = $ this -> container -> get ( 'sakonnin.files' ) ; $ sf -> storeFile ( $ file , isset ( $ data [ 'file_context' ] ) ? $ data [ 'file_context' ] : array ( ) ) ; if ( $ this -> isRest ( $ access ) ) { return $ this -> returnRestData ( $ request , "OK Done" ) ; } return $ this -> redirectToRoute ( 'file_show' , array ( 'id' => $ file -> getId ( ) ) ) ; } if ( $ this -> isRest ( $ access ) ) { # We have a problem, and need to tell our user what it is. # Better make this a Json some day. return $ this -> returnErrorResponse ( "Validation Error" , 400 , $ this -> handleFormErrors ( $ form ) ) ; } return $ this -> render ( 'BisonLabSakonninBundle:SakonninFile:new.html.twig' , array ( 'file' => $ file , 'form' => $ form -> createView ( ) ) ) ; }
Creates a new file entity.

@Route("/new", name="file_new", methods={"GET", "POST"})
Creates a new file entity .