-
Notifications
You must be signed in to change notification settings - Fork 10
/
DomainService.php
38 lines (32 loc) · 1.11 KB
/
DomainService.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
<?php
namespace go1\app;
use go1\app\App as GO1;
use Pimple\ServiceProviderInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
class DomainService extends GO1
{
const NAME = SERVICE_NAME;
const VERSION = SERVICE_VERSION;
public function __construct($values = [])
{
$serviceProviders = $values['serviceProviders'] ?? [];
unset($values['serviceProviders']);
parent::__construct($values);
// register configured service providers
foreach ($serviceProviders as $serviceProvider) {
$serviceProvider instanceof ServiceProviderInterface
? $this->register($serviceProvider)
: $this->register($serviceProvider[0], $serviceProvider[1]);
}
// default endpoint
$this->get('/', function () {
return new JsonResponse([
'service' => static::NAME,
'version' => static::VERSION,
'tag' => getenv('DD_VERSION') ?: '',
'env' => getenv('DD_ENV') ?: '',
'time' => time(),
]);
});
}
}