EcommerceBundle/Controller/FeatureController.php
public function sortAction(Request $request, $categoryId)
    {
        $em = $this->getDoctrine()->getManager();

        /** @var Category $category */
        $category = $em->getRepository('EcommerceBundle:Category')->find($categoryId);

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

        if ($request->isXmlHttpRequest()) {
            $this->get('admin_manager')->sort('EcommerceBundle:Feature', $request->get('values'));

            return new Response(0, 200);
        }

        $features = $em->getRepository('EcommerceBundle:Feature')->findBy(
            array('category' => $category),
            array('order' => 'asc')
        );

        return array(
            'features' => $features,
            'category' => $category
        );
    }
public function sortAction(Request $request, $categoryId)
    {
        $em = $this->getDoctrine()->getManager();

        /** @var Category $category */
        $category = $em->getRepository('EcommerceBundle:Category')->find($categoryId);

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

        if ($request->isXmlHttpRequest()) {
            $this->get('admin_manager')->sort('EcommerceBundle:Feature', $request->get('values'));

            return new Response(0, 200);
        }

        $features = $em->getRepository('EcommerceBundle:Feature')->findBy(
            array('category' => $category),
            array('order' => 'asc')
        );

        return array(
            'features' => $features,
            'category' => $category
        );
    }
public function sortAction ( Request $ request , $ categoryId ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; /** @var Category $category */ $ category = $ em -> getRepository ( 'EcommerceBundle:Category' ) -> find ( $ categoryId ) ; if ( ! $ category ) { throw $ this -> createNotFoundException ( 'Unable to find Category entity.' ) ; } if ( $ request -> isXmlHttpRequest ( ) ) { $ this -> get ( 'admin_manager' ) -> sort ( 'EcommerceBundle:Feature' , $ request -> get ( 'values' ) ) ; return new Response ( 0 , 200 ) ; } $ features = $ em -> getRepository ( 'EcommerceBundle:Feature' ) -> findBy ( array ( 'category' => $ category ) , array ( 'order' => 'asc' ) ) ; return array ( 'features' => $ features , 'category' => $ category ) ; }
Sorts a list of features.

@param Request $request
@param int     $categoryId

@throws NotFoundHttpException
@return array|Response

@Route("/category/{categoryId}/sort")
@Method({"GET", "POST"})
@Template
Sorts a list of features .