/**
  * Populate content for the request
  *
  * @param Route $route
  * @param Request $request
  */
 protected function populateContent(Route $route, Request $request)
 {
     $content = $route->getContent();
     $name = $content;
     if ($route->isList()) {
         $name .= 's';
         $value = $this->repository->getContents($content, $route->getIndexBy(), $route->getOrder());
         if ($route->isPaginated()) {
             $paginator = new Paginator($value, $route->getPerPage());
             $value = $paginator->get($request->attributes->get('page'));
             $request->attributes->set('paginator', $paginator);
         }
     } else {
         $value = $this->repository->getContent($content, $request->attributes->get($content));
     }
     $request->attributes->set($name, $value);
 }
예제 #2
0
 /**
  * Dump route content to destination file
  *
  * @param Route $route
  * @param string $name
  */
 protected function dump(Route $route, $name)
 {
     if (!$route->isVisible()) {
         return;
     }
     if (!in_array('GET', $route->getMethods())) {
         throw new Exception(sprintf('Only GET mehtod supported, "%s" given.', $name));
     }
     if ($route->hasContent()) {
         if ($route->isList()) {
             if ($route->isPaginated()) {
                 $this->buildPaginatedRoute($route, $name);
             } else {
                 $this->buildListRoute($route, $name);
             }
         } else {
             $this->buildContentRoute($route, $name);
         }
     } else {
         $this->logger->log(sprintf('Building route <comment>%s</comment>', $name));
         $this->builder->build($route, $name);
     }
 }