Skip to content

Releases: sumocoders/Framework-User-Implementation-Example

v9.1.2

22 Oct 10:06
407c83e

Choose a tag to compare

What's Changed

Full Changelog: v9.1.1...v9.1.2

v9.1.1

14 Oct 12:59
d7a2dc7

Choose a tag to compare

What's Changed

Full Changelog: v9.1.0...v9.1.1

v9.1.0

09 Oct 13:40
d034738

Choose a tag to compare

What's Changed

Full Changelog: v9.0.1...v9.1.0

v9.0.1

04 Oct 11:49
c74e84b

Choose a tag to compare

What's Changed

Full Changelog: v9.0.0...v9.0.1

v9.0.0

13 Sep 07:35
aa8dec7

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v8.0.1...v9.0.0

v8.0.1

10 Sep 14:48
9b48e9f

Choose a tag to compare

What's Changed

Full Changelog: V8.0.0...v8.0.1

V8.0.0

10 Sep 13:11
b77547f

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v7.0...V8.0.0

v7.0

04 Jan 12:33
e4352f1

Choose a tag to compare

Changes

Logout no longer needs a controller

Symfony 6.4 and up no longer need a controller and route for logout functionality. Use the following config in the security.yaml file to enable the logout

firewalls:
    main:
        logout:
            path: app_logout
            # target: app_any_route

Do make sure the routes/security.yaml file isn't empty

_security_logout:
  resource: security.route_loader.logout
  type: service

Map $_GET params using #[MapQueryParameters]

GET params no longer need to be got from the query parameters in request. Just add the MapQueryParameter attribute to the controller action parameter to populate it dynamically

    #[Route('/admin/users')]
    #[Breadcrumb('users')]
    public function __invoke(
        Request $request,
        UserRepository $userRepository,
    ): Response {
        $page = $request->query->getInt('page', 1);

        $form = $this->createForm(FilterType::class, new FilterDataTransferObject() );
        $form->handleRequest($request);

        $paginatedUsers = $userRepository->getAllFilteredUsers($form->getData());
        $paginatedUsers->paginate($page);

        return $this->render('user/admin/overview.html.twig', [
            'form' => $form->createView(),
            'users' => $paginatedUsers,
        ]);
    }

becomes

    #[Route('/admin/users')]
    #[Breadcrumb('users')]
    public function __invoke(
        Request $request,
        UserRepository $userRepository,
        #[MapQueryParameter] ?int $page = 1
    ): Response {
        $form = $this->createForm(FilterType::class, new FilterDataTransferObject() );
        $form->handleRequest($request);

        $paginatedUsers = $userRepository->getAllFilteredUsers($form->getData());
        $paginatedUsers->paginate($page);

        return $this->render('user/admin/overview.html.twig', [
            'form' => $form->createView(),
            'users' => $paginatedUsers,
        ]);
    }

Impersonating users

When impersonating users we no longer need to manually need to define magic get properties in the path. We kan now use the build in twig methods to generate te correct links

Impersonate

<a class="text-nowrap" href="{{ path('profile', {'_switch_user': user.username}) }}">
  <i class="fas fa-sign-in-alt" title="{{ 'Switch to user'|trans }}" data-toggle="tooltip" data-placement="top"></i>
</a>

becomes

<a class="text-nowrap" href="{{ impersonation_path(user.username) }}">
  <i class="fas fa-sign-in-alt" title="{{ 'Switch to user'|trans }}" data-toggle="tooltip" data-placement="top"></i>
</a>

Exit impersonation

<a href="{{ path('user_overview', {'_switch_user': '_exit'}) }}">{{ 'user.actions.switchback'|trans|ucfirst }}</a>

becomes

<a href="{{ impersonation_exit_path(path('user_overview')) }}" class="dropdown-item">{{'user.actions.switchback'|trans|ucfirst }}</a>

Routes can be accessed by their FQCN

Routes no longer need to define a name to be accessed bij the router. When no name is provided a generated name based on the FQCN is used.

For example the App\Controller\User\Admin\OverviewController file would us the path name user_overview since it's defined

#[Route('/admin/users', name: 'user_overview')]
#[Breadcrumb('users')]
public function __invoke(
    Request $request,
    UserRepository $userRepository,
    #[MapQueryParameter]
    ?int $page = 1
): Response ...

If the name isn't defined it would be app_user_admin_overview

#[Route('/admin/users')]
#[Breadcrumb('users')]
public function __invoke(
    Request $request,
    UserRepository $userRepository,
    #[MapQueryParameter]
    ?int $page = 1
): Response ...

In both cases the FQCN can be used in the router to point at the correct path

return $this->redirectToRoute(OverviewController::class);

if a specific method needs to be called this can be added as well

return $this->redirectToRoute(OverviewController::class.'::index');

New Contributors

Full Changelog: https://github.com/sumocoders/Framework-User-Implementation-Example/commits/v7.0