FIX Replace static session getter for the current page ID

This commit is contained in:
Robbie Averill 2017-09-04 16:56:42 +12:00
parent faf04bff43
commit 9929284a9b

View File

@ -2,12 +2,12 @@
namespace SilverStripe\UserForms\Model\Recipient; namespace SilverStripe\UserForms\Model\Recipient;
use SilverStripe\Admin\LeftAndMain;
use SilverStripe\Assets\FileFinder; use SilverStripe\Assets\FileFinder;
use SilverStripe\CMS\Controllers\CMSMain; use SilverStripe\CMS\Controllers\CMSMain;
use SilverStripe\CMS\Controllers\CMSPageEditController; use SilverStripe\CMS\Controllers\CMSPageEditController;
use SilverStripe\Control\Controller; use SilverStripe\Control\Controller;
use SilverStripe\Control\Email\Email; use SilverStripe\Control\Email\Email;
use SilverStripe\Control\Session;
use SilverStripe\Core\Manifest\ModuleLoader; use SilverStripe\Core\Manifest\ModuleLoader;
use SilverStripe\Forms\CheckboxField; use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\DropdownField; use SilverStripe\Forms\DropdownField;
@ -118,9 +118,12 @@ class EmailRecipient extends DataObject
*/ */
protected function getFormParent() protected function getFormParent()
{ {
// LeftAndMain::sessionNamespace is protected. @todo replace this with a non-deprecated equivalent.
$sessionNamespace = $this->config()->get('session_namespace') ?: LeftAndMain::class;
$formID = $this->FormID $formID = $this->FormID
? $this->FormID ? $this->FormID
: Session::get('CMSMain.currentPage'); : Controller::curr()->getRequest()->getSession()->get($sessionNamespace . '.currentPage');
return UserDefinedForm::get()->byID($formID); return UserDefinedForm::get()->byID($formID);
} }