I am creating a custom validator in Zend framework.
const MSG_MINIMUM = 'msgMinimum';
const MSG_MAXIMUM = 'msgMaximum';
const MSG_NUMERIC = 'msgNumeric';
protected $_config = null;
protected $_min = 0;
protected $_max = 0;
protected $_messageTemplates = array(
self::MSG_MINIMUM => "You must have at least ".$this->_min." selected",
self::MSG_MAXIMUM => "Too many, ".$this->_max." selected",
self::MSG_NUMERIC => "'%value%' is not a valid number"
);
public function __construct(Zend_Config $config)
{
$this->_config = $config;
$this->_min = $this->_config->limit->orderMin;
$this->_max = $this->_config->limit->orderMax;
}
Any idea why this line is a syntax error?
self::MSG_MINIMUM => "You must have at least ".$this->_min." selected",
I have a feeling I am breaking class rules.
Property declarations in the body of the class cannot contain expressions. They must be static values only. You would have to initialise
$_messageTemplatesin the constructor.Like this: