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:
Johannes Meyer 2014-07-18 09:43:03 +02:00
parent 58188c5cc1
commit 37fd3deb67
1 changed files with 20 additions and 16 deletions

View File

@ -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
*