diff --git a/src/Ajax/Ex/AjaxControllerEx.php b/src/Ajax/Ex/AjaxControllerEx.php index 8d6b3af..4af4c2e 100755 --- a/src/Ajax/Ex/AjaxControllerEx.php +++ b/src/Ajax/Ex/AjaxControllerEx.php @@ -2,19 +2,21 @@ namespace A2nt\CMSNiceties\Ajax\Ex; +use SilverStripe\CMS\Model\RedirectorPage; use SilverStripe\Control\Controller; use SilverStripe\Control\Director; -use SilverStripe\Control\HTTPRequest; use SilverStripe\Control\HTTPResponse; use SilverStripe\Core\Config\Config; use SilverStripe\Core\Extension; use SilverStripe\Core\Injector\Injector; +use SilverStripe\ErrorPage\ErrorPage; use SilverStripe\Forms\Form; use SilverStripe\Forms\HiddenField; use SilverStripe\ORM\FieldType\DBHTMLText; use SilverStripe\ORM\ValidationResult; use SilverStripe\Security\MemberAuthenticator\MemberAuthenticator; use SilverStripe\Security\Security; +use SilverStripe\UserForms\Control\UserDefinedFormController; use SilverStripe\View\SSViewer; /** @@ -270,4 +272,25 @@ class AjaxControllerEx extends Extension $response->setBody($body); } + + + public function isLegacy() + { + $object = $this->owner; + + if ( + is_a($object, UserDefinedFormController::class) + && $object->getAction() === 'finished' + ) { + return true; + } + + return $object->config()->get('legacy') || in_array( + $object->ClassName, + [ + RedirectorPage::class, + ErrorPage::class, + ] + ); + } }