Skip to content

Commit

Permalink
API Make ElementalAreaController a subclass of FormSchemaController (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Nov 19, 2024
1 parent b77d664 commit 2791227
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/Controllers/ElementalAreaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use DNADesign\Elemental\Forms\EditFormFactory;
use DNADesign\Elemental\Models\BaseElement;
use DNADesign\Elemental\Services\ElementTypeRegistry;
use SilverStripe\CMS\Controllers\CMSMain;
use SilverStripe\Control\HTTPResponse;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Forms\Form;
Expand All @@ -20,17 +19,18 @@
use Exception;
use SilverStripe\Control\HTTPRequest;
use InvalidArgumentException;
use SilverStripe\Admin\FormSchemaController;

/**
* Controller for "ElementalArea" - handles loading and saving of in-line edit forms in an elemental area in admin
*/
class ElementalAreaController extends CMSMain
class ElementalAreaController extends FormSchemaController
{
const FORM_NAME_TEMPLATE = 'ElementForm_%s';

private static $url_segment = 'elemental-area';

private static $ignore_menuitem = true;
private static string $required_permission_codes = 'CMS_ACCESS';

private static $url_handlers = [
'elementForm/$ItemID' => 'elementForm',
Expand Down
8 changes: 4 additions & 4 deletions tests/Controllers/ElementalAreaControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class ElementalAreaControllerTest extends FunctionalTest
{
protected static $fixture_file = 'ElementalAreaControllerTest.yml';

protected static $extra_dataobjects = [
TestElementContent::class,
TestElementalArea::class,
Expand Down Expand Up @@ -180,9 +180,9 @@ public function testElementFormPost(string $idType, string $dataType, string $fa
$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 2791227

Please sign in to comment.