HEX
Server: nginx
System: Linux pool195-106-36.bur.atomicsites.net 6.12.57+deb12-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.57-1~bpo12+1 (2025-11-17) x86_64
User: (0)
PHP: 8.3.32
Disabled: pcntl_fork
Upload Files
File: /wordpress/plugins/wp-cloud-client/beta/src/Access/SsoLoginReconciler.php
<?php

declare(strict_types=1);

namespace VPlugins\WPCloudClient\Access;

use WP_User;

/**
 * Shared skeleton for platform attributes reconciled on every WordPress login.
 *
 * The platform writes a desired state (role, super admin) to user meta via the
 * one_click_login action, and that state is reconciled onto the user on each
 * login. The wp_login registration and callback are identical across those
 * managers; only the reconciliation body differs. This base owns the shared
 * wiring so subclasses implement just their priority and their reconcile step —
 * a new SSO-driven attribute extends this instead of copying the skeleton again.
 */
abstract class SsoLoginReconciler {

	/**
	 * The wp_login hook priority for this reconciler.
	 *
	 * @return int
	 */
	abstract protected function hookPriority(): int;

	/**
	 * Reconcile the platform's desired state onto the authenticated user.
	 *
	 * @param WP_User $user The authenticated user.
	 * @return void
	 */
	abstract protected function reconcile( WP_User $user ): void;

	/**
	 * Register the wp_login hook.
	 *
	 * @return void
	 */
	public function register(): void {
		add_action( 'wp_login', array( $this, 'onLogin' ), $this->hookPriority(), 2 );
	}

	/**
	 * Delegate to the subclass reconciliation on login.
	 *
	 * Hooked to: wp_login
	 *
	 * @param string  $userLogin The user's login name (unused).
	 * @param WP_User $user      The authenticated user object.
	 * @return void
	 */
	public function onLogin( string $userLogin, WP_User $user ): void { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
		$this->reconcile( $user );
	}
}