<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Compatibility;

use PpPhp\Core\Platform\Compatibility\Adapters\LegacyDesignerAdapter;
use PpPhp\Core\Platform\Compatibility\Adapters\LegacyIconAdapter;
use PpPhp\Core\Platform\Compatibility\Adapters\LegacyIdentityAdapter;
use PpPhp\Core\Platform\Compatibility\Adapters\LegacyManifestAdapter;
use PpPhp\Core\Platform\Compatibility\Adapters\LegacyMetadataAdapter;
use PpPhp\Core\Platform\Compatibility\Adapters\LegacyRegistryAdapter;
use PpPhp\Core\Platform\Services\Registry\RegistryCollection;

final class CompatibilityServiceProvider
{
    public function register(RegistryCollection $registries): CompatibilityRegistry
    {
        $registry = new CompatibilityRegistry();

        $adapters = [
            new LegacyRegistryAdapter($registries),
            new LegacyManifestAdapter(),
            new LegacyMetadataAdapter(),
            new LegacyIdentityAdapter(),
            new LegacyDesignerAdapter(),
            new LegacyIconAdapter(),
        ];

        foreach ($adapters as $adapter) {
            $registry->register($adapter);
            $registry->addNotice($adapter->notice(removeAfter: 'R0100 phased removal'));
        }

        return $registry;
    }
}
