public function createAction(Request $request, AbstractAdmin $admin)
    {
        $translator = $this->getTranslator();

        // prepare entity
        $entityClass = $admin->getEntityClass();
        $entity = new $entityClass();

        $this->secure($admin, ContentVoter::CREATE_CONTENT, $entity);

        $form = $this->getCreateForm($admin, $entity);

        $form->handleRequest($request);
        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $admin->prePersist($entity);
            $em->persist($entity);
            $admin->postPersist($entity);
            $em->flush();

            $this->get('session')->getFlashBag()->add('success', $translator->trans('crud.create.success', [], 'ShuweeAdminBundle'));

            return $this->redirect($this->getAdminRoutingHelper()->generateUrl($admin, 'index'));
        }

        $admin->preCreateFormRender($form);

        return $this->render(
            'ShuweeAdminBundle:Content:create.html.twig',
            [
                'admin' => $admin,
                'form' => $form->createView(),
            ]
        );
    }
public function createAction(Request $request, AbstractAdmin $admin)
    {
        $translator = $this->getTranslator();

        // prepare entity
        $entityClass = $admin->getEntityClass();
        $entity = new $entityClass();

        $this->secure($admin, ContentVoter::CREATE_CONTENT, $entity);

        $form = $this->getCreateForm($admin, $entity);

        $form->handleRequest($request);
        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $admin->prePersist($entity);
            $em->persist($entity);
            $admin->postPersist($entity);
            $em->flush();

            $this->get('session')->getFlashBag()->add('success', $translator->trans('crud.create.success', [], 'ShuweeAdminBundle'));

            return $this->redirect($this->getAdminRoutingHelper()->generateUrl($admin, 'index'));
        }

        $admin->preCreateFormRender($form);

        return $this->render(
            'ShuweeAdminBundle:Content:create.html.twig',
            [
                'admin' => $admin,
                'form' => $form->createView(),
            ]
        );
    }
public function createAction ( Request $ request , AbstractAdmin $ admin ) { $ translator = $ this -> getTranslator ( ) ; // prepare entity $ entityClass = $ admin -> getEntityClass ( ) ; $ entity = new $ entityClass ( ) ; $ this -> secure ( $ admin , ContentVoter :: CREATE_CONTENT , $ entity ) ; $ form = $ this -> getCreateForm ( $ admin , $ entity ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ admin -> prePersist ( $ entity ) ; $ em -> persist ( $ entity ) ; $ admin -> postPersist ( $ entity ) ; $ em -> flush ( ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , $ translator -> trans ( 'crud.create.success' , [ ] , 'ShuweeAdminBundle' ) ) ; return $ this -> redirect ( $ this -> getAdminRoutingHelper ( ) -> generateUrl ( $ admin , 'index' ) ) ; } $ admin -> preCreateFormRender ( $ form ) ; return $ this -> render ( 'ShuweeAdminBundle:Content:create.html.twig' , [ 'admin' => $ admin , 'form' => $ form -> createView ( ) , ] ) ; }
Create an entity of given type

@param \Symfony\Component\HttpFoundation\Request $request
@param \Wanjee\Shuwee\AdminBundle\Admin\AbstractAdmin $admin
@return \Symfony\Component\HttpFoundation\Response
Create an entity of given type