diff --git a/.github/workflows/ci-4.x.yml b/.github/workflows/ci-4.x.yml index f78d921b..52c9800d 100644 --- a/.github/workflows/ci-4.x.yml +++ b/.github/workflows/ci-4.x.yml @@ -29,9 +29,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 - with: - ref: 4.x + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/.github/workflows/ci-5.x.yml b/.github/workflows/ci-5.x.yml index 5b8093db..c925acfa 100644 --- a/.github/workflows/ci-5.x.yml +++ b/.github/workflows/ci-5.x.yml @@ -18,9 +18,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 - with: - ref: 5.x + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -57,9 +55,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 - with: - ref: 5.x + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -130,9 +126,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 - with: - ref: 5.x + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/src/Controller/ViewerController.php b/src/Controller/ViewerController.php index 0ad0755d..85d7a3f1 100644 --- a/src/Controller/ViewerController.php +++ b/src/Controller/ViewerController.php @@ -10,19 +10,21 @@ use DH\Auditor\Provider\Doctrine\Persistence\Schema\SchemaManager; use DH\Auditor\Provider\Doctrine\Service\AuditingService; use DH\AuditorBundle\Helper\UrlHelper; -use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Security\Core\Exception\AccessDeniedException as SymfonyAccessDeniedException; +use Twig\Environment; /** * @see \DH\AuditorBundle\Tests\Controller\ViewerControllerTest */ -class ViewerController extends AbstractController +class ViewerController { private $environment; - public function __construct(\Twig\Environment $environment) + public function __construct(Environment $environment) { $this->environment = $environment; } @@ -53,7 +55,7 @@ static function ($entity) use ($reader, $scope) { ); } - return $this->render('@DHAuditor/Audit/audits.html.twig', [ + return $this->renderView('@DHAuditor/Audit/audits.html.twig', [ 'audited' => $audited, 'reader' => $reader, ]); @@ -66,7 +68,7 @@ public function showTransactionAction(Reader $reader, string $hash): Response { $audits = $reader->getAuditsByTransactionHash($hash); - return $this->render('@DHAuditor/Audit/transaction.html.twig', [ + return $this->renderView('@DHAuditor/Audit/transaction.html.twig', [ 'hash' => $hash, 'audits' => $audits, ]); @@ -85,7 +87,7 @@ public function showEntityHistoryAction(Request $request, Reader $reader, string $entity = UrlHelper::paramToNamespace($entity); if (!$reader->getProvider()->isAuditable($entity)) { - throw $this->createNotFoundException(); + throw new NotFoundHttpException('Not Found'); } try { @@ -95,18 +97,18 @@ public function showEntityHistoryAction(Request $request, Reader $reader, string 'page_size' => Reader::PAGE_SIZE, ]), $page, Reader::PAGE_SIZE); } catch (AccessDeniedException $e) { - throw $this->createAccessDeniedException(); + throw new SymfonyAccessDeniedException('Access Denied.'); } - return $this->render('@DHAuditor/Audit/entity_history.html.twig', [ + return $this->renderView('@DHAuditor/Audit/entity_history.html.twig', [ 'id' => $id, 'entity' => $entity, 'paginator' => $pager, ]); } - protected function renderView(string $view, array $parameters = []): string + protected function renderView(string $view, array $parameters = []): Response { - return $this->environment->render($view, $parameters); + return new Response($this->environment->render($view, $parameters)); } } diff --git a/src/Resources/config/services.yaml b/src/Resources/config/services.yaml index 3198d075..73bedbf3 100644 --- a/src/Resources/config/services.yaml +++ b/src/Resources/config/services.yaml @@ -67,8 +67,6 @@ services: # Bundle related services DH\AuditorBundle\Controller\ViewerController: arguments: ['@twig'] - calls: - - { method: setContainer, arguments: ['@service_container'] } tags: ['controller.service_arguments'] DH\AuditorBundle\User\UserProvider: