mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
|
|
namespace SilverStripe\Control\Tests\RequestHandlingTest;
|
|
|
|
use SilverStripe\Control\HTTPRequest;
|
|
use SilverStripe\Control\HTTPResponse;
|
|
use SilverStripe\Forms\FormRequestHandler;
|
|
|
|
/**
|
|
* Handler for
|
|
* @see TestForm
|
|
*/
|
|
class TestFormHandler extends FormRequestHandler
|
|
{
|
|
private static $url_handlers = [
|
|
'fields/$FieldName' => 'handleField',
|
|
"POST /" => "handleSubmission",
|
|
"GET /" => "handleGet",
|
|
];
|
|
|
|
// These are a different case from those in url_handlers to confirm that it's all case-insensitive
|
|
private static $allowed_actions = [
|
|
'handlesubmission',
|
|
'handlefield',
|
|
'handleget',
|
|
];
|
|
|
|
public function handleField($request)
|
|
{
|
|
return $this->form->Fields()->dataFieldByName($request->param('FieldName'));
|
|
}
|
|
|
|
public function handleSubmission(HTTPRequest $request): HTTPResponse
|
|
{
|
|
return HTTPResponse::create()->setBody("Form posted");
|
|
}
|
|
|
|
public function handleGet(HTTPRequest $request): HTTPResponse
|
|
{
|
|
return HTTPResponse::create()->setBody("Get request on form");
|
|
}
|
|
}
|