Skip to content

Commit 92cadd6

Browse files
authored
Use Route attributes for controller (#70)
* Use Route attributes for controller Switch to using Route attributes for the auth controller, and move the SshCommand's name to a constructor controller instead of the defaultName value. Drop testing on PHP 7.4. Bug: T361554 * Symfony version number * use tabs * Reset indenting
1 parent 4128802 commit 92cadd6

5 files changed

Lines changed: 8 additions & 11 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
strategy:
1515
matrix:
16-
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
16+
php: [ '8.0', '8.1', '8.2', '8.3' ]
1717

1818
runs-on: ubuntu-latest
1919

Command/SshCommand.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
class SshCommand extends Command
2020
{
2121

22-
/** @var string */
23-
protected static $defaultName = 'toolforge:ssh';
24-
2522
/** @var ReplicasClient */
2623
protected $client;
2724

@@ -38,7 +35,7 @@ class SshCommand extends Command
3835
public function __construct(ReplicasClient $client)
3936
{
4037
$this->client = $client;
41-
parent::__construct();
38+
parent::__construct('toolforge:ssh');
4239
}
4340

4441
/**

Controller/AuthController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
use Symfony\Component\HttpFoundation\RedirectResponse;
1010
use Symfony\Component\HttpFoundation\Request;
1111
use Symfony\Component\HttpFoundation\Session\Session;
12-
use Symfony\Component\Routing\Annotation\Route;
12+
use Symfony\Component\Routing\Attribute\Route;
1313
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1414

1515
class AuthController extends AbstractController
1616
{
1717

1818
/**
1919
* Redirect to Meta for Oauth authentication.
20-
* @Route("/login", name="toolforge_login")
2120
* @return RedirectResponse
2221
*/
22+
#[Route("/login", name:"toolforge_login")]
2323
public function loginAction(Request $request, Client $oauthClient, Session $session): RedirectResponse
2424
{
2525
// Automatically log in a development user if defined.
@@ -53,10 +53,10 @@ public function loginAction(Request $request, Client $oauthClient, Session $sess
5353

5454
/**
5555
* Receive authentication credentials back from the OAuth wiki.
56-
* @Route("/oauth_callback", name="toolforge_oauth_callback")
5756
* @param Request $request The HTTP request.
5857
* @return RedirectResponse
5958
*/
59+
#[Route("/oauth_callback", name:"toolforge_oauth_callback")]
6060
public function oauthCallbackAction(Request $request, Session $session, Client $client): RedirectResponse
6161
{
6262
// Give up if the required GET params or stored request token don't exist.
@@ -94,9 +94,9 @@ public function oauthCallbackAction(Request $request, Session $session, Client $
9494

9595
/**
9696
* Log out the user and return to the homepage.
97-
* @Route("/logout", name="toolforge_logout")
9897
* @return RedirectResponse
9998
*/
99+
#[Route("/logout", name:"toolforge_logout")]
100100
public function logoutAction(Session $session): RedirectResponse
101101
{
102102
$session->invalidate();

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Toolforge Bundle
22
================
33

4-
A Symfony 4/5 bundle that provides some common parts of web-based tools in Wikimedia Toolforge.
4+
A Symfony 5/6/7 bundle that provides some common parts of web-based tools in Wikimedia Toolforge.
55

66
Features:
77

Resources/config/routes.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
toolforge_oauth:
22
resource: "@ToolforgeBundle/Controller/"
3-
type: annotation
3+
type: attribute

0 commit comments

Comments
 (0)