-
Notifications
You must be signed in to change notification settings - Fork 2
/
ConfigProvider.php
59 lines (54 loc) · 1.76 KB
/
ConfigProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
declare(strict_types=1);
namespace Psr7Versioning;
/**
* The configuration provider for version middleware
*
* @see https://docs.zendframework.com/zend-component-installer/
*/
class ConfigProvider
{
/**
* @return array
*/
public function __invoke(): array
{
return [
'dependencies' => $this->getDependencies(),
'versioning' => [
// regex patterns to use in Psr7Versioning\VersionMiddleware
// to match path version each regex should include a named
// subpattern in format (?P<name>) for "version"
'path_regex' => [
'#^/v(?P<version>[^/]+).*$#',
],
// regex patterns to use in Psr7Versioning\VersionMiddleware
// to match Accept: header each regex should include named
// subpatterns in format (?P<name>) for "vendor", "version",
// and "resource"
'header_regex' => [
// phpcs:ignore -- this line is too long but that's ok
'#^application/vnd\.(?P<vendor>[^.]+)\.v(?P<version>\d+)(?:\.(?P<resource>[a-zA-Z0-9_-]+))?(?:\+[a-z]+)?$#',
],
// default version settings for Psr7Versioning\VersionMiddleware
'version' => [
'vendor' => 'unk',
'version' => '1',
'resource' => '',
'from' => 'default',
],
],
];
}
/**
* @return array
*/
public function getDependencies(): array
{
return [
'factories' => [
VersionMiddleware::class => VersionMiddlewareFactory::class,
],
];
}
}