Violet88github /
silverstripe-bugsnag-module-vue
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Violet88\BugsnagModule; |
||
| 4 | |||
| 5 | use Psr\Container\NotFoundExceptionInterface; |
||
| 6 | use RuntimeException; |
||
| 7 | use SilverStripe\Control\Controller; |
||
| 8 | use SilverStripe\Control\HTTPResponse; |
||
| 9 | use SilverStripe\Core\Injector\Injector; |
||
| 10 | |||
| 11 | class BugsnagController extends Controller |
||
| 12 | { |
||
| 13 | private static $allowed_actions = [ |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 14 | 'build', |
||
| 15 | 'initial' |
||
| 16 | ]; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Simply sends the given release to Bugsnag, to be used in CLI. |
||
| 20 | * |
||
| 21 | * @throws NotFoundExceptionInterface |
||
| 22 | */ |
||
| 23 | public function build(): HTTPResponse |
||
| 24 | { |
||
| 25 | $repository = $_GET['repository'] ?? null; |
||
| 26 | $revision = $_GET['revision'] ?? null; |
||
| 27 | $provider = $_GET['provider'] ?? null; |
||
| 28 | $builderName = $_GET['builderName'] ?? null; |
||
| 29 | $appVersion = $_GET['revision'] ?? null; |
||
| 30 | |||
| 31 | $bugsnag = Injector::inst()->get(Bugsnag::class); |
||
| 32 | $bugsnag |
||
| 33 | ->setAppVersion($appVersion) |
||
| 34 | ->notifyBuild($repository, $revision, $provider, $builderName); |
||
| 35 | |||
| 36 | $response = new HTTPResponse(); |
||
| 37 | $response->setStatusCode(200); |
||
| 38 | return $response; |
||
| 39 | } |
||
| 40 | |||
| 41 | public function initial() |
||
| 42 | { |
||
| 43 | $bugsnag = Injector::inst()->get(Bugsnag::class); |
||
| 44 | $bugsnag->sendException(new RuntimeException("Test error")); |
||
| 45 | } |
||
| 46 | } |
||
| 47 |