Files
shlink/module/Rest/src/ConfigProvider.php
T

32 lines
708 B
PHP
Raw Normal View History

2016-07-19 17:07:59 +02:00
<?php
2017-10-12 10:13:20 +02:00
declare(strict_types=1);
2016-07-19 17:07:59 +02:00
namespace Shlinkio\Shlink\Rest;
use Zend\Config\Factory;
use Zend\Stdlib\Glob;
class ConfigProvider
{
2018-01-07 20:45:05 +01:00
const ROUTES_PREFIX = '/rest/v{version:1}';
2016-07-19 17:07:59 +02:00
public function __invoke()
{
2018-01-07 20:45:05 +01:00
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;
2016-07-19 17:07:59 +02:00
}
}