<?php

declare(strict_types=1);

namespace ReallySimplePlugins\RSS\Core\Features\Pro\Vulnerability;

use ReallySimplePlugins\RSS\Core\Features\Pro\Vulnerability\Controllers\VulnerabilityMeasuresConfigController;
use ReallySimplePlugins\RSS\Core\Features\Pro\Vulnerability\Controllers\VulnerabilityMeasuresController;
use ReallySimplePlugins\RSS\Core\Interfaces\FeatureInterface;

/**
 * Registers Pro vulnerability-measures controllers (force update / quarantine).
 *
 * Notes:
 * - The Free Vulnerability feature owns syncing & storage.
 * - The Pro feature reacts to sync completion and applies automated measures.
 */
final class VulnerabilityController implements FeatureInterface
{
    /**
     * Register hooks for Pro controllers.
     */
    public function register(): void
    {
        add_filter('rss_core_controller_classes', [$this, 'registerControllers']);
    }

    /**
     * Registers the controllers related to vulnerability management. This
     * method is hooked into the 'rss_core_controller_classes' filter, that
     * is applied here {@see Plugin::registerControllers}, to make sure the
     * {@see ControllerManager} can register them in the plugin lifecycle.
     */
    public function registerControllers(array $existingControllers): array
    {
        $availableControllers = [
            VulnerabilityMeasuresConfigController::class,
            VulnerabilityMeasuresController::class,
        ];
        return array_merge($existingControllers, $availableControllers);
    }
}
