From 9db76bf371247bd000506ca2cfbc116c4e57df0f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 6 Oct 2014 10:19:36 +0200 Subject: [PATCH] CsrfCounterMeasure: Save calls to `setRequired()' and `setIgnore()' --- .../Web/Form/Element/CsrfCounterMeasure.php | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/library/Icinga/Web/Form/Element/CsrfCounterMeasure.php b/library/Icinga/Web/Form/Element/CsrfCounterMeasure.php index 722b1d3232..e9bc37eddd 100644 --- a/library/Icinga/Web/Form/Element/CsrfCounterMeasure.php +++ b/library/Icinga/Web/Form/Element/CsrfCounterMeasure.php @@ -4,8 +4,8 @@ namespace Icinga\Web\Form\Element; -use Zend_Form_Element_Xhtml; use Icinga\Web\Session; +use Icinga\Web\Form\FormElement; use Icinga\Web\Form\InvalidCSRFTokenException; /** @@ -13,7 +13,7 @@ * * You must not set a value to successfully use this element, just give it a name and you're good to go. */ -class CsrfCounterMeasure extends Zend_Form_Element_Xhtml +class CsrfCounterMeasure extends FormElement { /** * Default form view helper to use for rendering @@ -22,14 +22,26 @@ class CsrfCounterMeasure extends Zend_Form_Element_Xhtml */ public $helper = 'formHidden'; + /** + * Counter measure element is required + * + * @var bool + */ + protected $_ignore = true; + + /** + * Ignore element when retrieving values at form level + * + * @var bool + */ + protected $_required = true; + /** * Initialize this form element */ public function init() { - $this->setRequired(true); // Not requiring this element would not make any sense - $this->setIgnore(true); // We do not want this element's value being retrieved by Form::getValues() - $this->setDecorators(array('ViewHelper')); + $this->addDecorator('ViewHelper'); $this->setValue($this->generateCsrfToken()); }