ENHANCEMENT Added BankAccountField::is_valid_array_structure() to avoid PHP Notices when converting empty array values

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@64305 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-10-15 12:57:17 +00:00
parent c8c9c2166d
commit dada15629a

View File

@ -71,7 +71,23 @@ class BankAccountField extends FormField {
}
}
/**
/**
* Checks for a valid array structure.
*
* @param array $arr
* @return boolean
*/
protected static function is_valid_array_structure($arr) {
return (
is_array($arr)
&& array_key_exists('BankCode', $arr)
&& array_key_exists('BranchCode', $arr)
&& array_key_exists('AccountNumber', $arr)
&& array_key_exists('AccountSuffix', $arr)
);
}
/**
* @return string
*/
function getBankCode() {
@ -217,8 +233,10 @@ JS;
$valueArr['AccountNumber'],
$valueArr['AccountSuffix']
) = explode(" ",$value);
} else {
} elseif(self::is_valid_array_structure($value)) {
$valueArr = $value;
} else {
return false;
}
if(strlen(trim($valueArr['AccountNumber'])) == 7) {