22
33namespace librarianphp \Web ;
44
5+ use Librarian \ContentType ;
56use Librarian \Provider \TwigServiceProvider ;
67use Librarian \Response ;
78use Librarian \Provider \ContentServiceProvider ;
1415 */
1516class ContentController extends WebController
1617{
17- public function handle (): int
18+ public function handle (): void
1819 {
1920 /** @var TwigServiceProvider $twig */
2021 $ twig = $ this ->getApp ()->twig ;
@@ -37,17 +38,17 @@ public function handle(): int
3738 }
3839
3940 $ start = ($ page * $ limit ) - $ limit ;
40-
41- $ content_list = $ content_provider ->fetchFrom ($ request -> getRoute () , $ start , $ limit );
41+ $ contentType = $ content_provider -> getContentType ( $ request -> getRoute ());
42+ $ content_list = $ content_provider ->fetchFrom ($ contentType , $ start , $ limit );
4243 $ response = new Response ($ twig ->render ('content/listing.html.twig ' , [
4344 'content_list ' => $ content_list ,
4445 'total_pages ' => $ content_provider ->fetchTotalPages ($ limit ),
4546 'current_page ' => $ page ,
46- 'base_url ' => $ request ->getRoute ()
47+ 'base_url ' => $ request ->getRoute (),
48+ 'content_type ' => $ contentType
4749 ]));
4850
4951 $ response ->output ();
50- return 0 ;
5152 }
5253 } catch (\Exception $ e ) {
5354 Response::redirect ('/notfound ' );
@@ -60,6 +61,5 @@ public function handle(): int
6061
6162 $ response = new Response ($ output );
6263 $ response ->output ();
63- return 0 ;
6464 }
6565}
0 commit comments