mirror of
https://github.com/silverstripe/silverstripe-multiform
synced 2024-10-22 11:05:49 +02:00
FIX: Update class properties to use late static binding
This commit is contained in:
parent
a0187dc133
commit
25f0c051ff
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.DS_Store
|
@ -7,8 +7,9 @@
|
|||||||
*
|
*
|
||||||
* CAUTION: If you're using controller permission control,
|
* CAUTION: If you're using controller permission control,
|
||||||
* you have to allow the following methods:
|
* you have to allow the following methods:
|
||||||
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* static $allowed_actions = array('next','prev');
|
* private static $allowed_actions = array('next','prev');
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @package multiform
|
* @package multiform
|
||||||
@ -120,13 +121,7 @@ abstract class MultiForm extends Form {
|
|||||||
$validator = null;
|
$validator = null;
|
||||||
$applyValidation = true;
|
$applyValidation = true;
|
||||||
|
|
||||||
// Check if the $_REQUEST action that user clicked is an exempt one
|
$actionNames = static::$actions_exempt_from_validation;
|
||||||
// if the Config class is available, use that instead of get_static() which is deprecated in SS 3.x
|
|
||||||
if(class_exists('Config')) {
|
|
||||||
$actionNames = Config::inst()->get(get_class($this), 'actions_exempt_from_validation', Config::FIRST_SET);
|
|
||||||
} else {
|
|
||||||
$actionNames = Object::get_static(get_class($this),'actions_exempt_from_validation');
|
|
||||||
}
|
|
||||||
|
|
||||||
if( $actionNames ) {
|
if( $actionNames ) {
|
||||||
foreach( $actionNames as $exemptAction) {
|
foreach( $actionNames as $exemptAction) {
|
||||||
@ -180,7 +175,7 @@ abstract class MultiForm extends Form {
|
|||||||
* @return MultiFormStep subclass
|
* @return MultiFormStep subclass
|
||||||
*/
|
*/
|
||||||
public function getCurrentStep() {
|
public function getCurrentStep() {
|
||||||
$startStepClass = $this->stat('start_step');
|
$startStepClass = static::$start_step;
|
||||||
|
|
||||||
// Check if there was a start step defined on the subclass of MultiForm
|
// Check if there was a start step defined on the subclass of MultiForm
|
||||||
if(!isset($startStepClass)) user_error('MultiForm::init(): Please define a $startStep on ' . $this->class, E_USER_ERROR);
|
if(!isset($startStepClass)) user_error('MultiForm::init(): Please define a $startStep on ' . $this->class, E_USER_ERROR);
|
||||||
@ -498,7 +493,7 @@ abstract class MultiForm extends Form {
|
|||||||
$currentStep = $this->getCurrentStep();
|
$currentStep = $this->getCurrentStep();
|
||||||
if(is_array($data)) {
|
if(is_array($data)) {
|
||||||
foreach($data as $field => $value) {
|
foreach($data as $field => $value) {
|
||||||
if(in_array($field, $this->stat('ignored_fields'))) {
|
if(in_array($field, static::$ignored_fields)) {
|
||||||
unset($data[$field]);
|
unset($data[$field]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -557,7 +552,7 @@ abstract class MultiForm extends Form {
|
|||||||
public function getAllStepsLinear() {
|
public function getAllStepsLinear() {
|
||||||
$stepsFound = (class_exists('ArrayList')) ? new ArrayList() : new DataObjectSet();
|
$stepsFound = (class_exists('ArrayList')) ? new ArrayList() : new DataObjectSet();
|
||||||
|
|
||||||
$firstStep = DataObject::get_one($this->stat('start_step'), "\"SessionID\" = {$this->session->ID}");
|
$firstStep = DataObject::get_one(static::$start_step, "\"SessionID\" = {$this->session->ID}");
|
||||||
$firstStep->LinkingMode = ($firstStep->ID == $this->getCurrentStep()->ID) ? 'current' : 'link';
|
$firstStep->LinkingMode = ($firstStep->ID == $this->getCurrentStep()->ID) ? 'current' : 'link';
|
||||||
$firstStep->setForm($this);
|
$firstStep->setForm($this);
|
||||||
$stepsFound->push($firstStep);
|
$stepsFound->push($firstStep);
|
@ -12,17 +12,17 @@
|
|||||||
*/
|
*/
|
||||||
class MultiFormSession extends DataObject {
|
class MultiFormSession extends DataObject {
|
||||||
|
|
||||||
static $db = array(
|
private static $db = array(
|
||||||
'Hash' => 'Varchar(40)', // cryptographic hash identification to this session
|
'Hash' => 'Varchar(40)', // cryptographic hash identification to this session
|
||||||
'IsComplete' => 'Boolean' // flag to determine if this session is marked completed
|
'IsComplete' => 'Boolean' // flag to determine if this session is marked completed
|
||||||
);
|
);
|
||||||
|
|
||||||
static $has_one = array(
|
private static $has_one = array(
|
||||||
'Submitter' => 'Member',
|
'Submitter' => 'Member',
|
||||||
'CurrentStep' => 'MultiFormStep'
|
'CurrentStep' => 'MultiFormStep'
|
||||||
);
|
);
|
||||||
|
|
||||||
static $has_many = array(
|
private static $has_many = array(
|
||||||
'FormSteps' => 'MultiFormStep'
|
'FormSteps' => 'MultiFormStep'
|
||||||
);
|
);
|
||||||
|
|
@ -11,11 +11,11 @@
|
|||||||
*/
|
*/
|
||||||
class MultiFormStep extends DataObject {
|
class MultiFormStep extends DataObject {
|
||||||
|
|
||||||
static $db = array(
|
private static $db = array(
|
||||||
'Data' => 'Text' // stores serialized maps with all session information
|
'Data' => 'Text' // stores serialized maps with all session information
|
||||||
);
|
);
|
||||||
|
|
||||||
static $has_one = array(
|
private static $has_one = array(
|
||||||
'Session' => 'MultiFormSession'
|
'Session' => 'MultiFormSession'
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ class MultiFormStep extends DataObject {
|
|||||||
* @return String Classname of a {@link MultiFormStep} subclass
|
* @return String Classname of a {@link MultiFormStep} subclass
|
||||||
*/
|
*/
|
||||||
public function getNextStep() {
|
public function getNextStep() {
|
||||||
$nextSteps = $this->stat('next_steps');
|
$nextSteps = static::$next_steps;
|
||||||
|
|
||||||
// Check if next_steps have been implemented properly if not the final step
|
// Check if next_steps have been implemented properly if not the final step
|
||||||
if(!$this->isFinalStep()) {
|
if(!$this->isFinalStep()) {
|
||||||
@ -231,7 +231,8 @@ class MultiFormStep extends DataObject {
|
|||||||
*/
|
*/
|
||||||
public function getNextStepFromDatabase() {
|
public function getNextStepFromDatabase() {
|
||||||
if($this->SessionID && is_numeric($this->SessionID)) {
|
if($this->SessionID && is_numeric($this->SessionID)) {
|
||||||
$nextSteps = $this->stat('next_steps');
|
$nextSteps = static::$next_steps;
|
||||||
|
|
||||||
if(is_string($nextSteps)) {
|
if(is_string($nextSteps)) {
|
||||||
return DataObject::get_one($nextSteps, "\"SessionID\" = {$this->SessionID}");
|
return DataObject::get_one($nextSteps, "\"SessionID\" = {$this->SessionID}");
|
||||||
} elseif(is_array($nextSteps)) {
|
} elseif(is_array($nextSteps)) {
|
||||||
@ -248,7 +249,7 @@ class MultiFormStep extends DataObject {
|
|||||||
* @return string|array
|
* @return string|array
|
||||||
*/
|
*/
|
||||||
public function getNextSteps() {
|
public function getNextSteps() {
|
||||||
return $this->stat('next_steps');
|
return static::$next_steps;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -336,7 +337,7 @@ class MultiFormStep extends DataObject {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function canGoBack() {
|
public function canGoBack() {
|
||||||
return $this->stat('can_go_back');
|
return static::$can_go_back;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -346,7 +347,7 @@ class MultiFormStep extends DataObject {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isFinalStep() {
|
public function isFinalStep() {
|
||||||
return $this->stat('is_final_step');
|
return static::$is_final_step;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@ -99,7 +99,7 @@ class MultiFormTest_Form extends MultiForm implements TestOnly {
|
|||||||
public static $start_step = 'MultiFormTest_StepOne';
|
public static $start_step = 'MultiFormTest_StepOne';
|
||||||
|
|
||||||
function getStartStep() {
|
function getStartStep() {
|
||||||
return $this->stat('start_step');
|
return self::$start_step;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user