generated from xaraya-modules/skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestController.php
38 lines (34 loc) · 1.28 KB
/
TestController.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
/**
* @see https://github.com/symfony/symfony/blob/7.0/src/Symfony/Component/Webhook/Controller/WebhookController.php
* @see https://github.com/spatie/laravel-webhook-client/blob/main/src/Http/Controllers/WebhookController.php
*/
namespace Xaraya\Modules\Webhooks\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* Webhook Test Controller
* independent of the Symfony Webhook + RemoteEvent + Messenger combo
* or the Laravel (Spatie) Webhook Client Controller + Processor + ...
*/
class TestController
{
public function __construct(array $config = []) {}
/**
* @param array<string, mixed> $pathParams from FastRoute dispatcher (optional)
*/
public function handle(mixed $type, Request $request, array $pathParams = []): Response
{
//$type = $request->query->get('type', 'webhook');
// ...
// Re-use modules ItemCreate event
// $item = array('module' => $module, 'itemid' => $itemid [, 'itemtype' => $itemtype, ...]);
// xarHooks::notify('ItemCreate', $item);
// ...
if (empty($type)) {
$type = 'world';
}
$name = rawurlencode(ucwords($request->get('name', $type)));
return new Response("Hello, {$name}!");
}
}