<?php
/**
 * Activity Log Module.
 *
 * Records notable site actions (logins, content changes, settings changes, role
 * changes, and Helm link edits) to a custom table, viewable under Helm →
 * Activity Log. Detailed by default.
 *
 * The table is preserved on uninstall unless the user opts in to full data
 * removal (handled in uninstall.php), per the safe-lifecycle policy.
 *
 * @package Platform\Helm\Modules\Activity_Log
 */

declare( strict_types = 1 );

namespace Platform\Helm\Modules\Activity_Log;

use Platform\Helm\Contracts\ModuleInterface;

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

final class ActivityLogModule implements ModuleInterface {

	private ActivityLogger $logger;
	private EventCollector $collector;
	private ActivityLogPage $page;
	private ActivityMaintenance $maintenance;

	public function __construct() {
		$this->logger      = new ActivityLogger();
		$this->collector   = new EventCollector( $this->logger );
		$this->page        = new ActivityLogPage( $this->logger );
		$this->maintenance = new ActivityMaintenance( $this->logger );
	}

	public function id(): string {
		return 'activity_log';
	}

	public function name(): string {
		return __( 'Activity Log', 'platform-helm' );
	}

	public function description(): string {
		return __( 'Records notable actions — logins, content changes, settings and role changes, and Helm link edits — to a searchable log under Helm → Activity Log.', 'platform-helm' );
	}

	public function default_enabled(): bool {
		return false;
	}

	public function boot(): void {
		$this->logger->maybe_install();
		$this->collector->register_hooks();
		$this->page->register_hooks();
		$this->maintenance->register_hooks();
	}
}
