public function duplicateAction(Request $request)
    {
        /* @var $rep ItemRepository */
        $rep = $this->getDoctrine()->getRepository('AnimeDbCatalogBundle:Item');

        // get store item
        $item = $request->getSession()->get(self::NAME_ITEM_ADDED);
        if (!($item instanceof Item)) {
            throw $this->createNotFoundException('Not found item for confirm duplicate');
        }

        // confirm duplicate
        if ($request->isMethod('POST')) {
            $request->getSession()->remove(self::NAME_ITEM_ADDED);
            switch ($request->request->get('do')) {
                case 'add':
                    return $this->addItem($item->freez($this->getDoctrine()));
                default:
                    return $this->redirect($this->generateUrl('home'));
            }
        }

        // re searching for duplicates
        $duplicate = $rep->findDuplicate($item);
        // now there is no duplication
        if (!$duplicate) {
            return $this->addItem($item->freez($this->getDoctrine()));
        }

        return $this->render('AnimeDbCatalogBundle:Item:duplicate.html.twig', [
            'items' => $duplicate,
        ]);
    }
public function duplicateAction(Request $request)
    {
        /* @var $rep ItemRepository */
        $rep = $this->getDoctrine()->getRepository('AnimeDbCatalogBundle:Item');

        // get store item
        $item = $request->getSession()->get(self::NAME_ITEM_ADDED);
        if (!($item instanceof Item)) {
            throw $this->createNotFoundException('Not found item for confirm duplicate');
        }

        // confirm duplicate
        if ($request->isMethod('POST')) {
            $request->getSession()->remove(self::NAME_ITEM_ADDED);
            switch ($request->request->get('do')) {
                case 'add':
                    return $this->addItem($item->freez($this->getDoctrine()));
                default:
                    return $this->redirect($this->generateUrl('home'));
            }
        }

        // re searching for duplicates
        $duplicate = $rep->findDuplicate($item);
        // now there is no duplication
        if (!$duplicate) {
            return $this->addItem($item->freez($this->getDoctrine()));
        }

        return $this->render('AnimeDbCatalogBundle:Item:duplicate.html.twig', [
            'items' => $duplicate,
        ]);
    }
public function duplicateAction ( Request $ request ) { /* @var $rep ItemRepository */ $ rep = $ this -> getDoctrine ( ) -> getRepository ( 'AnimeDbCatalogBundle:Item' ) ; // get store item $ item = $ request -> getSession ( ) -> get ( self :: NAME_ITEM_ADDED ) ; if ( ! ( $ item instanceof Item ) ) { throw $ this -> createNotFoundException ( 'Not found item for confirm duplicate' ) ; } // confirm duplicate if ( $ request -> isMethod ( 'POST' ) ) { $ request -> getSession ( ) -> remove ( self :: NAME_ITEM_ADDED ) ; switch ( $ request -> request -> get ( 'do' ) ) { case 'add' : return $ this -> addItem ( $ item -> freez ( $ this -> getDoctrine ( ) ) ) ; default : return $ this -> redirect ( $ this -> generateUrl ( 'home' ) ) ; } } // re searching for duplicates $ duplicate = $ rep -> findDuplicate ( $ item ) ; // now there is no duplication if ( ! $ duplicate ) { return $ this -> addItem ( $ item -> freez ( $ this -> getDoctrine ( ) ) ) ; } return $ this -> render ( 'AnimeDbCatalogBundle:Item:duplicate.html.twig' , [ 'items' => $ duplicate , ] ) ; }
Confirm duplicate item.

@param Request $request

@return Response
Confirm duplicate item .