-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathPostProcessApiEvent.php
More file actions
40 lines (35 loc) · 1.26 KB
/
PostProcessApiEvent.php
File metadata and controls
40 lines (35 loc) · 1.26 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
36
37
38
39
40
<?php
namespace DreamFactory\Core\Events;
use DreamFactory\Core\Contracts\ServiceRequestInterface;
use DreamFactory\Core\Contracts\ServiceResponseInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\StreamedResponse;
class PostProcessApiEvent extends InterProcessApiEvent
{
public $request;
public $response;
/**
* Create a new event instance.
*
* @param string $path
* @param ServiceRequestInterface $request
* @param ServiceResponseInterface $response
* @param mixed $resource
*/
public function __construct($path, $request, &$response, $resource = null)
{
$this->request = $request;
$this->response = $response;
$name = strtolower($path . '.' . str_replace('/', '.', $resource) . '.' . $request->getMethod()) . '.post_process';
parent::__construct($name, $resource);
}
public function makeData()
{
return [
'request' => $this->request->toArray(),
'resource' => $this->resource,
'response' => ($this->response instanceof RedirectResponse || $this->response instanceof StreamedResponse)
? [] : $this->response->toArray()
];
}
}