src/Flowcode/ShopBundle/Controller/AdminProductController.php
/**
     * Displays a form to create a new Gallery entity.
     *
     * @Route("/{product}/galleryitem/{id}/remove", name="admin_product_gallery_item_remove")
     */
Displays a form to create a new Gallery entity.
Displays a form to create a new Gallery entity .
public function removeitemAction(Product $product, Request $request, GalleryItem $entity)
    {
        $em = $this->getDoctrine()->getManager();
        $galleryItem = $em->getRepository('AmulenMediaBundle:GalleryItem')->find($entity->getId());
        $gallery = $galleryItem->getGallery();
        $em->remove($galleryItem);
        $em->flush();
        $i = 0;
        $galleryItems = $em->getRepository('AmulenMediaBundle:GalleryItem')->findBy(array("gallery" => $product->getMediaGallery()), array("position" => "ASC"));
        foreach ($galleryItems as $item) {
            $item->setPosition($i);
            $i++;
        }
        $em->flush();
        return $this->redirect($this->generateUrl('admin_product_show', array('id' => $product->getId())));
    }
public function removeitemAction ( Product $ product , Request $ request , GalleryItem $ entity ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ galleryItem = $ em -> getRepository ( 'AmulenMediaBundle:GalleryItem' ) -> find ( $ entity -> getId ( ) ) ; $ gallery = $ galleryItem -> getGallery ( ) ; $ em -> remove ( $ galleryItem ) ; $ em -> flush ( ) ; $ i = 0 ; $ galleryItems = $ em -> getRepository ( 'AmulenMediaBundle:GalleryItem' ) -> findBy ( array ( " gallery " => $ product -> getMediaGallery ( ) ) , array ( " position " => " ASC " ) ) ; foreach ( $ galleryItems as $ item ) { $ item -> setPosition ( $ i ) ; $ i ++ ; } $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'admin_product_show' , array ( 'id' => $ product -> getId ( ) ) ) ) ; }
Displays a form to create a new Gallery entity.
Displays a form to create a new Gallery entity .