public function autocompleteNameAction(Request $request)
    {
        /* @var $response JsonResponse */
        $response = $this->getCacheTimeKeeper()
            ->getResponse('AnimeDbCatalogBundle:Item', -1, new JsonResponse());
        // response was not modified for this request
        if ($response->isNotModified($request)) {
            return $response;
        }

        $term = mb_strtolower($request->get('term'), 'UTF8');
        /* @var $service Manager */
        $service = $this->get('anime_db.item.search');
        $result = $service->searchByName($term, self::AUTOCOMPLETE_LIMIT);

        $list = [];
        /* @var $item Item */
        foreach ($result as $item) {
            if (strpos(mb_strtolower($item->getName(), 'UTF8'), $term) === 0) {
                $list[] = $item->getName();
            } else {
                /* @var $name Name */
                foreach ($item->getNames() as $name) {
                    if (strpos(mb_strtolower($name->getName(), 'UTF8'), $term) === 0) {
                        $list[] = $name->getName();
                        break;
                    }
                }
            }
        }

        return $response->setData($list);
    }
public function autocompleteNameAction(Request $request)
    {
        /* @var $response JsonResponse */
        $response = $this->getCacheTimeKeeper()
            ->getResponse('AnimeDbCatalogBundle:Item', -1, new JsonResponse());
        // response was not modified for this request
        if ($response->isNotModified($request)) {
            return $response;
        }

        $term = mb_strtolower($request->get('term'), 'UTF8');
        /* @var $service Manager */
        $service = $this->get('anime_db.item.search');
        $result = $service->searchByName($term, self::AUTOCOMPLETE_LIMIT);

        $list = [];
        /* @var $item Item */
        foreach ($result as $item) {
            if (strpos(mb_strtolower($item->getName(), 'UTF8'), $term) === 0) {
                $list[] = $item->getName();
            } else {
                /* @var $name Name */
                foreach ($item->getNames() as $name) {
                    if (strpos(mb_strtolower($name->getName(), 'UTF8'), $term) === 0) {
                        $list[] = $name->getName();
                        break;
                    }
                }
            }
        }

        return $response->setData($list);
    }
public function autocompleteNameAction ( Request $ request ) { /* @var $response JsonResponse */ $ response = $ this -> getCacheTimeKeeper ( ) -> getResponse ( 'AnimeDbCatalogBundle:Item' , - 1 , new JsonResponse ( ) ) ; // response was not modified for this request if ( $ response -> isNotModified ( $ request ) ) { return $ response ; } $ term = mb_strtolower ( $ request -> get ( 'term' ) , 'UTF8' ) ; /* @var $service Manager */ $ service = $ this -> get ( 'anime_db.item.search' ) ; $ result = $ service -> searchByName ( $ term , self :: AUTOCOMPLETE_LIMIT ) ; $ list = [ ] ; /* @var $item Item */ foreach ( $ result as $ item ) { if ( strpos ( mb_strtolower ( $ item -> getName ( ) , 'UTF8' ) , $ term ) === 0 ) { $ list [ ] = $ item -> getName ( ) ; } else { /* @var $name Name */ foreach ( $ item -> getNames ( ) as $ name ) { if ( strpos ( mb_strtolower ( $ name -> getName ( ) , 'UTF8' ) , $ term ) === 0 ) { $ list [ ] = $ name -> getName ( ) ; break ; } } } } return $ response -> setData ( $ list ) ; }
Autocomplete name.

@param Request $request

@return Response
Autocomplete name .