EcommerceBundle/Controller/FeatureValueController.php
public function createAction(Request $request, $featureId)
    {
        $em = $this->getDoctrine()->getManager();

        /** @var Feature $feature */
        $feature = $em->getRepository('EcommerceBundle:Feature')->find($featureId);

        if (!$feature) {
            throw $this->createNotFoundException('Unable to find Feature entity.');
        }

        $entity  = new FeatureValue();
        $form = $this->createForm(new FeatureValueType(), $entity);
        $entity->setFeature($feature);

        $form->bind($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($entity);
            $em->flush();

            $this->get('session')->getFlashBag()->add('success', 'value.created');

            return $this->redirect($this->generateUrl('ecommerce_featurevalue_show', array('featureId' => $featureId, 'id' => $entity->getId())));
        }

        return array(
            'entity'    => $entity,
            'feature' => $feature,
            'form'      => $form->createView(),
        );
    }
public function createAction(Request $request, $featureId)
    {
        $em = $this->getDoctrine()->getManager();

        /** @var Feature $feature */
        $feature = $em->getRepository('EcommerceBundle:Feature')->find($featureId);

        if (!$feature) {
            throw $this->createNotFoundException('Unable to find Feature entity.');
        }

        $entity  = new FeatureValue();
        $form = $this->createForm(new FeatureValueType(), $entity);
        $entity->setFeature($feature);

        $form->bind($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($entity);
            $em->flush();

            $this->get('session')->getFlashBag()->add('success', 'value.created');

            return $this->redirect($this->generateUrl('ecommerce_featurevalue_show', array('featureId' => $featureId, 'id' => $entity->getId())));
        }

        return array(
            'entity'    => $entity,
            'feature' => $feature,
            'form'      => $form->createView(),
        );
    }
public function createAction ( Request $ request , $ featureId ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; /** @var Feature $feature */ $ feature = $ em -> getRepository ( 'EcommerceBundle:Feature' ) -> find ( $ featureId ) ; if ( ! $ feature ) { throw $ this -> createNotFoundException ( 'Unable to find Feature entity.' ) ; } $ entity = new FeatureValue ( ) ; $ form = $ this -> createForm ( new FeatureValueType ( ) , $ entity ) ; $ entity -> setFeature ( $ feature ) ; $ form -> bind ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ entity ) ; $ em -> flush ( ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'value.created' ) ; return $ this -> redirect ( $ this -> generateUrl ( 'ecommerce_featurevalue_show' , array ( 'featureId' => $ featureId , 'id' => $ entity -> getId ( ) ) ) ) ; } return array ( 'entity' => $ entity , 'feature' => $ feature , 'form' => $ form -> createView ( ) , ) ; }
Creates a new FeatureValue entity.

@param Request $request   The request
@param int     $featureId The feature id

@throws NotFoundHttpException
@return array|RedirectResponse

@Route("/")
@Method("POST")
@Template("EcommerceBundle:FeatureValue:new.html.twig")
Creates a new FeatureValue entity .