Rename initCsrfToken to addCsrfToken and move it upwards
Form::addCsrfToken() should be public and fluent to ensure more flexibility. refs #5525
This commit is contained in:
parent
58188c5cc1
commit
37fd3deb67
|
@ -157,6 +157,26 @@ class Form extends Zend_Form
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add CSRF counter measure field to this form
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function addCsrfToken()
|
||||
{
|
||||
if (false === $this->tokenDisabled && $this->getElement($this->tokenElementName) === null) {
|
||||
$this->addElement(
|
||||
'hidden',
|
||||
$this->tokenElementName,
|
||||
array(
|
||||
'value' => $this->generateCsrfToken()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the default decorators
|
||||
*
|
||||
|
@ -184,22 +204,6 @@ class Form extends Zend_Form
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add CSRF counter measure field to this form
|
||||
*/
|
||||
protected function initCsrfToken()
|
||||
{
|
||||
if (false === $this->tokenDisabled && $this->getElement($this->tokenElementName) === null) {
|
||||
$this->addElement(
|
||||
'hidden',
|
||||
$this->tokenElementName,
|
||||
array(
|
||||
'value' => $this->generateCsrfToken()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a new (seed, token) pair
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue