Move all domain folders from src/AKSRT/{Domain} to src/{Domain}; remap
Composer PSR-4 "AKSRT\\": "src/"; update audit script + README + ADR
paths; remove dead tools/build-psr4-map.php (scanned deleted inc/classes).
49 lines
1.5 KiB
PHP
49 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* Identity verification lifecycle.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
namespace AKSRT\Identity;
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
final class Identity {
|
|
|
|
private static ?self $instance = null;
|
|
|
|
public static function get_instance(): self {
|
|
return self::$instance ??= new self();
|
|
}
|
|
|
|
public function init(): void {
|
|
add_action('rest_api_init', [new RestController(), 'register_routes']);
|
|
add_action('rest_api_init', [new CallbackController(), 'register_routes']);
|
|
(new EvidenceService())->init();
|
|
add_action('init', [$this, 'ensure_reviewer_capability']);
|
|
add_action('delete_user', [$this, 'delete_user_data']);
|
|
}
|
|
|
|
public function ensure_reviewer_capability(): void {
|
|
$role = get_role('administrator');
|
|
if ($role && !$role->has_cap('aksrt_review_identity')) {
|
|
$role->add_cap('aksrt_review_identity');
|
|
}
|
|
}
|
|
|
|
public function delete_user_data(int $user_id): void {
|
|
global $wpdb;
|
|
$applications = \AKSRT\Core\DBMigrator::table('identity_application');
|
|
$events = \AKSRT\Core\DBMigrator::table('identity_event');
|
|
if ($applications === '' || $events === '') {
|
|
return;
|
|
}
|
|
$ids = $wpdb->get_col($wpdb->prepare("SELECT id FROM {$applications} WHERE user_id = %d", $user_id));
|
|
foreach ((array) $ids as $id) {
|
|
$wpdb->delete($events, ['application_id' => (int) $id], ['%d']);
|
|
}
|
|
$wpdb->delete($applications, ['user_id' => $user_id], ['%d']);
|
|
}
|
|
}
|