src/Flowcode/ShopBundle/Controller/InventoryController.php
/**
     * Creates a new Inventory entity.
     *
     * @Route("/create", name="stock_inventory_create")
     * @Method("POST")
     * @Template("FlowerStockBundle:Inventory:new.html.twig")
     */
Creates a new Inventory entity.
Creates a new Inventory entity .
public function createAction(Request $request)
    {
        $inventory = new Inventory();
        $inventory->setStatus(Inventory::STATUS_DRAFT);
        $form = $this->createForm(new InventoryType(), $inventory);
        if ($form->handleRequest($request)->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $this->get('flower.stock.service.inventory')->fillInventory($inventory);
            $em->persist($inventory);
            $em->flush();
            return $this->redirect($this->generateUrl('stock_inventory_show', array('id' => $inventory->getId())));
        }
        return array(
            'inventory' => $inventory,
            'form' => $form->createView(),
        );
    }
public function createAction ( Request $ request ) { $ inventory = new Inventory ( ) ; $ inventory -> setStatus ( Inventory :: STATUS_DRAFT ) ; $ form = $ this -> createForm ( new InventoryType ( ) , $ inventory ) ; if ( $ form -> handleRequest ( $ request ) -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ this -> get ( 'flower.stock.service.inventory' ) -> fillInventory ( $ inventory ) ; $ em -> persist ( $ inventory ) ; $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'stock_inventory_show' , array ( 'id' => $ inventory -> getId ( ) ) ) ) ; } return array ( 'inventory' => $ inventory , 'form' => $ form -> createView ( ) , ) ; }
Creates a new Inventory entity.
Creates a new Inventory entity .