Skip to content

Commit

Permalink
Add PHP routing files
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Dec 15, 2021
1 parent 57c760f commit ba5f8d7
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 27 deletions.
2 changes: 1 addition & 1 deletion docs/deletion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ Add the routing config:
# config/routes/nucleos_user.yaml
nucleos_user_deletion:
resource: "@NucleosUserBundle/Resources/config/routing/deletion.xml"
resource: "@NucleosUserBundle/Resources/config/routing/deletion.php"
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ The following documents are available:
doctrine
canonicalizer
custom_storage_layer
routing
security
deletion
configuration_reference
Expand Down
16 changes: 14 additions & 2 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,20 @@ logging in, creating users, etc.
.. code-block:: yaml
# config/routes/nucleos_user.yaml
nucleos_user:
resource: "@NucleosUserBundle/Resources/config/routing/all.xml"
nucleos_user_security:
resource: "@NucleosUserBundle/Resources/config/routing/security.php"
nucleos_user_resetting:
resource: "@NucleosUserBundle/Resources/config/routing/resetting.php"
prefix: /resetting
nucleos_user_change_password:
resource: "@NucleosUserBundle/Resources/config/routing/change_password.php"
prefix: /security
nucleos_user_deletion:
resource: "@NucleosUserBundle/Resources/config/routing/deletion.php"
prefix: /deletetion
Step 7: Update your database schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
22 changes: 0 additions & 22 deletions docs/routing.rst

This file was deleted.

23 changes: 23 additions & 0 deletions src/Resources/config/routing/change_password.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

/*
* This file is part of the NucleosUserBundle package.
*
* (c) Christian Gripp <mail@core23.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Routing\Loader\Configurator;

use Nucleos\UserBundle\Action\ChangePasswordAction;

return static function (RoutingConfigurator $routes): void {
$routes->add('nucleos_user_change_password', '/change-password')
->controller(ChangePasswordAction::class)
->methods(['GET', 'POST'])
;
};
23 changes: 23 additions & 0 deletions src/Resources/config/routing/deletion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

/*
* This file is part of the NucleosUserBundle package.
*
* (c) Christian Gripp <mail@core23.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Routing\Loader\Configurator;

use Nucleos\UserBundle\Action\AccountDeletionAction;

return static function (RoutingConfigurator $routes): void {
$routes->add('nucleos_user_delete_account', '/delete')
->controller(AccountDeletionAction::class)
->methods(['GET', 'POST'])
;
};
51 changes: 51 additions & 0 deletions src/Resources/config/routing/resetting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

declare(strict_types=1);

/*
* This file is part of the NucleosUserBundle package.
*
* (c) Christian Gripp <mail@core23.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Routing\Loader\Configurator;

use Nucleos\UserBundle\Action\CheckEmailAction;
use Nucleos\UserBundle\Action\RequestResetAction;
use Nucleos\UserBundle\Action\ResetAction;
use Nucleos\UserBundle\Action\SendEmailAction;
use Symfony\Bundle\FrameworkBundle\Controller\RedirectController;

return static function (RoutingConfigurator $routes): void {
$routes->add('nucleos_user_resetting_request', '/request')
->controller(RequestResetAction::class)
->methods(['GET'])
;

$routes->add('nucleos_user_resetting_send_email', '/send-email')
->controller(SendEmailAction::class)
->methods(['POST'])
;

$routes->add('nucleos_user_resetting_check_email', '/check-email')
->controller(CheckEmailAction::class)
->methods(['GET'])
;

$routes->add('nucleos_user_resetting_reset', '/reset/{token}')
->controller(ResetAction::class)
->methods(['GET', 'POST'])
;

$routes->add('nucleos_user_resetting', '/')
->controller(RedirectController::class)
->methods(['GET'])
->defaults([
'route' => 'nucleos_user_resetting_request',
'permanent' => true,
])
;
};
41 changes: 41 additions & 0 deletions src/Resources/config/routing/security.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

/*
* This file is part of the NucleosUserBundle package.
*
* (c) Christian Gripp <mail@core23.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Routing\Loader\Configurator;

use Nucleos\UserBundle\Action\CheckLoginAction;
use Nucleos\UserBundle\Action\LoggedinAction;
use Nucleos\UserBundle\Action\LoginAction;
use Nucleos\UserBundle\Action\LogoutAction;

return static function (RoutingConfigurator $routes): void {
$routes->add('nucleos_user_security_login', '/login')
->controller(LoginAction::class)
->methods(['GET', 'POST'])
;

$routes->add('nucleos_user_security_check', '/login_check')
->controller(CheckLoginAction::class)
->methods(['POST'])
;

$routes->add('nucleos_user_security_loggedin', '/loggedin')
->controller(LoggedinAction::class)
->methods(['GET', 'POST'])
;

$routes->add('nucleos_user_security_logout', '/logout')
->controller(LogoutAction::class)
->methods(['GET', 'POST'])
;
};
5 changes: 4 additions & 1 deletion tests/App/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ public function getProjectDir(): string

protected function configureRoutes(RouteCollectionBuilder $routes): void
{
$routes->import(__DIR__.'/../../src/Resources/config/routing/all.xml');
$routes->import(__DIR__.'/../../src/Resources/config/routing/security.php');
$routes->import(__DIR__.'/../../src/Resources/config/routing/change_password.php');
$routes->import(__DIR__.'/../../src/Resources/config/routing/resetting.php', '/resetting');
$routes->import(__DIR__.'/../../src/Resources/config/routing/deletion.php');
}

protected function configureContainer(ContainerBuilder $containerBuilder, LoaderInterface $loader): void
Expand Down

0 comments on commit ba5f8d7

Please sign in to comment.