Skip to content

Commit

Permalink
API Make LinkFieldController a subclass of FormSchemaController
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Nov 14, 2024
1 parent 06636c4 commit e52f39a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/Controllers/LinkFieldController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace SilverStripe\LinkField\Controllers;

use SilverStripe\Admin\LeftAndMain;
use SilverStripe\Admin\FormSchemaController;
use SilverStripe\Control\HTTPResponse;
use SilverStripe\Forms\DefaultFormFactory;
use SilverStripe\Forms\Form;
Expand All @@ -25,14 +25,12 @@
use SilverStripe\ORM\Queries\SQLUpdate;
use SilverStripe\Versioned\Versioned;

class LinkFieldController extends LeftAndMain
class LinkFieldController extends FormSchemaController
{
public const FORM_NAME_TEMPLATE = 'LinkForm_%s';

private static string $url_segment = 'linkfield';

private static $ignore_menuitem = true;

private static array $url_handlers = [
'linkForm/$ItemID' => 'linkForm',
'GET data/$ItemID' => 'linkData',
Expand Down
6 changes: 3 additions & 3 deletions tests/php/Controllers/LinkFieldControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ public function testLinkFormPost(
$response = $this->post($url, $data, $headers);
$this->assertSame($expectedCode, $response->getStatusCode());
if ($fail === 'csrf-token') {
// Will end up at an HTML page with "Silverstripe - Bad Request"
$this->assertSame('text/html; charset=utf-8', $response->getHeader('Content-type'));
$this->assertStringContainsString('Silverstripe - Bad Request', $response->getBody());
// Gives suitable error message for XHR request
$this->assertStringStartsWith('text/plain', $response->getHeader('Content-type'));
$this->assertStringContainsString('There seems to have been a technical problem', $response->getBody());
return;
}
$this->assertSame($expectedCode, $response->getStatusCode());
Expand Down

0 comments on commit e52f39a

Please sign in to comment.