diff --git a/config/listeners.yml b/config/listeners.yml index b1228b0..e79a770 100644 --- a/config/listeners.yml +++ b/config/listeners.yml @@ -24,7 +24,6 @@ services: Terminal42\PasswordValidationBundle\EventListener\RedirectToPasswordChangePageListener: arguments: - - '@contao.framework' - '@security.token_storage' - '@contao.routing.scope_matcher' tags: diff --git a/src/EventListener/RedirectToPasswordChangePageListener.php b/src/EventListener/RedirectToPasswordChangePageListener.php index 499bcb3..451b835 100644 --- a/src/EventListener/RedirectToPasswordChangePageListener.php +++ b/src/EventListener/RedirectToPasswordChangePageListener.php @@ -6,7 +6,6 @@ namespace Terminal42\PasswordValidationBundle\EventListener; use Contao\CoreBundle\Exception\PageNotFoundException; use Contao\CoreBundle\Exception\RedirectResponseException; -use Contao\CoreBundle\Framework\ContaoFramework; use Contao\CoreBundle\Routing\ScopeMatcher; use Contao\FrontendUser; use Contao\PageModel; @@ -16,7 +15,6 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInt final readonly class RedirectToPasswordChangePageListener { public function __construct( - private ContaoFramework $framework, private TokenStorageInterface $tokenStorage, private ScopeMatcher $scopeMatcher, ) { @@ -36,12 +34,10 @@ final readonly class RedirectToPasswordChangePageListener return; } - /** @var PageModel $adapter */ - $adapter = $this->framework->getAdapter(PageModel::class); - $rootPage = $adapter->findById($page->rootId); + $rootPage = PageModel::findById($page->rootId); // Search for password-change page - $pwChangePage = $adapter->findPublishedById($rootPage->pwChangePage ?? 0); + $pwChangePage = PageModel::findPublishedById($rootPage->pwChangePage ?? 0); if (!$pwChangePage instanceof PageModel) { throw new PageNotFoundException('No password-change page found.'); diff --git a/src/Validation/ValidationConfiguration.php b/src/Validation/ValidationConfiguration.php index 61fb774..f15dd60 100644 --- a/src/Validation/ValidationConfiguration.php +++ b/src/Validation/ValidationConfiguration.php @@ -20,7 +20,7 @@ final class ValidationConfiguration /** * @var array> Configuration parameters in the format [Contao\FrontendUser => [ min_chars => 8, max_chars => 20 ]] */ - private $configurations = []; + private array $configurations = []; public function addConfiguration(string $entityName, array $configuration): void { @@ -34,6 +34,6 @@ final class ValidationConfiguration public function getConfiguration(string $entityName): array|null { - return $this->configurations[$entityName]; + return $this->configurations[$entityName] ?? null; } }