Skip to content

Commit

Permalink
Merge pull request #3323 from acrobat/switch-route-validator-to-attri…
Browse files Browse the repository at this point in the history
…butes

[AllBundles] Switch Route and Validator annotations to attributes
  • Loading branch information
acrobat authored Dec 20, 2023
2 parents d4d27f1 + f9ab024 commit 8079d25
Show file tree
Hide file tree
Showing 84 changed files with 258 additions and 749 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ public function __construct(UserManager $userManager)
$this->userManager = $userManager;
}

/**
* @Route("/change-password", name="kunstmaan_admin_forced_change_password", methods={"GET", "POST"})
*/
#[Route(path: '/change-password', name: 'kunstmaan_admin_forced_change_password', methods: ['GET', 'POST'])]
public function formAction(Request $request): Response
{
$user = $this->getUser();
Expand All @@ -45,9 +43,7 @@ public function formAction(Request $request): Response
]);
}

/**
* @Route("/change-password/success", name="kunstmaan_admin_forced_change_password_success", methods={"GET"})
*/
#[Route(path: '/change-password/success', name: 'kunstmaan_admin_forced_change_password_success', methods: ['GET'])]
public function successAction(): Response
{
return $this->render('@KunstmaanAdmin/authentication/forced_change_password/success.html.twig', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ public function __construct(PasswordResetService $passwordResetService, UserMana
$this->userManager = $userManager;
}

/**
* @Route("/password-reset/request", name="kunstmaan_admin_reset_password", methods={"GET", "POST"})
*/
#[Route(path: '/password-reset/request', name: 'kunstmaan_admin_reset_password', methods: ['GET', 'POST'])]
public function requestAction(Request $request)
{
$form = $this->createForm(PasswordRequestType::class);
Expand All @@ -49,9 +47,7 @@ public function requestAction(Request $request)
return $this->render('@KunstmaanAdmin/authentication/password_reset/request.html.twig', ['form' => $form->createView()]);
}

/**
* @Route("/password-reset/confirm/{token}", name="kunstmaan_admin_reset_password_confirm", methods={"GET", "POST"})
*/
#[Route(path: '/password-reset/confirm/{token}', name: 'kunstmaan_admin_reset_password_confirm', methods: ['GET', 'POST'])]
public function confirmAction(Request $request, string $token)
{
/** @var UserInterface|null $user */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ public function __construct(AuthenticationUtils $authenticationUtils, Environmen
$this->twig = $twig;
}

/**
* @Route("/login", name="kunstmaan_admin_login", methods={"GET", "POST"})
*/
#[Route(path: '/login', name: 'kunstmaan_admin_login', methods: ['GET', 'POST'])]
public function loginAction()
{
$error = $this->authenticationUtils->getLastAuthenticationError();
Expand All @@ -34,9 +32,7 @@ public function loginAction()
]));
}

/**
* @Route("/logout", name="kunstmaan_admin_logout")
*/
#[Route(path: '/logout', name: 'kunstmaan_admin_logout')]
public function logoutAction()
{
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
Expand Down
6 changes: 2 additions & 4 deletions src/Kunstmaan/AdminBundle/Controller/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ public function __construct(ParameterBagInterface $parameterBag, ManagerRegistry

/**
* The index action will render the main screen the users see when they log in in to the admin
*
* @Route("/", name="KunstmaanAdminBundle_homepage")
*/
#[Route(path: '/', name: 'KunstmaanAdminBundle_homepage')]
public function indexAction(): Response
{
if ($this->parameterBag->has('kunstmaan_admin.dashboard_route')) {
Expand All @@ -56,9 +55,8 @@ public function indexAction(): Response

/**
* The admin of the index page
*
* @Route("/adminindex", name="KunstmaanAdminBundle_homepage_admin")
*/
#[Route(path: '/adminindex', name: 'KunstmaanAdminBundle_homepage_admin')]
public function editIndexAction(Request $request): Response
{
/* @var $em EntityManager */
Expand Down
18 changes: 3 additions & 15 deletions src/Kunstmaan/AdminBundle/Controller/ExceptionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,16 @@ private function getAdminListConfigurator()
return $this->configurator;
}

/**
* @Route("/", name="kunstmaanadminbundle_admin_exception")
*/
#[Route(path: '/', name: 'kunstmaanadminbundle_admin_exception')]
public function indexAction(Request $request)
{
return parent::doIndexAction($this->getAdminListConfigurator(), $request);
}

/**
* @Route("/resolve_all", name="kunstmaanadminbundle_admin_exception_resolve_all", methods={"POST"})
*
* @return RedirectResponse
*
* @throws \Doctrine\ORM\NonUniqueResultException
* @throws \Doctrine\ORM\NoResultException
* @throws \InvalidArgumentException
*/
#[Route(path: '/resolve_all', name: 'kunstmaanadminbundle_admin_exception_resolve_all', methods: ['POST'])]
public function resolveAllAction(Request $request)
{
if (!$this->isCsrfTokenValid('exception-resolve_all', $request->request->get('token'))) {
Expand All @@ -60,14 +53,9 @@ public function resolveAllAction(Request $request)
}

/**
* @Route("/toggle_resolve/{id}", name="kunstmaanadminbundle_admin_exception_toggle_resolve", methods={"POST"})
*
* @return RedirectResponse
*
* @throws \Doctrine\ORM\OptimisticLockException
* @throws \InvalidArgumentException
* @throws \Doctrine\ORM\ORMInvalidArgumentException
*/
#[Route(path: '/toggle_resolve/{id}', name: 'kunstmaanadminbundle_admin_exception_toggle_resolve', methods: ['POST'])]
public function toggleResolveAction(Request $request, Exception $model)
{
if (!$this->isCsrfTokenValid('exception-resolve-item', $request->request->get('token'))) {
Expand Down
4 changes: 1 addition & 3 deletions src/Kunstmaan/AdminBundle/Controller/ModulesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

final class ModulesController extends AbstractController
{
/**
* @Route("/", name="KunstmaanAdminBundle_modules")
*/
#[Route(path: '/', name: 'KunstmaanAdminBundle_modules')]
public function indexAction(): Response
{
return $this->render('@KunstmaanAdmin/Modules/index.html.twig');
Expand Down
17 changes: 2 additions & 15 deletions src/Kunstmaan/AdminBundle/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;

final class SettingsController extends AbstractController
{
Expand All @@ -22,27 +21,15 @@ public function __construct(VersionChecker $versionChecker, LoggerInterface $log
$this->logger = $logger;
}

/**
* Index page for the settings
*
* @Route("/", name="KunstmaanAdminBundle_settings")
*
* @throws AccessDeniedException
*/
#[Route(path: '/', name: 'KunstmaanAdminBundle_settings')]
public function indexAction(): Response
{
$this->denyAccessUnlessGranted('ROLE_ADMIN');

return $this->render('@KunstmaanAdmin/Settings/index.html.twig');
}

/**
* Show bundles version update information
*
* @Route("/bundle-version", name="KunstmaanAdminBundle_settings_bundle_version")
*
* @throws AccessDeniedException
*/
#[Route(path: '/bundle-version', name: 'KunstmaanAdminBundle_settings_bundle_version')]
public function bundleVersionAction(): Response
{
$this->denyAccessUnlessGranted('ROLE_SUPER_ADMIN');
Expand Down
2 changes: 1 addition & 1 deletion src/Kunstmaan/AdminBundle/Entity/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
* @ORM\Index(name="idx_exception_is_resolved", columns={"is_resolved"})
* }
* )
* @UniqueEntity("hash")
* @ORM\HasLifecycleCallbacks()
*/
#[ORM\Entity(repositoryClass: ExceptionRepository::class)]
#[ORM\Table(name: 'kuma_exception')]
#[ORM\Index(name: 'idx_exception_is_resolved', columns: ['is_resolved'])]
#[UniqueEntity('hash')]
#[ORM\HasLifecycleCallbacks]
#[UniqueEntity('hash')]
class Exception extends AbstractEntity
{
/**
Expand Down
6 changes: 2 additions & 4 deletions src/Kunstmaan/AdminBundle/Entity/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ class Group implements GroupInterface
protected $id;

/**
* @Assert\NotBlank()
* @ORM\Column(type="string")
*/
#[ORM\Column(name: 'name', type: 'string')]
#[Assert\NotBlank]
protected $name;

/**
Expand Down Expand Up @@ -226,9 +226,7 @@ public function setName($name)
return $this;
}

/**
* @Assert\Callback()
*/
#[Assert\Callback]
public function isGroupValid(ExecutionContextInterface $context)
{
if (!(\count($this->getRoles()) > 0)) {
Expand Down
3 changes: 1 addition & 2 deletions src/Kunstmaan/AdminBundle/Entity/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
/**
* @ORM\Entity
* @ORM\Table( name="kuma_roles" )
* @UniqueEntity("role")
*/
#[ORM\Entity]
#[ORM\Table(name: 'kuma_roles')]
Expand All @@ -27,10 +26,10 @@ class Role
protected $id;

/**
* @Assert\NotBlank()
* @ORM\Column(type="string", name="role", unique=true, length=70)
*/
#[ORM\Column(name: 'role', type: 'string', unique: true, length: 70)]
#[Assert\NotBlank]
protected $role;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,9 @@ protected function getEntityManager()
}

/**
* @Route(
* "check/{id}/{repository}",
* requirements={"id" = "\d+"},
* name="KunstmaanAdminListBundle_entity_lock_check"
* )
*
* @return JsonResponse
*/
#[Route(path: 'check/{id}/{repository}', requirements: ['id' => '\d+'], name: 'KunstmaanAdminListBundle_entity_lock_check')]
public function checkAction(Request $request, $id, $repository)
{
$entityIsLocked = false;
Expand Down
6 changes: 1 addition & 5 deletions src/Kunstmaan/ArticleBundle/Entity/AbstractCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ abstract class AbstractCategory extends AbstractEntity implements Translatable
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
* @Assert\NotBlank()
* @Gedmo\Translatable
*/
#[ORM\Column(name: 'name', type: 'string', length: 255)]
#[Gedmo\Translatable]
#[Assert\NotBlank]
protected $name;

/**
Expand All @@ -36,8 +36,6 @@ abstract class AbstractCategory extends AbstractEntity implements Translatable
protected $deletedAt;

/**
* Set name
*
* @param string $name
*/
public function setName($name)
Expand All @@ -46,8 +44,6 @@ public function setName($name)
}

/**
* Get name
*
* @return string
*/
public function getName()
Expand Down
6 changes: 1 addition & 5 deletions src/Kunstmaan/ArticleBundle/Entity/AbstractTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ abstract class AbstractTag extends AbstractEntity implements Translatable
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
* @Assert\NotBlank()
* @Gedmo\Translatable
*/
#[ORM\Column(name: 'name', type: 'string', length: 255)]
#[Gedmo\Translatable]
#[Assert\NotBlank]
protected $name;

/**
Expand All @@ -36,8 +36,6 @@ abstract class AbstractTag extends AbstractEntity implements Translatable
protected $deletedAt;

/**
* Set name
*
* @param string $name
*/
public function setName($name)
Expand All @@ -46,8 +44,6 @@ public function setName($name)
}

/**
* Get name
*
* @return string
*/
public function getName()
Expand Down
6 changes: 2 additions & 4 deletions src/Kunstmaan/CacheBundle/Controller/VarnishController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ public function __construct(VarnishHelper $varnishHelper)

/**
* Generates the varnish ban form.
*
* @Route("/settings/varnish", name="kunstmaancachebundle_varnish_settings_ban")
*/
#[Route(path: '/settings/varnish', name: 'kunstmaancachebundle_varnish_settings_ban')]
public function indexAction(Request $request): Response
{
$this->checkPermission();
Expand All @@ -54,10 +53,9 @@ public function indexAction(Request $request): Response
/**
* Ban route from varnish
*
* @Route("/varnish/ban/{node}", name="kunstmaancachebundle_varnish_ban")
*
* @return RedirectResponse
*/
#[Route(path: '/varnish/ban/{node}', name: 'kunstmaancachebundle_varnish_ban')]
public function banAction(Node $node)
{
$this->checkPermission();
Expand Down
Loading

0 comments on commit 8079d25

Please sign in to comment.