mirror of
https://github.com/shlinkio/shlink.git
synced 2026-08-01 09:07:54 -05:00
32 lines
708 B
PHP
32 lines
708 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Shlinkio\Shlink\Rest;
|
|
|
|
use Zend\Config\Factory;
|
|
use Zend\Stdlib\Glob;
|
|
|
|
class ConfigProvider
|
|
{
|
|
const ROUTES_PREFIX = '/rest/v{version:1}';
|
|
|
|
public function __invoke()
|
|
{
|
|
return $this->applyRoutesPrefix(
|
|
Factory::fromFiles(Glob::glob(__DIR__ . '/../config/{,*.}config.php', Glob::GLOB_BRACE))
|
|
);
|
|
}
|
|
|
|
private function applyRoutesPrefix(array $config): array
|
|
{
|
|
$routes =& $config['routes'] ?? [];
|
|
|
|
// Prepend the routes prefix to every path
|
|
foreach ($routes as $key => $route) {
|
|
$routes[$key]['path'] = self::ROUTES_PREFIX . $route['path'];
|
|
}
|
|
|
|
return $config;
|
|
}
|
|
}
|