Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
"minimum-stability": "dev",
"require": {
"php": ">=8.1.10",
"symfony/config": "^5.4 | ^6.0 | ^7.0",
"symfony/dependency-injection": "^5.4 | ^6.0 | ^7.0",
"symfony/config": "^5.4 | ^6.0 | ^7.0 | ^8.0",
"symfony/dependency-injection": "^5.4 | ^6.0 | ^7.0 | ^8.0",
"symfony/deprecation-contracts": "^2.2 | ^3.0",
"symfony/http-kernel": "^5.4 | ^6.0 | ^7.0"
"symfony/http-kernel": "^5.4 | ^6.0 | ^7.0 | ^8.0"
},
"require-dev": {
"doctrine/orm": "^2.13",
"symfony/framework-bundle": "^5.4 | ^6.0 | ^7.0",
"symfony/phpunit-bridge": "^5.4 | ^6.0 | ^7.0",
"symfony/framework-bundle": "^5.4 | ^6.0 | ^7.0 | ^8.0",
"symfony/phpunit-bridge": "^5.4 | ^6.0 | ^7.0 | ^8.0",
"doctrine/doctrine-bundle": "^2.8",
"doctrine/annotations": "^1.0",
"symfony/process": "^6.4 | ^7.0 | ^7.1",
"symfony/process": "^6.4 | ^7.0 | ^8.0",
"symfonycasts/internal-test-helpers": "dev-main"
},
"autoload": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\DependencyInjection\Reference;

/**
Expand All @@ -23,8 +23,8 @@ final class SymfonyCastsResetPasswordExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new XmlFileLoader($container, new FileLocator(\dirname(__DIR__).'/Resources/config'));
$loader->load('reset_password_services.xml');
$loader = new PhpFileLoader($container, new FileLocator(\dirname(__DIR__).'/Resources/config'));
$loader->load('reset_password_services.php');

$configuration = $this->getConfiguration($configs, $container);
if (!$configuration) {
Expand Down
58 changes: 58 additions & 0 deletions src/Resources/config/reset_password_services.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/*
* This file is part of the SymfonyCasts ResetPasswordBundle package.
* Copyright (c) SymfonyCasts <https://symfonycasts.com/>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use SymfonyCasts\Bundle\ResetPassword\Command\ResetPasswordRemoveExpiredCommand;
use SymfonyCasts\Bundle\ResetPassword\Generator\ResetPasswordRandomGenerator;
use SymfonyCasts\Bundle\ResetPassword\Generator\ResetPasswordTokenGenerator;
use SymfonyCasts\Bundle\ResetPassword\Persistence\Fake\FakeResetPasswordInternalRepository;
use SymfonyCasts\Bundle\ResetPassword\ResetPasswordHelper;
use SymfonyCasts\Bundle\ResetPassword\ResetPasswordHelperInterface;
use SymfonyCasts\Bundle\ResetPassword\Util\ResetPasswordCleaner;

return static function (ContainerConfigurator $container) {
$services = $container->services();
$parameters = $container->parameters();

$services->set('symfonycasts.reset_password.fake_request_repository', FakeResetPasswordInternalRepository::class)
->private();

$services->set('symfonycasts.reset_password.cleaner', ResetPasswordCleaner::class)
->private()
->args([
'', // reset password request persister
'', // reset password request enable_garbage_collection
]);

$services->set(ResetPasswordRemoveExpiredCommand::class)
->args([service('symfonycasts.reset_password.cleaner')])
->tag('console.command', ['command' => 'reset-password:remove-expired']);

$services->set('symfonycasts.reset_password.random_generator', ResetPasswordRandomGenerator::class)
->private();

$services->set('symfonycasts.reset_password.token_generator', ResetPasswordTokenGenerator::class)
->private()
->args([
'%kernel.secret%',
service('symfonycasts.reset_password.random_generator'),
]);

$services->alias(ResetPasswordHelperInterface::class, 'symfonycasts.reset_password.helper');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the arguments be swapped for it? like:

Suggested change
$services->alias(ResetPasswordHelperInterface::class, 'symfonycasts.reset_password.helper');
$services->alias('symfonycasts.reset_password.helper', ResetPasswordHelperInterface::class);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, it should be correct


$services->set('symfonycasts.reset_password.helper', ResetPasswordHelper::class)
->args([
service('symfonycasts.reset_password.token_generator'),
service('symfonycasts.reset_password.cleaner'),
'', // reset password request persister
'', // reset password request lifetime
'', // reset password throttle limit
]);
};
35 changes: 0 additions & 35 deletions src/Resources/config/reset_password_services.xml

This file was deleted.

1 change: 1 addition & 0 deletions tests/Fixtures/App/.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ APP_SECRET=7e6cd3398232b047dc249e51729039fa
DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
MAILER_DSN=null://null
DEFAULT_URI=http://localhost