src/Kunstmaan/AdminBundle/Controller/DefaultController.php
public function editIndexAction(Request $request)
    {
        /* @var $em EntityManager */
        $em = $this->getDoctrine()->getManager();

        /* @var DashboardConfiguration $dashboardConfiguration */
        $dashboardConfiguration = $em
            ->getRepository('KunstmaanAdminBundle:DashboardConfiguration')
            ->findOneBy(array());

        if (is_null($dashboardConfiguration)) {
            $dashboardConfiguration = new DashboardConfiguration();
        }
        $form = $this->createForm(DashboardConfigurationType::class, $dashboardConfiguration);

        if ($request->isMethod('POST')) {
            $form->handleRequest($request);
            if ($form->isSubmitted() && $form->isValid()) {
                $em->persist($dashboardConfiguration);
                $em->flush($dashboardConfiguration);

                $this->addFlash(
                    FlashTypes::SUCCESS,
                    $this->get('translator')->trans('kuma_admin.edit.flash.success')
                );

                return new RedirectResponse($this->generateUrl('KunstmaanAdminBundle_homepage'));
            }
        }

        return array(
            'form' => $form->createView(),
            'dashboardConfiguration' => $dashboardConfiguration,
        );
    }
public function editIndexAction(Request $request)
    {
        /* @var $em EntityManager */
        $em = $this->getDoctrine()->getManager();

        /* @var DashboardConfiguration $dashboardConfiguration */
        $dashboardConfiguration = $em
            ->getRepository('KunstmaanAdminBundle:DashboardConfiguration')
            ->findOneBy(array());

        if (is_null($dashboardConfiguration)) {
            $dashboardConfiguration = new DashboardConfiguration();
        }
        $form = $this->createForm(DashboardConfigurationType::class, $dashboardConfiguration);

        if ($request->isMethod('POST')) {
            $form->handleRequest($request);
            if ($form->isSubmitted() && $form->isValid()) {
                $em->persist($dashboardConfiguration);
                $em->flush($dashboardConfiguration);

                $this->addFlash(
                    FlashTypes::SUCCESS,
                    $this->get('translator')->trans('kuma_admin.edit.flash.success')
                );

                return new RedirectResponse($this->generateUrl('KunstmaanAdminBundle_homepage'));
            }
        }

        return array(
            'form' => $form->createView(),
            'dashboardConfiguration' => $dashboardConfiguration,
        );
    }
public function editIndexAction ( Request $ request ) { /* @var $em EntityManager */ $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; /* @var DashboardConfiguration $dashboardConfiguration */ $ dashboardConfiguration = $ em -> getRepository ( 'KunstmaanAdminBundle:DashboardConfiguration' ) -> findOneBy ( array ( ) ) ; if ( is_null ( $ dashboardConfiguration ) ) { $ dashboardConfiguration = new DashboardConfiguration ( ) ; } $ form = $ this -> createForm ( DashboardConfigurationType :: class , $ dashboardConfiguration ) ; if ( $ request -> isMethod ( 'POST' ) ) { $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em -> persist ( $ dashboardConfiguration ) ; $ em -> flush ( $ dashboardConfiguration ) ; $ this -> addFlash ( FlashTypes :: SUCCESS , $ this -> get ( 'translator' ) -> trans ( 'kuma_admin.edit.flash.success' ) ) ; return new RedirectResponse ( $ this -> generateUrl ( 'KunstmaanAdminBundle_homepage' ) ) ; } } return array ( 'form' => $ form -> createView ( ) , 'dashboardConfiguration' => $ dashboardConfiguration , ) ; }
The admin of the index page

@Route("/adminindex", name="KunstmaanAdminBundle_homepage_admin")
@Template("@KunstmaanAdmin/Default/editIndex.html.twig")

@param \Symfony\Component\HttpFoundation\Request $request

@return array
The admin of the index page