<?php

namespace AutoAdmin\Bundle\Admin\Controller\Admin;

use AutoAdmin\Bundle\Cache\Service\CacheService;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Contracts\Service\Attribute\Required;

class CacheRuleController extends EntityController
{
    private CacheService $cacheService;

    #[Required]
    public function setCacheService(CacheService $service): void
    {
        $this->cacheService = $service;
    }

    public function cacheClear(Request $request): RedirectResponse
    {
        $this->cacheService->clearCachedResponse();

        return $this->redirect($request->headers->get('referer'));
    }
}
