| @@ 107-120 (lines=14) @@ | ||
| 104 | * @param string $slug |
|
| 105 | * @return string |
|
| 106 | */ |
|
| 107 | public function tag(ServerRequestInterface $request, $slug) |
|
| 108 | { |
|
| 109 | $this->provideWidgets(); |
|
| 110 | ||
| 111 | $paginator = $this->paginatorBuilder->build($request, $this->posts->byTagCount($slug)); |
|
| 112 | ||
| 113 | $posts = $this->posts->byTag($slug, $paginator->getCriteria()); |
|
| 114 | ||
| 115 | return $this->view('index.twig', [ |
|
| 116 | 'posts' => $posts, |
|
| 117 | 'paginator' => $paginator, |
|
| 118 | 'title' => 'Posty otagowane \''.$slug.'\'' |
|
| 119 | ]); |
|
| 120 | } |
|
| 121 | ||
| 122 | /** |
|
| 123 | * /?q={term} |
|
| @@ 129-143 (lines=15) @@ | ||
| 126 | * @param string $term |
|
| 127 | * @return string |
|
| 128 | */ |
|
| 129 | public function search(ServerRequestInterface $request, $term) |
|
| 130 | { |
|
| 131 | $this->provideWidgets(); |
|
| 132 | ||
| 133 | $paginator = $this->paginatorBuilder->build($request, $this->posts->searchCount($term)); |
|
| 134 | ||
| 135 | $posts = $this->posts->search($term, $paginator->getCriteria()); |
|
| 136 | ||
| 137 | return $this->view('index.twig', [ |
|
| 138 | 'posts' => $posts, |
|
| 139 | 'paginator' => $paginator, |
|
| 140 | 'title' => 'Wyniki wyszukiwania dla \''.$term.'\'', |
|
| 141 | 'searchTerm' => $term |
|
| 142 | ]); |
|
| 143 | } |
|
| 144 | ||
| 145 | protected function notFound() |
|
| 146 | { |
|