-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCallRuntime.php
More file actions
35 lines (28 loc) · 1.07 KB
/
CallRuntime.php
File metadata and controls
35 lines (28 loc) · 1.07 KB
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
<?php
namespace CommonGateway\CoreBundle\Twig;
use Adbar\Dot;
use CommonGateway\CoreBundle\Service\CallService;
use CommonGateway\CoreBundle\Service\GatewayResourceService;
use Doctrine\ORM\EntityManagerInterface;
use Twig\Extension\RuntimeExtensionInterface;
class CallRuntime implements RuntimeExtensionInterface
{
public function __construct(
private readonly CallService $callService,
private readonly GatewayResourceService $resourceService
) {
}//end __construct()
/**
* Call source of given id or reference
*
* @param array $array The array to turn into a dot array.
*
* @return array The dot aray.
*/
public function call(string $sourceId, string $endpoint, string $method = 'GET', array $configuration = []): array
{
$source = $this->resourceService->getSource($sourceId, 'common-gateway/zgw-to-zds-bundle');
$response = $this->callService->call($source, $endpoint, $method, $configuration);
return $this->callService->decodeResponse($source, $response);
}//end call()
}//end class