src/Flowcode/PageBundle/Controller/AdminPageController.php
public function createBlockAction(Request $request, $type)
    {
        $entity = new Block();
        $entity->setType($type);
        $form = $this->createBlockCreateForm($entity);
        $form->handleRequest($request);

        $availableLangs = $this->container->getParameter('flowcode_page.available_languages');

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $page = $entity->getPage();
            foreach ($availableLangs as $key => $value) {
                $entityLang = new Block();
                $entityLang->setName($entity->getName());
                $entityLang->setLang($key);
                $entityLang->setContent($entity->getContent());
                $entityLang->setPage($entity->getPage());
                $entityLang->setType($type);
                $em->persist($entityLang);
            }


            $em->flush();

            return $this->redirect($this->generateUrl('admin_page_show', array('id' => $page->getId())));
        }

        return array(
            'entity' => $entity,
            'form' => $form->createView(),
        );
    }
public function createBlockAction(Request $request, $type)
    {
        $entity = new Block();
        $entity->setType($type);
        $form = $this->createBlockCreateForm($entity);
        $form->handleRequest($request);

        $availableLangs = $this->container->getParameter('flowcode_page.available_languages');

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $page = $entity->getPage();
            foreach ($availableLangs as $key => $value) {
                $entityLang = new Block();
                $entityLang->setName($entity->getName());
                $entityLang->setLang($key);
                $entityLang->setContent($entity->getContent());
                $entityLang->setPage($entity->getPage());
                $entityLang->setType($type);
                $em->persist($entityLang);
            }


            $em->flush();

            return $this->redirect($this->generateUrl('admin_page_show', array('id' => $page->getId())));
        }

        return array(
            'entity' => $entity,
            'form' => $form->createView(),
        );
    }
public function createBlockAction ( Request $ request , $ type ) { $ entity = new Block ( ) ; $ entity -> setType ( $ type ) ; $ form = $ this -> createBlockCreateForm ( $ entity ) ; $ form -> handleRequest ( $ request ) ; $ availableLangs = $ this -> container -> getParameter ( 'flowcode_page.available_languages' ) ; if ( $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ page = $ entity -> getPage ( ) ; foreach ( $ availableLangs as $ key => $ value ) { $ entityLang = new Block ( ) ; $ entityLang -> setName ( $ entity -> getName ( ) ) ; $ entityLang -> setLang ( $ key ) ; $ entityLang -> setContent ( $ entity -> getContent ( ) ) ; $ entityLang -> setPage ( $ entity -> getPage ( ) ) ; $ entityLang -> setType ( $ type ) ; $ em -> persist ( $ entityLang ) ; } $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'admin_page_show' , array ( 'id' => $ page -> getId ( ) ) ) ) ; } return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , ) ; }
Creates a new Block entity.

@Route("/block/{type}", name="admin_page_block_create")
@Method("POST")
@Template("FlowcodePageBundle:AdminPage:new_block.html.twig")
Creates a new Block entity .