<?php

namespace Foxstudio\Plugins\Template\Utils;

function mapAndIncludeFiles($folderPath)
{
    $files = scandir($folderPath);
    foreach ($files as $file) {
        if ($file != '.' && $file != '..') {
            if (is_file($folderPath . $file)) {
                // Check if the file is a PHP file
                if (pathinfo($folderPath . $file, PATHINFO_EXTENSION) == 'php') {
                    // Include the PHP file
                    echo $folderPath . $file;
                    include_once $folderPath . $file;
                }
            } elseif (is_dir($folderPath . $file)) {
                // Recursively call mapAndIncludeFiles for subdirectories
                mapAndIncludeFiles($folderPath . $file . '/');
            }
        }
    }
}