Skip to content

Commit 480dc95

Browse files
committed
Allow support for Symfony 8
1 parent 8dac0aa commit 480dc95

3 files changed

Lines changed: 38 additions & 7 deletions

File tree

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
"require": {
2323
"php": "^8.2",
2424
"rollerworks/password-strength-validator": "^2.0",
25-
"symfony/framework-bundle": "^6.0 || ^7.0"
25+
"symfony/framework-bundle": "^6.4 || ^7.0 || ^8.0"
2626
},
2727
"require-dev": {
28-
"matthiasnoback/symfony-dependency-injection-test": "^4.3.1 || ^5.0",
29-
"phpunit/phpunit": "^9.5",
28+
"matthiasnoback/symfony-dependency-injection-test": "^4.3.1 || ^5.0 || ^6.2",
29+
"phpunit/phpunit": "^9.5 || ^10.0",
3030
"rollerscapes/standards": "^1.0",
31-
"symfony/phpunit-bridge": "^7.4"
31+
"symfony/phpunit-bridge": "^7.4 || ^8.0"
3232
},
3333
"minimum-stability": "dev",
3434
"prefer-stable": true,

src/DependencyInjection/RollerworksPasswordStrengthExtension.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@
1616
use Symfony\Component\DependencyInjection\ContainerBuilder;
1717
use Symfony\Component\DependencyInjection\Extension\Extension;
1818
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
19-
use Symfony\Component\DependencyInjection\Loader;
19+
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
20+
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
2021

2122
final class RollerworksPasswordStrengthExtension extends Extension implements PrependExtensionInterface
2223
{
2324
public function load(array $configs, ContainerBuilder $container): void
2425
{
25-
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
26-
$loader->load('strength_validator.xml');
26+
if (class_exists(XmlFileLoader::class)) {
27+
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
28+
$loader->load('strength_validator.xml');
29+
} else {
30+
$loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
31+
$loader->load('strength_validator.php');
32+
}
2733
}
2834

2935
public function prepend(ContainerBuilder $container): void
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the RollerworksPasswordStrengthBundle package.
7+
*
8+
* (c) Sebastiaan Stok <s.stok@rollerscapes.net>
9+
*
10+
* This source file is subject to the MIT license that is bundled
11+
* with this source code in the file LICENSE.
12+
*/
13+
14+
use Rollerworks\Component\PasswordStrength\Validator\Constraints\PasswordStrengthValidator;
15+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
16+
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
17+
18+
return static function (ContainerConfigurator $container): void {
19+
$di = $container->services();
20+
21+
$di->set(PasswordStrengthValidator::class)
22+
->args([service('translator')->nullOnInvalid()])
23+
->tag('validator.constraint_validator');
24+
};
25+

0 commit comments

Comments
 (0)