<?php

namespace AutoAdmin\Bundle\Admin\Routing;

use Symfony\Component\Config\Loader\Loader;
use Symfony\Component\Routing\RouteCollection;

class RouteLoader extends Loader
{
    public function load(mixed $resource, string $type = null): RouteCollection
    {
        $collection = new RouteCollection();

        $resources = [
            ['path' => '@AutoAdminBundle/Admin/Resources/config/auto_loaded_routing.yaml', 'type' => 'yaml'],
            ['path' => '@AutoAdminBundle/Media/Resources/config/auto_loaded_routing.yaml', 'type' => 'yaml'],
        ];

        foreach ($resources as $resource) {
            $importedRoutes = $this->import($resource['path'], $resource['type']);

            $collection->addCollection($importedRoutes);
        }

        return $collection;
    }

    public function supports(mixed $resource, string $type = null): bool
    {
        return $type === 'aa';
    }
}
