Use MicroKernelTrait to bootstrap application. Rewrote routes, controllers and structure of application a bit. Including use of twig.
This commit is contained in:
@@ -3,12 +3,16 @@
|
||||
namespace Krzysiej\RyobiCrawler\Controller;
|
||||
|
||||
use Krzysiej\RyobiCrawler\Models\Product;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
final class StarController extends BaseController
|
||||
{
|
||||
public function __invoke(int $productId): void
|
||||
#[Route('/star/{productId<\d+>}', name: 'app_star')]
|
||||
public function __invoke(int $productId, Request $request): Response
|
||||
{
|
||||
Product::find($productId)->toggleStarred()->save();
|
||||
header('Location: ' . $_SERVER['HTTP_REFERER']);
|
||||
return $this->redirect($request->headers->get('referer'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user