本文整理汇总了PHP中Pagerfanta\Pagerfanta::getNextPage方法的典型用法代码示例。如果您正苦于以下问题:PHP Pagerfanta::getNextPage方法的具体用法?PHP Pagerfanta::getNextPage怎么用?PHP Pagerfanta::getNextPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pagerfanta\Pagerfanta
的用法示例。
在下文中一共展示了Pagerfanta::getNextPage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(Pagerfanta $paginator, Request $request, $base_url)
{
$this->data = $paginator->getCurrentPageResults();
$this->total_count = $paginator->getNbResults();
$this->count = count($this->data);
$query = array('q' => $request->get('q'), 'limit' => $request->get('limit'), 'page' => $request->get('page'));
$this->query = $query;
$this->urls['current'] = $base_url . '?' . http_build_query($query);
if ($paginator->hasPreviousPage()) {
$query['page'] = $paginator->getPreviousPage();
$this->urls['previous'] = $base_url . '?' . http_build_query($query);
if ($paginator->getCurrentPage() > 2) {
$query['page'] = 1;
$this->urls['start'] = $base_url . '?' . http_build_query($query);
}
}
if ($paginator->hasNextPage()) {
$query['page'] = $paginator->getNextPage();
$this->urls['next'] = $base_url . '?' . http_build_query($query);
if ($paginator->getCurrentPage() < $paginator->getNbPages() - 1) {
$query['page'] = $paginator->getNbPages();
$this->urls['end'] = $base_url . '?' . http_build_query($query);
}
}
}
示例2: searchAction
public function searchAction(Request $request)
{
$format = $request->getRequestFormat();
$query = trim($request->query->get('q'));
if (empty($query)) {
if ('json' === $format) {
return new JsonResponse(array('status' => 'error', 'message' => 'Missing or too short search query, example: ?q=example'), 400);
}
return $this->render('KnpBundlesBundle:Bundle:search.html.twig');
}
// Skip search if query matches exactly one bundle name, and such was found in database
if (!$request->isXmlHttpRequest() && preg_match('/^[a-z0-9-]+\\/[a-z0-9-]+$/i', $query)) {
list($ownerName, $name) = explode('/', $query);
$bundle = $this->getRepository('Bundle')->findOneBy(array('ownerName' => $ownerName, 'name' => $name));
if ($bundle) {
return $this->redirect($this->generateUrl('bundle_show', array('ownerName' => $ownerName, 'name' => $name, '_format' => $format)));
}
}
/** @var $solarium \Solarium_Client */
$solarium = $this->get('solarium.client');
$select = $solarium->createSelect();
$escapedQuery = $select->getHelper()->escapeTerm($query);
$dismax = $select->getDisMax();
$dismax->setQueryFields(array('name^2', 'ownerName', 'fullName^1.5', 'description', 'keywords', 'text', 'text_ngram'));
$dismax->setPhraseFields(array('description^30'));
$dismax->setQueryParser('edismax');
$select->setQuery($escapedQuery);
try {
$paginator = new Pagerfanta(new SolariumAdapter($solarium, $select));
$paginator->setMaxPerPage($request->query->get('limit', 10))->setCurrentPage($request->query->get('page', 1), false, true);
if (1 === $paginator->getNbResults() && !$request->isXmlHttpRequest()) {
$first = $paginator->getCurrentPageResults()->getIterator()->current();
if (strtolower($first['name']) == strtolower($query)) {
return $this->redirect($this->generateUrl('bundle_show', array('ownerName' => $first['ownerName'], 'name' => $first['name'], '_format' => $format)));
}
}
} catch (\Solarium_Client_HttpException $e) {
$msg = 'Seems that our search engine is currently offline. Please check later.';
if ('json' === $format) {
return new JsonResponse(array('status' => 'error', 'message' => $msg), 500);
}
throw new HttpException(500, $msg);
}
if ('json' === $format) {
$result = array('results' => array(), 'total' => $paginator->getNbResults());
foreach ($paginator as $bundle) {
$result['results'][] = array('name' => $bundle->fullName, 'description' => null !== $bundle->description ? substr($bundle->description, 0, 110) . '...' : '', 'avatarUrl' => $bundle->avatarUrl ?: 'http://www.gravatar.com/avatar/?d=identicon&f=y&s=50', 'state' => $bundle->state, 'score' => $bundle->totalScore, 'url' => $this->generateUrl('bundle_show', array('ownerName' => $bundle->ownerName, 'name' => $bundle->name), true));
}
if (!$request->isXmlHttpRequest()) {
if ($paginator->hasPreviousPage()) {
$result['prev'] = $this->generateUrl('search', array('q' => urldecode($query), 'page' => $paginator->getPreviousPage(), '_format' => 'json'), true);
}
if ($paginator->hasNextPage()) {
$result['next'] = $this->generateUrl('search', array('q' => urldecode($query), 'page' => $paginator->getNextPage(), '_format' => 'json'), true);
}
}
return new JsonResponse($request->isXmlHttpRequest() ? $result['results'] : $result);
}
return $this->render('KnpBundlesBundle:Bundle:searchResults.html.twig', array('query' => urldecode($query), 'bundles' => $paginator));
}
示例3: next
/**
* {@inheritdoc}
*/
public function next()
{
$this->currentPage++;
if ($this->valid()) {
$this->pager->setCurrentPage($this->pager->getNextPage());
}
}
示例4: createCollection
public function createCollection(QueryBuilder $qb, Request $request, $route, array $routeParams = array())
{
$page = $request->query->get(self::PARAMETER_NAME_PAGE_NUMBER, 1);
$count = $request->query->get(self::PARAMETER_NAME_PAGE_SIZE, self::PAGE_DEFAULT_COUNT);
if ($count > self::MAX_PAGE_COUNT) {
$count = self::MAX_PAGE_COUNT;
}
if ($count <= 0) {
$count = self::PAGE_DEFAULT_COUNT;
}
$adapter = new DoctrineORMAdapter($qb);
$pagerfanta = new Pagerfanta($adapter);
$pagerfanta->setMaxPerPage($count);
$pagerfanta->setCurrentPage($page);
$players = [];
foreach ($pagerfanta->getCurrentPageResults() as $result) {
$players[] = $result;
}
$paginatedCollection = new PaginatedCollection($players, $pagerfanta->getNbResults());
// make sure query parameters are included in pagination links
$routeParams = array_merge($routeParams, $request->query->all());
$createLinkUrl = function ($targetPage) use($route, $routeParams) {
return $this->router->generate($route, array_merge($routeParams, array(self::PARAMETER_NAME_PAGE_NUMBER => $targetPage)));
};
$paginatedCollection->addLink('self', $createLinkUrl($page));
$paginatedCollection->addLink('first', $createLinkUrl(1));
$paginatedCollection->addLink('last', $createLinkUrl($pagerfanta->getNbPages()));
if ($pagerfanta->hasNextPage()) {
$paginatedCollection->addLink('next', $createLinkUrl($pagerfanta->getNextPage()));
}
if ($pagerfanta->hasPreviousPage()) {
$paginatedCollection->addLink('prev', $createLinkUrl($pagerfanta->getPreviousPage()));
}
return $paginatedCollection;
}
示例5: paginate
/**
* Paginate to the next dataset if possible
*/
protected function paginate()
{
if ($this->currentItem == $this->pagerfanta->getMaxPerPage() and $this->pagerfanta->hasNextPage()) {
$this->pagerfanta->setCurrentPage($this->pagerfanta->getNextPage());
$this->loadData();
}
}
示例6: testGetNextPageShouldThrowALogicExceptionIfTheCurrentPageIsTheLast
/**
* @expectedException Pagerfanta\Exception\LogicException
*/
public function testGetNextPageShouldThrowALogicExceptionIfTheCurrentPageIsTheLast()
{
$this->setAdapterNbResultsAny(100);
$this->pagerfanta->setMaxPerPage(10);
$this->pagerfanta->setCurrentPage(10);
$this->pagerfanta->getNextPage();
}
示例7: addPagination
protected function addPagination(Request $request, Pagerfanta $pager, $resource)
{
$route = $request->attributes->get('_route');
$params = $request->attributes->get('_route_params');
$params = array_merge($params, $request->query->all());
$resource->setMetaValue('page', $pager->getCurrentPage());
$resource->setMetaValue('count', $pager->getNbResults());
$resource->setMetaValue('nextPage', null);
$resource->setMetaValue('previousPage', null);
$resource->setMetaValue('next', null);
$resource->setMetaValue('previous', null);
if ($pager->hasNextPage()) {
$resource->setMetaValue('next', $this->generateUrl($route, array_replace($params, ['page' => $pager->getNextPage(), 'limit' => $pager->getMaxPerPage()]), true));
$resource->setMetaValue('nextPage', $pager->getNextPage());
}
if ($pager->hasPreviousPage()) {
$resource->setMetaValue('previous', $this->generateUrl($route, array_replace($params, ['page' => $pager->getPreviousPage(), 'limit' => $pager->getMaxPerPage()]), true));
$resource->setMetaValue('previousPage', $pager->getPreviousPage());
}
}
示例8: serializePagerfanta
/**
* @param JsonApiSerializationVisitor $visitor
* @param Pagerfanta $pagerfanta
* @param array $type
* @param Context $context
* @return Pagerfanta
*/
public function serializePagerfanta(JsonApiSerializationVisitor $visitor, Pagerfanta $pagerfanta, array $type, Context $context)
{
$request = $this->requestStack->getCurrentRequest();
$pagerfanta->setNormalizeOutOfRangePages(true);
$pagerfanta->setAllowOutOfRangePages(true);
$pagerfanta->setMaxPerPage($request->get('page[limit]', $this->paginationOptions['limit'], true));
$pagerfanta->setCurrentPage($request->get('page[number]', 1, true));
$results = $pagerfanta->getCurrentPageResults();
if ($results instanceof \ArrayIterator) {
$results = $results->getArrayCopy();
}
$data = $context->accept($results);
$root = $visitor->getRoot();
$root['meta'] = array('page' => $pagerfanta->getCurrentPage(), 'limit' => $pagerfanta->getMaxPerPage(), 'pages' => $pagerfanta->getNbPages(), 'total' => $pagerfanta->getNbResults());
$root['links'] = array('first' => $this->getUriForPage(1), 'last' => $this->getUriForPage($pagerfanta->getNbPages()), 'prev' => $pagerfanta->hasPreviousPage() ? $this->getUriForPage($pagerfanta->getPreviousPage()) : null, 'next' => $pagerfanta->hasNextPage() ? $this->getUriForPage($pagerfanta->getNextPage()) : null);
$visitor->setRoot($root);
return $data;
}
示例9: getNavigationLinks
private function getNavigationLinks(Pagerfanta $pager, array $params = array())
{
$page = $pager->getCurrentPage();
$limit = $pager->getMaxPerPage();
$links = [];
if ($pager->getCurrentPage() > 1) {
$links['first'] = $this->generateUrl('app_api_categories', array_merge($params, ['offset' => $this->getOffset(1, $limit)]));
}
if ($pager->hasPreviousPage()) {
$links['previous'] = $this->generateUrl('app_api_categories', array_merge($params, ['offset' => $this->getOffset($pager->getPreviousPage(), $limit)]));
}
if ($pager->hasNextPage()) {
$links['next'] = $this->generateUrl('app_api_categories', array_merge($params, ['offset' => $this->getOffset($pager->getNextPage(), $limit)]));
}
if ($pager->getNbPages() != $page) {
$links['last'] = $this->generateUrl('app_api_categories', array_merge($params, ['offset' => $this->getOffset($pager->getNbPages(), $limit)]));
}
return $links;
}
示例10: getFolderChildrens
/**
* Return list of children node
* @param \eZ\Publish\Core\Repository\Values\Content\Location $location
* @param type $maxPerPage
* @param type $currentPage
* @return type
*/
public function getFolderChildrens(\eZ\Publish\Core\Repository\Values\Content\Location $location, $currentUser, $maxPerPage, $currentPage = 1, $category)
{
$criteria = array(new Criterion\ParentLocationId($location->id), new Criterion\ContentTypeIdentifier(array('service_link')), new Criterion\Visibility(Criterion\Visibility::VISIBLE));
if (isset($category) && $category != "all") {
$criteria[] = new Criterion\Field('category', Criterion\Operator::CONTAINS, $category);
}
$query = new Query();
$query->filter = new Criterion\LogicalAnd($criteria);
$query->sortClauses = array($this->sortClauseAuto($location));
$searchResult = $this->repository->getSearchService()->findContent($query);
$subscritions = $this->fetchByUserId($currentUser->id);
//$this->debug($subscritions);
$content = array();
$contentId = null;
foreach ($searchResult->searchHits as $serviceLink) {
if (!$contentId) {
$contentId = $serviceLink->valueObject->getVersionInfo()->getContentInfo()->id;
}
$content[] = array('serviceLink' => $serviceLink->valueObject->contentInfo->mainLocationId, 'subscrition' => $this->hasSubscription($subscritions, $serviceLink->valueObject->getVersionInfo()->getContentInfo()->id));
}
$result['offset'] = ($currentPage - 1) * $maxPerPage;
$adapter = new ArrayAdapter($content);
$pagerfanta = new Pagerfanta($adapter);
$pagerfanta->setMaxPerPage($maxPerPage);
$pagerfanta->setCurrentPage($currentPage);
$httpReferer = $_SERVER['SCRIPT_URL'];
if (isset($category)) {
$httpReferer .= "?category=" . $category;
} else {
$httpReferer .= "?";
}
$result['offset'] = ($currentPage - 1) * $maxPerPage;
$result['prev_page'] = $pagerfanta->hasPreviousPage() ? $pagerfanta->getPreviousPage() : 0;
$result['next_page'] = $pagerfanta->hasNextPage() ? $pagerfanta->getNextPage() : 0;
$result['nb_pages'] = $pagerfanta->getNbPages();
$result['items'] = $pagerfanta->getCurrentPageResults();
$result['base_href'] = $httpReferer;
$result['current_page'] = $pagerfanta->getCurrentPage();
$result['options'] = isset($contentId) ? $this->getCategorie($contentId, "ezselection") : array();
return $result;
}
示例11: getPagerMeta
/**
* @param Pagerfanta $pager
*
* @return array
*/
protected function getPagerMeta(Pagerfanta $pager)
{
if ($pager instanceof OutOfRangePager) {
return array('currentPage' => $pager->getOriginalPage(), 'maxPerPage' => $pager->getMaxPerPage(), 'hasNextPage' => false, 'outOfRange' => true);
}
$meta = array('currentPage' => $pager->getCurrentPage(), 'maxPerPage' => $pager->getMaxPerPage(), 'pagesCount' => $pager->getNbPages(), 'hasNextPage' => $pager->hasNextPage(), 'resultsCount' => $pager->getNbResults(), 'hasPreviousPage' => $pager->hasPreviousPage());
if ($pager->hasNextPage()) {
$meta['nextPage'] = $pager->getNextPage();
}
if ($pager->hasPreviousPage()) {
$meta['previousPage'] = $pager->getPreviousPage();
}
return $meta;
}
示例12: configureCollectionRepresentation
protected function configureCollectionRepresentation(CollectionRepresentation $collectionRepresentation, Pagerfanta $pager, $entity = null, $collectionRel = null)
{
// Properties
$collectionRepresentation->total = $pager->getNbResults();
$collectionRepresentation->page = $pager->getCurrentPage();
$collectionRepresentation->limit = $pager->getMaxPerPage();
// Links between pages
$createRoute = function ($page, $limit) use($entity, $collectionRel) {
$parameters = array('search' => array('page' => $page, 'limit' => $limit));
return null !== $entity && null !== $collectionRel ? $this->getUrlGenerator()->generateEntityCollectionUrl($entity, $collectionRel, $parameters) : $this->getUrlGenerator()->generateCollectionUrl($parameters);
};
$collectionRepresentation->addLink($this->atomLinkFactory->create('self', $createRoute($pager->getCurrentPage(), $pager->getMaxPerPage())));
if ($pager->hasNextPage()) {
$collectionRepresentation->addLink($this->atomLinkFactory->create('next', $createRoute($pager->getNextPage(), $pager->getMaxPerPage())));
}
if ($pager->hasPreviousPage()) {
$collectionRepresentation->addLink($this->atomLinkFactory->create('previous', $createRoute($pager->getPreviousPage(), $pager->getMaxPerPage())));
}
$collectionRepresentation->addLink($this->atomLinkFactory->create('first', $createRoute(1, $pager->getMaxPerPage())));
$collectionRepresentation->addLink($this->atomLinkFactory->create('last', $createRoute($pager->getNbPages(), $pager->getMaxPerPage())));
}
示例13: addLinksToMetadata
/**
* @param Pagerfanta $paginator
* @param $route
* @param $limit
*/
protected function addLinksToMetadata(Pagerfanta $paginator, $route, $limit)
{
$data = $this->get('bite_codes_rest_api_generator.services.response_data');
$router = $this->get('router');
$first = $router->generate($route, ['page' => 1, 'limit' => $limit], UrlGeneratorInterface::ABSOLUTE_URL);
$prev = $paginator->hasPreviousPage() ? $router->generate($route, ['page' => $paginator->getPreviousPage(), 'limit' => $limit], UrlGeneratorInterface::ABSOLUTE_URL) : null;
$current = $router->generate($route, ['page' => $paginator->getCurrentPage(), 'limit' => $limit], UrlGeneratorInterface::ABSOLUTE_URL);
$next = $paginator->hasNextPage() ? $router->generate($route, ['page' => $paginator->getNextPage(), 'limit' => $limit], UrlGeneratorInterface::ABSOLUTE_URL) : null;
$last = $router->generate($route, ['page' => $paginator->getNbPages(), 'limit' => $limit], UrlGeneratorInterface::ABSOLUTE_URL);
$data->addLink('first', $first);
$data->addLink('prev', $prev);
$data->addLink('current', $current);
$data->addLink('next', $next);
$data->addLink('last', $last);
$data->addMeta('total', $paginator->getNbResults());
}
示例14: searchAction
/**
* @Route("/search/", name="search.ajax")
* @Route("/search.{_format}", requirements={"_format"="(html|json)"}, name="search", defaults={"_format"="html"})
* @Method({"GET"})
*/
public function searchAction(Request $req)
{
$form = $this->createForm(SearchQueryType::class, new SearchQuery());
$filteredOrderBys = $this->getFilteredOrderedBys($req);
$normalizedOrderBys = $this->getNormalizedOrderBys($filteredOrderBys);
$this->computeSearchQuery($req, $filteredOrderBys);
$typeFilter = str_replace('%type%', '', $req->query->get('type'));
$tagsFilter = $req->query->get('tags');
if ($req->query->has('search_query') || $typeFilter || $tagsFilter) {
/** @var $solarium \Solarium_Client */
$solarium = $this->get('solarium.client');
$select = $solarium->createSelect();
// configure dismax
$dismax = $select->getDisMax();
$dismax->setQueryFields(array('name^4', 'package_name^4', 'description', 'tags', 'text', 'text_ngram', 'name_split^2'));
$dismax->setPhraseFields(array('description'));
$dismax->setBoostFunctions(array('log(trendiness)^10'));
$dismax->setMinimumMatch(1);
$dismax->setQueryParser('edismax');
// filter by type
if ($typeFilter) {
$filterQueryTerm = sprintf('type:"%s"', $select->getHelper()->escapeTerm($typeFilter));
$filterQuery = $select->createFilterQuery('type')->setQuery($filterQueryTerm);
$select->addFilterQuery($filterQuery);
}
// filter by tags
if ($tagsFilter) {
$tags = array();
foreach ((array) $tagsFilter as $tag) {
$tags[] = $select->getHelper()->escapeTerm($tag);
}
$filterQueryTerm = sprintf('tags:("%s")', implode('" AND "', $tags));
$filterQuery = $select->createFilterQuery('tags')->setQuery($filterQueryTerm);
$select->addFilterQuery($filterQuery);
}
if (!empty($filteredOrderBys)) {
$select->addSorts($normalizedOrderBys);
}
$form->handleRequest($req);
if ($form->isValid()) {
$escapedQuery = $select->getHelper()->escapeTerm($form->getData()->getQuery());
$escapedQuery = preg_replace('/(^| )\\\\-(\\S)/', '$1-$2', $escapedQuery);
$escapedQuery = preg_replace('/(^| )\\\\\\+(\\S)/', '$1+$2', $escapedQuery);
if (substr_count($escapedQuery, '"') % 2 == 0) {
$escapedQuery = str_replace('\\"', '"', $escapedQuery);
}
$select->setQuery($escapedQuery);
}
$paginator = new Pagerfanta(new SolariumAdapter($solarium, $select));
$perPage = $req->query->getInt('per_page', 15);
if ($perPage <= 0 || $perPage > 100) {
if ($req->getRequestFormat() === 'json') {
return JsonResponse::create(array('status' => 'error', 'message' => 'The optional packages per_page parameter must be an integer between 1 and 100 (default: 15)'), 400)->setCallback($req->query->get('callback'));
}
$perPage = max(0, min(100, $perPage));
}
$paginator->setMaxPerPage($perPage);
$paginator->setCurrentPage($req->query->get('page', 1), false, true);
$metadata = array();
foreach ($paginator as $package) {
if (is_numeric($package->id)) {
$metadata['downloads'][$package->id] = $package->downloads;
$metadata['favers'][$package->id] = $package->favers;
}
}
if ($req->getRequestFormat() === 'json') {
try {
$result = array('results' => array(), 'total' => $paginator->getNbResults());
} catch (\Solarium_Client_HttpException $e) {
return JsonResponse::create(array('status' => 'error', 'message' => 'Could not connect to the search server'), 500)->setCallback($req->query->get('callback'));
}
foreach ($paginator as $package) {
if (ctype_digit((string) $package->id)) {
$url = $this->generateUrl('view_package', array('name' => $package->name), UrlGeneratorInterface::ABSOLUTE_URL);
} else {
$url = $this->generateUrl('view_providers', array('name' => $package->name), UrlGeneratorInterface::ABSOLUTE_URL);
}
$row = array('name' => $package->name, 'description' => $package->description ?: '', 'url' => $url, 'repository' => $package->repository);
if (is_numeric($package->id)) {
$row['downloads'] = $metadata['downloads'][$package->id];
$row['favers'] = $metadata['favers'][$package->id];
} else {
$row['virtual'] = true;
}
$result['results'][] = $row;
}
if ($paginator->hasNextPage()) {
$params = array('_format' => 'json', 'q' => $form->getData()->getQuery(), 'page' => $paginator->getNextPage());
if ($tagsFilter) {
$params['tags'] = (array) $tagsFilter;
}
if ($typeFilter) {
$params['type'] = $typeFilter;
}
if ($perPage !== 15) {
//.........这里部分代码省略.........
示例15: searchAction
/**
* @Route("/search/", name="search.ajax")
* @Route("/search.{_format}", requirements={"_format"="(html|json)"}, name="search", defaults={"_format"="html"})
*/
public function searchAction(Request $req)
{
$form = $this->createSearchForm();
// transform q=search shortcut
if ($req->query->has('q')) {
$req->query->set('search_query', array('query' => $req->query->get('q')));
} elseif ($req->getRequestFormat() === 'json') {
return new JsonResponse(array('error' => 'Missing search query, example: ?q=example'), 400);
}
if ($req->query->has('search_query')) {
$form->bind($req);
if ($form->isValid()) {
/** @var $solarium \Solarium_Client */
$solarium = $this->get('solarium.client');
$select = $solarium->createSelect();
$escapedQuery = $select->getHelper()->escapeTerm($form->getData()->getQuery());
$typeFilter = $req->query->get('type');
// filter by type
if ($typeFilter !== null) {
$filterQueryTerm = sprintf('type:%s', $select->getHelper()->escapeTerm($typeFilter));
$filterQuery = $select->createFilterQuery('type')->setQuery($filterQueryTerm);
$select->addFilterQuery($filterQuery);
}
$dismax = $select->getDisMax();
$dismax->setQueryFields(array('name^2', 'description', 'tags', 'text', 'text_ngram', 'name_split^1.5'));
$dismax->setPhraseFields(array('description^30'));
//this is very lenient, and may want to be refined
$dismax->setMinimumMatch(1);
$dismax->setQueryParser('edismax');
$select->setQuery($escapedQuery);
$paginator = new Pagerfanta(new SolariumAdapter($solarium, $select));
$paginator->setMaxPerPage(15);
$paginator->setCurrentPage($req->query->get('page', 1), false, true);
if ($req->getRequestFormat() === 'json') {
$result = array('results' => array(), 'total' => $paginator->getNbResults());
foreach ($paginator as $package) {
$url = $this->generateUrl('view_package', array('name' => $package->name), true);
$result['results'][] = array('name' => $package->name, 'description' => $package->description ?: '', 'url' => $url);
}
if ($paginator->hasNextPage()) {
$result['next'] = $this->generateUrl('search', array('_format' => 'json', 'q' => $form->getData()->getQuery(), 'page' => $paginator->getNextPage()), true);
}
return new JsonResponse($result);
}
if ($req->isXmlHttpRequest()) {
return $this->render('PackagistWebBundle:Web:list.html.twig', array('packages' => $paginator, 'noLayout' => true));
}
return $this->render('PackagistWebBundle:Web:search.html.twig', array('packages' => $paginator, 'searchForm' => $form->createView()));
}
}
return $this->render('PackagistWebBundle:Web:search.html.twig', array('searchForm' => $form->createView()));
}