<?php

namespace Formatrica\Registration;

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

use Formatrica\Setup\Service_Locator;
use Formatrica\Setup\Service_Provider;

final class Registration_Service_Provider implements Service_Provider
{
    public function register(Service_Locator $services): void
    {
        $verification = new Email_Verification_Controller();
        add_action('init', [$verification, 'maybe_handle_verify_request']);

        $guard = new Auth_Guard();
        add_filter('authenticate', [$guard, 'block_unverified_login'], 30, 3);

        $login_messages = new Login_Messages();
        add_filter('login_message', [$login_messages, 'add_login_message']);

        $services->set(Email_Verification_Controller::class, $verification);
        $services->set(Auth_Guard::class, $guard);
        $services->set(Login_Messages::class, $login_messages);
    }
}
