Update star route.
This commit is contained in:
13
browser.php
13
browser.php
@@ -7,6 +7,7 @@ use Krzysiej\RyobiCrawler\Controller\CategoryController;
|
||||
use Krzysiej\RyobiCrawler\Controller\IndexController;
|
||||
use Krzysiej\RyobiCrawler\Controller\ProductController;
|
||||
use Krzysiej\RyobiCrawler\Controller\SearchController;
|
||||
use Krzysiej\RyobiCrawler\Controller\StarController;
|
||||
use Krzysiej\RyobiCrawler\Models\Product;
|
||||
use Twig\{Environment, Loader\FilesystemLoader};
|
||||
use Symfony\Component\Routing\Matcher\UrlMatcher;
|
||||
@@ -17,15 +18,17 @@ use Symfony\Component\Routing\RouteCollection;
|
||||
if (!file_exists('database.sqlite')) {
|
||||
exit('Database file <code>database.sqlite</code> missing. Run docker compose <blockquote>docker compose exec php-app php index.php app:migrate</blockquote> to create it.');
|
||||
}
|
||||
$productRoute = new Route('browser.php/product/{product_id}', ['_controller' => ProductController::class], ['product_id' => '\d+']);
|
||||
$searchRoute = new Route('browser.php?search={search_term}', ['_controller' => SearchController::class]);
|
||||
$productRoute = new Route('/browser.php/product/{product_id}', ['_controller' => ProductController::class], ['product_id' => '\d+']);
|
||||
$searchRoute = new Route('/browser.php?search={search_term}', ['_controller' => SearchController::class]);
|
||||
$categoryRoute = new Route('/browser.php/category/{category_name}', ['_controller' => CategoryController::class]);
|
||||
$indexRoute = new Route('browser.php', ['_controller' => IndexController::class]);
|
||||
$starRoute = new Route('/browser.php/star/{product_id}', ['_controller' => StarController::class]);
|
||||
$indexRoute = new Route('/browser.php', ['_controller' => IndexController::class]);
|
||||
$routes = new RouteCollection();
|
||||
|
||||
$routes->add('product_show', $productRoute);
|
||||
$routes->add('search_show', $searchRoute);
|
||||
$routes->add('category_show', $categoryRoute);
|
||||
$routes->add('start_show', $starRoute);
|
||||
$routes->add('index_show', $indexRoute);
|
||||
|
||||
$context = new RequestContext();
|
||||
@@ -36,12 +39,10 @@ try {
|
||||
die($e->getMessage());
|
||||
}
|
||||
|
||||
//dd($parameters['category_name']);
|
||||
|
||||
match ($parameters['_controller']) {
|
||||
SearchController::class => (new $parameters['_controller']())($parameters['search_term']),
|
||||
CategoryController::class => (new $parameters['_controller']())($parameters['category_name']),
|
||||
ProductController::class => (new $parameters['_controller']())($parameters['product_id']),
|
||||
ProductController::class, StarController::class => (new $parameters['_controller']())($parameters['product_id']),
|
||||
IndexController::class => (new $parameters['_controller']())(),
|
||||
default => throw new Exception('Route not found')
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user