-
Notifications
You must be signed in to change notification settings - Fork 169
/
MainController.php
65 lines (49 loc) · 1.7 KB
/
MainController.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
60
61
62
63
64
65
<?php
namespace Sentry\SentryBundle\Test\End2End\App\Controller;
use Sentry\State\HubInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
class MainController
{
/** @var HubInterface */
private $sentry;
/** @var RequestStack */
private $requestStack;
/** @var HttpKernelInterface */
private $kernel;
public function __construct(HubInterface $sentry, RequestStack $requestStack, HttpKernelInterface $kernel)
{
$this->sentry = $sentry;
$this->requestStack = $requestStack;
$this->kernel = $kernel;
}
public function exception(): Response
{
throw new \RuntimeException('This is an intentional error');
}
public function fatal(): Response
{
$foo = eval("return new class() implements \Serializable {};");
return new Response('This response should not happen: ' . json_encode($foo));
}
public function index(): Response
{
$this->sentry->captureMessage('Hello there');
return new Response('Hello there');
}
public function notice(): Response
{
@trigger_error('This is an intentional notice', E_USER_NOTICE);
return new Response('Hello there');
}
public function subrequest(): Response
{
$request = $this->requestStack->getCurrentRequest();
assert($request instanceof Request);
$path['_controller'] = __CLASS__ . '::index';
$subRequest = $request->duplicate([], null, $path);
return $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
}
}