Controller/BrowserController.php
public function filesAction(Request $request)
    {
        $id = $request->query->get('id');
        $em = $this->getDoctrine()->getManager();

        $files = $this->getDoctrine()->getRepository('ClasticMediaBundle:File')
            ->findBy(array(
                'directory' => $em->getReference('ClasticMediaBundle:Directory', $id),
            ));

        $data = array_map(function (File $file) {
            return array(
                'id' => $file->getId(),
                'text' => $file->getName(),
                'path' => '/uploads/documents/'.$file->getPath(),
            );
        }, $files);

        return new JsonResponse($data);
    }
public function filesAction(Request $request)
    {
        $id = $request->query->get('id');
        $em = $this->getDoctrine()->getManager();

        $files = $this->getDoctrine()->getRepository('ClasticMediaBundle:File')
            ->findBy(array(
                'directory' => $em->getReference('ClasticMediaBundle:Directory', $id),
            ));

        $data = array_map(function (File $file) {
            return array(
                'id' => $file->getId(),
                'text' => $file->getName(),
                'path' => '/uploads/documents/'.$file->getPath(),
            );
        }, $files);

        return new JsonResponse($data);
    }
public function filesAction ( Request $ request ) { $ id = $ request -> query -> get ( 'id' ) ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ files = $ this -> getDoctrine ( ) -> getRepository ( 'ClasticMediaBundle:File' ) -> findBy ( array ( 'directory' => $ em -> getReference ( 'ClasticMediaBundle:Directory' , $ id ) , ) ) ; $ data = array_map ( function ( File $ file ) { return array ( 'id' => $ file -> getId ( ) , 'text' => $ file -> getName ( ) , 'path' => '/uploads/documents/' . $ file -> getPath ( ) , ) ; } , $ files ) ; return new JsonResponse ( $ data ) ; }
Get all files is a specific folder.

@param Request $request

@return JsonResponse
Get all files is a specific folder .