Never mind. I figured it out. Apparently, what it does is breaks the array into separate arguments. Hence why only the value of the first element appears. To pass the whole array as an array, you have to wrap that in another array.
--Seth
From: Atkins, Seth (RICH1:5278)
Sent: Tuesday, July 07, 2009 12:32 AM
To: fw-mvc@lists.zend.com
Subject: autoloader issue with reflection class
I'm not sure if this is a possible bug, or just something I don't understand about reflection classes. I've been trying to figure out why my custom validator is losing "data" that I am trying to pass to it in the form of options. I'm trying to pass an array of options.
I've stepped through all the code with a debugger and it seems to be failing at the point that my custom validator is loaded. Up to the point in the code where it creates the instance of the class (see below the snippet from Zend_Form_Element, the _loadValidator method), $validator['options'] carries an array of data. At the point that the __construct method of the custom validator gets it, the array is reduced to just the value of the first array entry. Everything else vanishes. I'm not REAL familiar with reflection classes or how they work, but it looks to me like it is reducing my array of options to just one option.
What am I missing here??
...
$r = new ReflectionClass($name);
if ($r->hasMethod('__construct')) {
$instance = $r->newInstanceArgs((array) $validator['options']);
} else {
$instance = $r->newInstance();
}
if ($r->hasMethod('__construct')) {
$instance = $r->newInstanceArgs((array) $validator['options']);
} else {
$instance = $r->newInstance();
}
...
class My_Validator_DoesntWork extends Zend_Validate_Abstract
{
protected $_options = array();
function __construct($options)
{
$this->_options = $options;
}
{
$this->_options = $options;
}
.....
Seth Atkins
没有评论:
发表评论