示例#1
0
 /**
  * List
  *
  * @param Request $request
  * @param Application $app
  * @param integer $page
  *
  * @return Response
  */
 public function index(Request $request, Application $app, Paginator $paginator, array $articles, $page = 1)
 {
     return ['articles' => $articles, 'pages' => $paginator->count(), 'page' => $page];
 }
示例#2
0
 /**
  * Build paginated route
  *
  * @param Route $route
  * @param string $name
  */
 protected function buildPaginatedRoute(Route $route, $name)
 {
     $contentType = $route->getContent();
     $contents = $this->app['content_repository']->listContents($contentType);
     $paginator = new Paginator($contents, $route->getPerPage());
     $this->logger->log(sprintf('Building route <comment>%s</comment> for <info>%s</info> pages', $name, $paginator->count()));
     $this->logger->getProgress($paginator->count());
     $this->logger->start();
     foreach ($paginator as $index => $contents) {
         $this->builder->build($route, $name, ['page' => $index + 1]);
         $this->logger->advance();
     }
     $this->logger->finish();
 }